java连接到MicrosoftSQLServer2005

java连接到MicrosoftSQLServer2005,java,sql-server-2005,jdbc,Java,Sql Server 2005,Jdbc,Java正在连接MicrosoftSQLServer2005 使用的IDE:Eclipse helios 使用的驱动程序:sqljdbc.jar 使用的.dll:x86文件夹中的sqljdbc_auth.dll .dll已添加到重新启动系统的system32文件夹中 Ping成功地使用sqljdbc.jar将eclipse连接到SQLServer2005 错误报告是: 15:45:48,218 ERROR [STDERR] Jan 28, 2011 3:45:48 PM com.micros

Java正在连接MicrosoftSQLServer2005

  • 使用的IDE:Eclipse helios
  • 使用的驱动程序:sqljdbc.jar
  • 使用的.dll:x86文件夹中的sqljdbc_auth.dll
  • .dll已添加到重新启动系统的system32文件夹中
  • Ping成功地使用sqljdbc.jar将eclipse连接到SQLServer2005
错误报告是:

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.".

您的程序输出看起来与JDBC无关。您正在调用Java,向它传递一些环境参数,但基本上是告诉它使用类
mfirst
开始执行

相应地,程序输出状态为:

找不到主类:mfirst。程序将退出


这看起来不像是主类的正确名称(没有包,没有大写字符)。您确定正确调用了该程序吗?

Harry是对的。驱动程序无法加载身份验证DLL。转到您的环境变量,并将值
C:\JavaLib\Microsoft SQL Server JDBC驱动程序3.0\sqljdbc\u 3.0\chs\auth\x64添加到
路径中(为您的计算机选择正确的auth子文件夹,如x86等)

重新启动IDE,它应该可以像广告中的那样工作

请将sqljdbc_auth.dll文件复制到jdk bin文件夹中。 i、 e.C:\ProgramFiles\Java\jdk1.6\U 32\bin在运行JVM的服务器端粘贴文件
如果使用web服务,请在客户端也应用相同的连接属性。

验证以下内容:“连接属性,检查SQL Server实例是否在主机上运行并在端口接受TCP/IP连接,以及是否没有防火墙阻止到端口的TCP连接。”将此sqljdbc.jar文件放入C:\Program Files\Java\jdk1.6.0\u 21\jre\lib\ext。。。并将sqljdbc4.jar用于此sql server连接。并且可能不允许您连接到sql。。表示servercom.microsoft.sqlserver.jdbc.SQLServerException:此驱动程序未配置为集成身份验证。com.microsoft.sqlserver.jdbc.SQLServerException:此驱动程序未配置为集成身份验证。现在我遇到了这个错误,这通常表示驱动程序在JVM库路径中找不到合适的sqljdbc_auth.dll。要更正此问题,请使用java.exe-D选项指定“java.library.path”系统属性值。您需要指定包含sqljdbc_auth.dll的目录的完整路径。例如:java-cp。;“c:\jdbc1_2\sqljdbc.jar”-Djava.library.path=“c:\jdbc1_2\auth\x86”myApp或者,您可以将sqljdbc_auth.dll复制到搜索路径中的目录(例如:执行应用程序的本地目录)。
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.