JDBC and SQL Server 2005

Here is a quick tip. If your Java application is connecting to SQL Server 2005 via JDBC and you get a connection exception, check your that SQL Server has its TCP/IP protocol enabled. It took me a bit of digging to realize this when setting up a new test server. Here are the steps. Open the SQL Server Configuration Manager. In the configuration manager drill down to SQL Server Configuration Manager > SQL SErver 2005 Network Configuration > Protocols for SQLEXPRESS. Verify that the TCP/IP protocol is enabled. I also had to set the correct port number, 1433, in the TCP/IP Properties. After this, I was able to connect to SQL Server 2005 via JDBC.

Since I am on the subject, if you are working with a Java application and want to support SQL Server I recommend you use the jTDS JDBC driver.

Technorati Tags: , , , , , , , ,

Rails Named Routes »
« Jakarta Commons Lang Builders
 
Related Posts
Recent Posts
 

2 Comments so far

  1. afsina on February 3rd, 2007

    And an extra tip from me, for JTDS: if you want to have faster queries, add this to the connection URL: sendStringParametersAsUnicode=false

    If you are profiling the database, add prepareSQL=0 to see the queries in the profiler application..

  2. TechKnow on February 12th, 2007

    @afsina - Those are great tips. I wrote about jTDS in passing and forgot to mention that too. Thanks.

Leave a reply