JDBC sql server 2000 Run time error
843854Nov 28 2004 — edited Aug 29 2005Hi
I have a problem when I try to connect java and sql server 2000. An run time error is coming in my program.
Exception in thread "main" java.lang.ClassNotFoundException: new com/microsoft/jdbc/sqlserver/SQLServerDriver()
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:130)
at Test.<init>(Test.java:8)
at Test.main(Test.java:30)
I try all classpath first I place the msssqlserver.jar, msutil.jar, msbase.jar into jdk1.4\jre\lib\ext but the same above problem is come.
Then I make a directory in D drive d:\javasql and place all the jar files into this directory my .java and .class files also and I try these different paths
d:\javasql>set classpath=d:\msbase.jar;d:\msutil.jar;d:\mssqlserver.jar
d:\javasql>java �classpath �.;d:\msbase.jar;d:\msutil.jar;d:\mssqlserver.jar� Test
d:\javasql>set classpath=d:\..
and some different path also but the same problem exit please help me on it the program is.
import java.sql.*;
/**
* Microsoft SQL Server JDBC test program
*/
public class Test {
public Test() throws Exception {
// Get connection
Class.forName("new com.microsoft.jdbc.sqlserver.SQLServerDriver()");
Connection connection = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://server","uzairbaig","baig");
if (connection != null) {
System.out.println();
System.out.println("Successfully connected");
System.out.println();
// Meta data
DatabaseMetaData meta = connection.getMetaData();
System.out.println("\nDriver Information");
System.out.println("Driver Name: "
+ meta.getDriverName());
System.out.println("Driver Version: "
+ meta.getDriverVersion());
System.out.println("\nDatabase Information ");
System.out.println("Database Name: "
+ meta.getDatabaseProductName());
System.out.println("Database Version: "+
meta.getDatabaseProductVersion());
}
} // Test
public static void main (String args[]) throws Exception {
Test test = new Test();
}
Best Regards
Uzair Baig