import java.sql.*;
public class SMS {
public static void main(String args[]){
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection ct=null;
ct=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=StudentManager", "ss","123");
System.out.println("connected");
} catch (ClassNotFoundException e) {
e.printStackTrace();
System.out.println("unconnected1");
} catch (SQLException e) {
e.printStackTrace();
System.out.println("unconnected2");
}
}
}
com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'ss' 登录失败。
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at SMS.main(SMS.java:9)
unconnected2