public static void main(String[] args){
try{
Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver "); //加载数据库驱动
String url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs "; //声明数据库连接字符串
Connection con=DriverManager.getConnection(url, "sa ", "123 "); //创建数据库连接
System.out.print( "success ");
}
catch(Exception e)
{
e.printStackTrace();
}
}