title: Error:The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect
body: <p>I am using</p>
  
  <ul>
  <li>Windows 7  </li>
  <li>Netbeans IDE 7.1.2  </li>
  <li>SQL Server Management Studio Express 2005  </li>
  <li>JDK1.6</li>
  </ul>
  
  <p>I am getting the below error while connecting to the database:</p>
  
  <blockquote>
    <p>com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host  has failed. java.net.ConnectException: Connection refused: connect  </p>
  </blockquote>
  
  <p>My connection string is: </p>
  
  <pre><code>Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");  
  Connection connection = DriverManager.getConnection(  
      "jdbc:sqlserver://127.0.0.1:1433;databaseName=dbcm;" +  
      "user=sa;password=sa");
  </code></pre>
  
  <p>I've checked below things:  </p>
  
  <ol>
  <li>In SQL Server Configuration Manager, Protocols for SQLEXPRESS : TCP/IP Enabled
  In fact I made enable remaining 3 too.  </li>
  <li>SQL Server(SQLExpress) and SQL Browser Service both are running.</li>
  </ol>