package pkg;
import java.sql.*;
public class Test {
public static void main(String args[]) {
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; // 加载JDBC驱动
String dbURL = "jdbc:sqlserver://localhost:1433;integratedSecurity=true;DatabaseName=wulei"; // 连接服务器和数据库sample
Connection dbConn;
try {
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL);
System.out.println("Connection Successful!"); // 假如连接成功
} catch (Exception e) {
e.printStackTrace();
}
}
}