官方文档:
代码:
public static final String CONN_URL = "jdbc:sqlserver://localhost:1433;databaseName=Xxx;user=sa;password=xxxx";
@Test
public void testVersion() {
Connection conn = null;
try {
conn = DriverManager.getConnection(CONN_URL);
DatabaseMetaData metaData = conn.getMetaData();
String driverVersion = metaData.getDriverVersion();
// 7.2.2.0
System.out.println(driverVersion);
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (Objects.nonNull(conn)) {
try {
conn.close();
} catch (SQLException sqlException) {
sqlException.printStackTrace();
}
}
}
}
因此,可以看下源码
mssql-jdbc-7.2.2.jre8.jar里面7.2.2就是
Microsoft JDBC Driver for SQL Server的版本号