Total Pageviews

Monday, July 09, 2007

Connecting to a Microsoft SQLServer Express 2005 database via JDBC

I discovered a few stepstones when connecting via JDBC to a locally installed SQLSever Express 2005 database. Here are my observations:
  • Activate "Accepting TCP/IP" connections in the SQL Server Configuration Manager. Otherwise the SQLServer Express database won't accept any JDBC connections. This option was disabled in my configuration. Also make sure to use a static TCP/IP port, otherwise (when choosing a dynamic) the port might change on every start of the SQLServer database.
  • When using Microsofts JDBC driver (not recommended) the following two steps should be considered:
  • Copy the file sqljdbc_auth.dll that is packaged within the JDBC driver archive to a location that is part of you PATH variable, e.g. c:/winnt/system32.
  • Open the Microsoft SQL Server Management Studio application and create a new database user account. Be careful not to choose an existing windows account name, but to create a new SQLServer account. Otherwise you might have a chance to run into an error when trying to login via JDBC. Possible error messages and their status codes are described under http://blogs.msdn.com/sql_protocols/archive/2006/02/21/536201.aspx.