- This topic has 3 replies, 2 voices, and was last updated 18 years, 1 month ago by
Mark Sanders.
-
AuthorPosts
-
Mark SandersMemberWindows XP sp2
msSQL 2005 (local)i’m just doing some testing. i have been able to set up my DBExplorer conction to my SQL server access tables and run some querys.
what i have done now is created a Java application and i am trying to test some code to produce results in the console. the test works fine if i use the following piece (partial) of code:
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);//load JDBC DRIVER
Connection con = DriverManager.getConnection(“jdbc:odbc:PhaseGates;integratedSecurity=true”);
//get connectionwhen i use the following instead:
Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);//load JDBC DRIVER
Connection con = DriverManager.getConnection(“jdbc:sqlserver://localhost:1433;databaseName=PhaseGates;integratedSecurity=true”);
//get connection
I get the following error:java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
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.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.DBconn.Test1.main(Test1.java:15)I have a feeling i need to placing the sqljdbc.jar file somewhere for eclipse or myeclipse to see it.
any ideas?
thanks,
Haris PecoMemberlittleccguy,
Yes, you have to download MS jdbc driver from http://msdn.microsoft.com/data/ref/jdbc (there is jTDS driver as well) and set in your project classpath
Regards,
Mark SandersMemberThank you.
I will do that.
Mark SandersMemberThank you.
I will do that.
-
AuthorPosts