在eclipse java项目中加载dll文件 [英] Loading dll file inside eclipse java project
本文介绍了在eclipse java项目中加载dll文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将文件 sqljdbc_auth.dll
添加到项目库中。我将包含dll的文件夹添加为外部类文件夹。
I am trying to add the file sqljdbc_auth.dll
to the project library. I add the folder containing the dll as external class folder.
这里我基本上尝试使用Microsoft提供的SQL驱动程序连接到我的SQL SERVER 2008数据库。
Here I am basically trying to connect to my SQL SERVER 2008 database using SQL drivers given by Microsoft.
我的代码是
private static void Connect(){
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:hostname:1433;databaseName=dbname;"
+ "user=username;password=password";
java.sql.Connection con = DriverManager.getConnection(connectionUrl);
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException e2)
{
e2.printStackTrace();
}
}`
我收到以下错误
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:b83147c7-b45a-4f35-b601-195a0aa9c32c
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667)
at com.microsoft.sqlserver.jdbc.AuthenticationJNI.<init>(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.sagar.com.package1.T1.Connect(T1.java:21)
at com.sagar.com.package1.T1.main(T1.java:37)
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.<clinit>(AuthenticationJNI.java:35)
... 13 more
推荐答案
如果你想在Eclipse内部使用DLL,你需要将DLL包含在系统 PATH
的某个位置,或者你需要显式在Eclipse的运行配置中指定 java.library.path
属性。
If you want to use a DLL from inside Eclipse, you either need to include the DLL in a location on the system PATH
, or you need to explicitly specify the java.library.path
property in the run configuration of Eclipse.
这篇关于在eclipse java项目中加载dll文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文