JDBC: Simple MSSql connection example not working

OK, so here’s what solved my problems:

  1. Download latest MSSQL JDBC driver from here:
    http://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx

  2. Referenced the 2 JAR files in my project:
    sqljdbc.jar and
    sqljdbc4.jar (I’m not yet sure if both of the above are required or just one..)

  3. Make sure the SQL Server Browser windows service is running

  4. Open SQL Server Configuration Manager and go to Protocols for SQLEXPRESS under SQL Server Network Configuration. Right-click on TCP/IP and choose Properties. Set Enabled = YES.

  5. While you’re there, click on IP Addresses tab and find the section IP All. Set TCP Port to 1433.

  6. Add sqljdbc_auth.dll to your PATH Environment Variable. In my case: D:\Java\sqljdbc_4.0\enu\auth\x64

  7. Copy the sqljdbc_auth.dll to your JDK directory. In my case: C:\Program Files\Java\jdk1.7.0_04\bin

I hope this helps someone.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)