简体   繁体   中英

JDBC Connection Exception with MS SQL Server 2008

I am using windows server 2003 on VM vare on which I have my database on MS SQL Server 2008 . Now when I used jdbc driver to connect my java code with database I am getting following exception. Kindly give some solution .

Exception in thread "main" java.lang.UnsatisfiedLinkError: com.microsoft.sqlserver.jdbc.AuthenticationJNI.SNISecGenClientContext([B[I[BI[B[I[ZLjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/util/logging/Logger;)I
    at com.microsoft.sqlserver.jdbc.AuthenticationJNI.SNISecGenClientContext(Native Method)
    at com.microsoft.sqlserver.jdbc.AuthenticationJNI.GenerateClientContext(AuthenticationJNI.java:80)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2691)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2234)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2220)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1326)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at test.jdbcdemo.main(jdbcdemo.java:24)

You have enabled integratedSecurity . This means that the sqljdbc_auth.dll needs to be on the library path of the jvm.

Most likely you do not have this library on your path, it is the wrong version or the wrong variant (x86 <> x64 <> IA64).

An old question but I had this issue today. I don't know the first thing about Java but for me the fix was to copy Microsoft's JDBC driver to Java's ext folder.

sqljdbc41.jar needs to be copied to C:\\[path to java installation]\\Java\\jre7\\lib\\ext\\

Make sure you pick the right version (x86 or x64).

Also for Integrated Security I needed to make a reference to auth when starting my application.

-Djava.library.path=C:\[Path to Microsoft JDBC Driver 4.1 for SQLServer]\sqljdbc_4.1\enu\auth\x86

I had the same exception when starting SpringBatch with an JdbcBatchItemWriter writing to MS SQL Server 2008.

Sqljdbc_auth.dll was on the library path. It turned out that I was running my SpringBatch application in Eclipse with JRE 1.6. I solved this by running it with JRE 1.7 (Eclipse JRE-Tab in Run-Configurations).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM