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: , , , , , , , ,

Related posts:

  1. SQL Server Who Lock
  2. SQL Server Query Shortcuts
  3. Create SQL Server Database and Database Tables From a File
  4. Desc SQL Tables
  5. TechKnow Year In Review 2005

This entry was posted in Java, SQL, TechKnow. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. afsina
    Posted February 3, 2007 at 8:24 pm | Permalink

    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. Posted February 12, 2007 at 12:27 pm | Permalink

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

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*