我正在尝试将我的 java 应用程序与 Microsoft SQL Server DBMS 连接。 这是我的连接字符串:
try{
String host = "jdbc:sqlserver://localhost:1433;databaseName=JITM;integratedSecurity=true";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerh=Driver");
con = DriverManager.getConnection(host);
stmt = con.createStatement();
System.out.println("Connection Successful");
}catch(SQLException err){
System.out.println(err.getMessage());
}catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
}
它显示此错误。
com.microsoft.sqlserver.jdbc.SQLServerh=Driver
我已在库中添加了 sqljdbc41.jar。数据库是windows身份验证。
最佳答案
驱动程序类名称中有打印错误。
将该代码行更改为此 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
关于java - 将 Java 应用程序与 SQL Server 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50079501/