Connecting JAVA with SQL Server 2000
843859Oct 17 2005 — edited Mar 21 2006Hai,...
I want to connect JAVA with SQL server 2000. But i don't know how to do it. I use jdk 1.4. Some people say that i have to Download SQL server for JDBC, so i download it from microsoft website. And then i run the following code:
import java.sql.*;
class testing
{
public static void main (String args [])
{
Connection con;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
} catch (java.lang.ClassNotFoundException e){
System.err.println("ClassNotFoundException");
System.err.println(e.getMessage());
}
try{
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://febry:1433","febry","febry");
}catch (SQLException ex){
System.err.println("SQL Exception :" + ex.getMessage());
}
}
}
I get an error ----> No Suitable Driver.
Other people use :
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
I try that one too, but it doesn't work.
What is the different between the one that i use with the "com.microsoft....." ?
Can someone please tell me how to do it?
Thank you,
Billy