我正在尝试连接MS SQL数据库,但每次我尝试我都会收到此错误:
SQLException:用户''登录失败.用户未与受信任的SQL Server连接关联.ClientConnectionId:86b1da77-8eff-4c3f-badb-5ab75efcbab4 SQLState:S0001 VendorError:18452
我已经在登录设置中配置为"SQL Server身份验证"和"已启用".如果有人能解决这个问题,我将非常感激.
这是我的代码:
public static void main(String[] args) {
String database="sisqualPONTO";
String connectionUrl = "jdbc:sqlserver://localhost:40000"+";DatabaseName=" + database+ ";integratedSecurity=true;";
String pass="****";
String user="sa";
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection(connectionUrl,user,pass);
System.out.println("Success");
}
catch (SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
catch (Exception e) {
System.out.println("Error: " + e);
}
}
Run Code Online (Sandbox Code Playgroud)
}
提前致谢.Cumps