发行说明 - JDBC Driver for SQL Server | Microsoft Learn
版本兼容性查看
支持矩阵 - JDBC Driver for SQL Server | Microsoft Learn
建议方法查看
SQL 版本兼容性?
Java 和 JDBC 规格支持
下面是2008版本对应的连接的驱动
?高版本的需要加入下面的内容:;integratedSecurity=false;encrypt=true;trustServerCertificate=true
//数据库连接公共类
public class Connectdatabase {
private Connection conn;
public Statement stmt;
private static final String DB_URL = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test1227";
private static final String DB_USER = "test";
private static final String DB_PASSWORD = "123456";
public Statement Connect(){
try{
//驱动类
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
conn=DriverManager.getConnection(DB_URL,DB_USER,DB_PASSWORD);
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
}
catch(Exception e){
System.out.println("异常:"+e.getMessage());
}
return stmt;
}
}