在Eclipse中将SQL Server与Java链接时Ping失败

时间:2019-07-03 20:18:36

标签: java sql-server eclipse

我正在尝试在eclipse中将SQL Server与Java SE 8.0链接。但是每次我收到Ping错误消息。

我研究了有关如何连接它们以及错误的文档,但没有一个对您有所帮助。

通过选择SQL 2008,URL地址为'jdbc:sqlserver://localhost:1433;databaseName=pubs',测试连接的结果为:

com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'Nastaran'. ClientConnectionId:aceb876b-7c92-454c-bab0-9c176045bb76
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
    at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:254)
    at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:84)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2964)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2244)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:43)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2230)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1717)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1328)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:993)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:829)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
    at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:328)
    at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105)
    at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54)
    at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:96)
    at org.eclipse.datatools.enablement.msft.internal.sqlserver.connection.JDBCSQLServerConnectionFactory.createConnection(JDBCSQLServerConnectionFactory.java:27)
    at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)
    at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:359)
    at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)
    at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
Can anyone help me?

1 个答案:

答案 0 :(得分:0)

  • 1.打开您的 SQL Server Management Studio
  • 连接到窗口身份验证
  • object_explorer==>属性==>安全
  • 中右键单击sqlexpress >
  • 选择SQL 服务器和窗口身份验证
  • 如果您没有用户并且您使用窗口身份验证,请创建一个 新用户

创建新用户

  • 对象资源管理器中点击安全 ==> 登录
  • 输入登录名“Student001”选择SQL服务器和窗口 身份验证
  • 然后点击GENERAL下的服务器角色并勾选你需要勾选的复选框 然后点击确定。
  • 重新启动 SQL 服务器。

  • 网址格式: jdbc:sqlserver://DESKTOP-CQEEAQ3\SQLEXPRESS;databaseName=Customer; DESKTOP-CQEEAQ3\SQLEXPRESS:从 SSMS 服务器名称复制。