java connecting to MicrosoftSQLServer 2005
Java Connecting with MicrosoftSqlServer 2005.
- IDE Used: Eclipse helios
- Driver used: sqljdbc.jar
- .dll used: sqljdbc_auth.dll from x86 folder.
- .dll is added to system32 folder rebooted system.
- Ping succeeded connecting eclipse with SQL server 2005 using sqljdbc.jar
Error report is:
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,
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.findC开发者_Python百科lass(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.
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
Please copy sqljdbc_auth.dll file in to jdk bin folder. i.e.C:\Program Files\Java\jdk1.6_32\bin paste file in your server side where JVM is running if consuming web services please apply same in client side as well.
Your program output doesn't look like the problem is anything to do with JDBC. You're invoking Java, passing it some environment arguments, but fundamentally telling it to start execution with the class mfirst
.
And accordingly, the program output states:
Could not find the main class: mfirst. Program will exit.
This doesn't look like a proper name for the main class (no package, no uppercase characters). Are you sure you're invoking the program correctly?
精彩评论