【发布时间】:2013-04-24 08:55:47
【问题描述】:
我正在使用 sql server 2008 r2 sql express。 我通常像这样连接到我的 sql:
现在我想从我的 Eclipse 连接到 sql server 2008 r2。
我搜索了谷歌,我发现我必须下载一个 jar 文件,我下载了,我在 eclipse 中将它添加到我的项目中。
我的代码是
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://localhost:1433;"
+ "databaseName=DATABASE;user=User-PC\\User;password=;";
老实说:我不知道我应该输入localhost 还是sqlexpress,而且我不知道密码,因为我应该在图像中使用你,或者我只是将其空置。
例外是:
The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
我在我的 sql 配置中启用 TCP/IP
请帮帮我
【问题讨论】:
-
你使用的是root用户吗?
-
是的,......
-
I have read that the root user can't can't be used in JDBC所以首先你必须在你的 sql server 中创建一个新的Login,然后再创建一个新的User。之后,请尝试再次连接并告诉我发生了什么。 -
我使用新用户创建了一个新登录,但是当我尝试将我的服务器连接到该新用户时,我收到了身份验证错误
-
你必须选择sql认证
标签: database jdbc database-connection sql-server-2008r2-express sqljdbc