แก้ไข JAVA JDBC MSSql connection ไม่ได้
แก้ไข JAVA JDBC MSSql connection ไม่ได้
- Download latest MSSQL JDBC driver from here: http://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx
- 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..)
- Make sure the SQL Server Browser windows service is running
- 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.
- While you're there, click on IP Addresses tab and find the section IP All. Set TCP Port to 1433.
- Add sqljdbc_auth.dll to your PATH Environment Variable. In my case:D:\Java\sqljdbc_4.0\enu\auth\x64
- 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.
ที่มา: http://stackoverflow.com/questions/12523865/jdbc-simple-mssql-connection-example-not-working