简体   繁体   中英

SQLException: Login failed for user ' ' JAVA

I'm trying to connect with the MS SQL database but everytime i try i get this error:

SQLException: Login failed for user ''. The user is not associated with a trusted SQL Server connection. ClientConnectionId:86b1da77-8eff-4c3f-badb-5ab75efcbab4 SQLState: S0001 VendorError: 18452

I've already configured to 'SQL Server authentication' and 'enabled' at the login settings. I would be very grateful if someone could solve this problem.

Here is my code:

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);
}
}

}

Thanks in advance. Cumps

从您的连接URL中删除'integratedSecurity=true'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM