2013-12-14 170 views
0

我想通过JDBC驱动程序连接到SQL Server,但不断收到此错误:连接到SQL Server使用JDBC错误

Error connecting to the specified data source: 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.".

我的连接字符串是:

jdbc:sqlserver://localhost\SRVR_SQL:1433;DatabaseName=spotfire_server  

我也试过这样:

jdbc:sqlserver://10.10.60.12\SRVR_SQL:1433;DatabaseName=spotfire_server  

这:

jdbc:sqlserver://localhost:1433;DatabaseName=spotfire_server 

这:

jdbc:sqlserver://SRVR_SQL:1433;DatabaseName=spotfire_server 

但他们都给出了同样的错误

+0

可能重复失败,错误:TCP/IP连接到主机失败](http://stackoverflow.com/questions/18841744/jdbc-connection-failed-error-tcp-ip-connection-to-host-failed) – duffymo

回答

0

尝试10.0.0.2 确保像数据库密码,姓名,表名基本的东西.... 。

0

读取错误:

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 Server在本地运行?你能通过SQL Server管理工具连接到它吗?

您正在使用哪种JDBC驱动程序 - Microsoft或jDTS?

试试这个URL,假设监听器上运行10.10.60.12,端口为1433,并且架构名称是DBNAME:

jdbc:sqlserver://10.10.60.12:1433;DatabaseName=dbName 
[JDBC连接
+0

我可以通过SSMS连接到它,我正在使用微软的JDBC驱动程序...我试着你上面提到的,但仍然得到相同的错误 – user2061886