title: JDBC connection Url for SQLServer express R2
body: <p>I wrote the below line for connection with sql server express r2:</p>
  
  <p>Connection con=DriverManager.getConnection("jdbc:sqlserver://localhost/SQLEXPRESS;databaseName=abc","sa","password");</p>
  
  <p>It is giving exception:
  com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost/SQLEXPRESS, port 1433 has failed. Error: "null. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".</p>
  
  <p>I followed the line to solve the exception:</p>
  
  <p>TCP/IP for SQL Server Express
  By default, TCP/IP for SQL Server Express is disabled, so JDBC cannot connect to it and you may get the following exception …</p>
  
  <p>Network error IOException: Connection refused: connect
  Enable TCP/IP</p>
  
  <p>To enable TCP/IP, start SQL Server Configuration Manager.</p>
  
  <p>Expand SQL Server 2005 Network Configuration node.
  In the right pane, select Protocols for SQLEXPRESS. The right pane should now show Protocols and Status columns.
  Select Enable from the TCP/IP context menu.
  Find or Configure TCP/IP Port</p>
  
  <p>After enabling TCP/IP, you have to find out which port number to use. SQL Server Express allocates a port dynamically each time it is started, so to find or configure the port number, continue using SQL Server Configuration Manager …</p>
  
  <p>Select Properties from the TCP/IP context menu. The TCP/IP Properties dialog should open.
  Select the IP Addresses tab.
  In the IPAll node …
  The TCP Dynamic Ports field shows the currently used port number. If you set that field to blank, then SQL Server Express should not automatically choose another port when it restarts.
  Set the desired port number in the TCP Port field.
  Press OK to apply your settings and close the dialog.</p>
  
  <p>After that also connection giving  same exception.</p>