jbdc Connection to SQL Server
-
Tuesday, January 22, 2013 10:23 PM
This has to be an FAQ but I have been unable to find a solution. I am using Eclipse I have set my CLASSPATH as
CLASSPATH=.;C:\Program Files (x86)\Java\jre7\lib\ext\QTJava.zip;C:\Program Files
\Microsoft JDBC Driver 4.0 for SQL Server\sqljdbc_4.0\enu\sqljdbc4.jarThe client is running Windows 7. I am running JRE 7. The conneciton URL is:
"jdbc:sqlserver://devmattkvm05:1433;" +
"databaseName=Productcatalog;user=rkb;password=*****";The application fails with the exception:
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at java.net.URLClassLoader$1.run(Unknown Source)
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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at HellowWorld.main(HellowWorld.java:19)The line that it is failing on is:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
The client is in the same domain as the server but it is on a remote/different machine than the client.
The server is running SQL Server 11.0. The server is running as I can connect to it using SMS. The user that I specify on the connection string basically has administrative rights.
As this error doesn't really show that I have even gotten to the connection point any other information is probably not relevant. Let me know if I have missed anything.
Kevin Burton

