myeclipse 连接sql server2008,用户“sa”登录失败 20
这是测试类,网上抄的packagelesson;importjava.sql.*;publicclassLesson{publicstaticConnectioncon;...
这是测试类,网上抄的
package lesson;import java.sql.*;
public class Lesson {
public static Connection con;
public static void main(String[] args)
{
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("qudongchenggong");
con = DriverManager.getConnection
("jdbc:sqlserver://localhost:1433;DatabaseName=ccc","sa","39071410");
System.out.print("lianjiechenggong");
con.close();
}
catch(Exception ex)
{
System.out.println("lianjieshibai");
ex.printStackTrace();
}
}
}
这是运行结果
qudongchenggong
lianjieshibai
com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'sa' 登录失败。
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:246)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:83)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2529)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:1905)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:1893)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1045)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:817)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:700)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at lesson.Lesson.main(Lesson.java:12) 展开
package lesson;import java.sql.*;
public class Lesson {
public static Connection con;
public static void main(String[] args)
{
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("qudongchenggong");
con = DriverManager.getConnection
("jdbc:sqlserver://localhost:1433;DatabaseName=ccc","sa","39071410");
System.out.print("lianjiechenggong");
con.close();
}
catch(Exception ex)
{
System.out.println("lianjieshibai");
ex.printStackTrace();
}
}
}
这是运行结果
qudongchenggong
lianjieshibai
com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'sa' 登录失败。
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:246)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:83)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2529)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:1905)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:1893)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1045)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:817)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:700)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at lesson.Lesson.main(Lesson.java:12) 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询