请大家指导一下。新手学习,我用MyEclipse Professional 2014链接SQL2008 出现的错误结果,如下:
com.microsoft.sqlserver.jdbc.SQLServerException: 用户 “”谢来”” 登录失败。
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:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at lesson.Lesson.main(Lesson.java:14)
代码为:
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(“加载驱动成功”);
con = DriverManager.getConnection(“jdbc:sqlserver://localhost:1433;DatabaseName=Text”,”谢来”,”mysql”);
System.out.println(“连接成功”);
con.close();
}
catch (Exception ex)
{
System.out.println(“连接失败”);
ex.printStackTrace();
}
}
}
SQLEXPRESS的TCP/IP端口 IPALL :1433
用户能登陆sql身份验证
jdbc驱动为Microsoft SQL Server JDBC Driver 3.0