public static void main(String[] args) {
DBUtil.testSqlServer();
}
public static void testSqlServer(){
String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test";
String user = "sa";
String password = "test";
try{
Class.forName(driver);
DriverManager.getConnection(url,user,password);
System.out.println("连接SqlServer数据库成功!");
}catch(Exception ex){
ex.printStackTrace();
}
}
SqlServer2008驱动包下载地址: