本文介绍了java连接到MicrosoftSQLServer 2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Java与MicrosoftSqlServer 2005连接.
Java Connecting with MicrosoftSqlServer 2005.
- 使用的IDE:Eclipse helios
- 使用的驱动程序:sqljdbc.jar
- .dll使用:x86文件夹中的sqljdbc_auth.dll.
- .dll已添加到system32文件夹重新启动的系统中.
- Ping使用sqljdbc.jar成功将Eclipse与SQL Server 2005连接
错误报告是:
15:45:48,218 ERROR [STDERR] Jan 28, 2011 3:45:48 PM com.microsoft.sqlserver.jdbc.AuthenticationJNI <clinit>
WARNING: Failed to load the sqljdbc_auth.dll
15:46:02,671 ERROR [STDERR] com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "connect timed out. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".
HELLO ALL,
HELLO ALL,
我已在命令提示符下执行了此操作:我现在正在获取此错误:
I HAVE EXECUTED THIS IN COMMAND PROMPT: I'M GETTING THIS ERROR NOW:
C:\>java -cp .;"C:\sqljdbc_1.2\enu\sqljdbc.jar" -Djava.library.path="C:\sqljdbc_
1.2\enu\auth\x86" mfirst
Exception in thread "main" java.lang.NoClassDefFoundError: mfirst
Caused by: java.lang.ClassNotFoundException: mfirst
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: mfirst. Program will exit.
推荐答案
哈里是对的.驱动程序无法加载身份验证DLL.转到您的环境变量,然后将值C:\JavaLib\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\enu\auth\x64
添加到您的PATH
中(为您的计算机选择正确的auth子文件夹-即x86等)重新启动您的IDE,它应该如广告所示
Harry is right. The driver can't load the authentication DLL. Go to your environment variables and add to your PATH
the value C:\JavaLib\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\enu\auth\x64
(choose the correct auth subfolder for your machine - i.e. x86 etc)restart your IDE and it should work as advertised
这篇关于java连接到MicrosoftSQLServer 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!