import java.sql.*;
public class TestForJDBC {
public static void main(String[] args){
String url="jdbc:sqlserver://localhost:1433;DatabaseName=EB";
String userName="sa";
String password=""; //密码自己根据情况而定
try{
System.out.println("before load driver");
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("after load driver sucessful");
}catch(ClassNotFoundException e){
System.err.print("fail to load driver");
}
try{
System.out.println("before connect to database");
Connection conn = DriverManager.getConnection(url,userName,password);
System.out.println("connect database sucessfull");
}catch(Exception e){
e.printStackTrace();
}
}
}