eplise连接mysql2008r2,在eclipse中解决sql server 2008 r2与java之间的连接错误

I am trying to connect SQL server 2008 r2 with my java application using microsoft JDBC sqljdbc_4.0 driver in eclipse IDE, I goggled several time with JDBC connection between java and sql server 2008 and I have tried some of but getting same error message, So lastly am decided to put the question here with error message what am getting than, i can get know what wrong am doing?

I followed a link! link for connectivity with SQL Server and Java.

My java program:

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

public class Connect

{

public static void main(String[] args) throws Exception

{

String userName = "Abhishek";

String password = "abhishek-nayak";

String url = "jdbc:sqlserver://Abhishek-VAIO\\MSSQLSERVER;databaseName=master;integratedSecurity=true";

try

{

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

Connection conn = DriverManager.getConnection(url,userName,password);

System.out.println("Connected");

}

catch(SQLException e)

{

e.printStackTrace();

}

}

}

my error message is:

Sep 06, 2012 9:09:55 PM com.microsoft.sqlserver.jdbc.AuthenticationJNI

WARNING: Failed to load the sqljdbc_auth.dll cause : no sqljdbc_auth in java.library.path

com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId:5cb4d70b-f644-4670-b7bc-a2312b8547b4

at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667)

at com.microsoft.sqlserver.jdbc.AuthenticationJNI.(AuthenticationJNI.java:60)

at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2229)

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 com.abhishek.Connect.main(Connect.java:17)

Caused by: java.lang.UnsatisfiedLinkError: no sqljdbc_auth in java.library.path

at java.lang.ClassLoader.loadLibrary(Unknown Source)

at java.lang.Runtime.loadLibrary0(Unknown Source)

at java.lang.System.loadLibrary(Unknown Source)

at com.microsoft.sqlserver.jdbc.AuthenticationJNI.(AuthenticationJNI.java:35)

... 12 more

解决方案

You're using a JDBC driver that is dependent on a native SQL Server driver and need to add a path to the DLL it's dependent on (sqljdbc_auth.dll) to your library path in java.

To add this to settings of your Eclipse project (assuming you already have a SQL Server driver installed) do:

right click the project in Project Explorer -> Properties -> Java Build Path -> select sqljdbc4.jar, so it expands -> select Native library location -> Edit... -> enter /sqljdbc_2.0/enu/auth/x64-> OK.

Result should look like:

3b4ea.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值