Hi
I installed the free software MS SQL Server 2000 from microsoft.com.
I installed the JDBC driver from the following microsoft link
http://msdn.microsoft.com/downloads/default.asp?URL=/downloads/sample.asp?url=/MSDN-FILES/027/001/779/msdncompositedoc.xml
I set the classpath to point to the jar files in the lib folder in the driver I downloaded.
I wrote the following test file to test the connectivity import java.io.*;
import java.sql.*;
public class Test
{
public static final String DB_URL = "jdbc:JDataConnect://localhost/testdb";
public static final String DB_USERNAME = "";
public static final String DB_PASSWORD = "";
public static final String DB_DRIVER = "com.microsoft.jdbc.base.BaseDriver";
public static void main(String args[])
{
ResultSet rs = null;
try
{
Class.forName (DB_DRIVER);
Connection conn=DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
System.out.println("Connection established");
}
catch(Exception e)
{
System.out.println("An exception has occurred" +e);
}
}
}
when I run this code using java Test after successful compilation I get the following error
An exception has occurredjava.sql.SQLException: No suitable driver
Please Help !!!!
Thanks in Advance
PlumTry this
it working for me
import java.io.*;
import java.sql.*;
public class Test
{
public static final String DB_URL = "jdbc:microsoft:sqlserver://server1:port1";
public static final String DB_USERNAME = "sa";
public static final String DB_PASSWORD = "a108810";
public static final String DB_DRIVER = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
public static void main(String args[])
{
ResultSet rs = null;
try
{
Class.forName (DB_DRIVER);
Connection conn=DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
System.out.println("Connection established");
}
catch(Exception e)
{
System.out.println("An exception has occurred" +e);
}
}
}|||When I tried to run your Test code.
An exception has occurredjava.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
I setup CLASSPATH to the 3 jar files which downloaded from microsoft.com, and I do not know WHY??
James|||the same siatuation happened to me
sometimes drivers cannot be found in jar files
try unpack the jar files in your work directory
Originally posted by james_hu
When I tried to run your Test code.
An exception has occurredjava.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
I setup CLASSPATH to the 3 jar files which downloaded from microsoft.com, and I do not know WHY??
James|||Hi,
My problem solved, I put space between ";" for CLASSPATH.
classpath=.; c:\..\msbase.jar; c:\..
MUST be classpath=.;c:\..\msbase.jar;c:\..
NO SPACE for classpath!!!
This is stupid JAVA, it should be improve later, this problem wastes my huge time!!!
I am not sure this is your prolem.
James
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment