我能够使用主机“ nash-pc \ sqlexpress”的SQL Server Management Studio连接到本地计算机上的MSSQL 2008 Express。但是,当我连接Microsoft JDBC驱动程序时,它给了我类似下面的错误。JDBC在主机名中有’'的问题吗?我不确定如何使主机名成为“ localhost”,而不是“ nash-pc \ sqlexpress”。有趣的是,如果我使用服务器名称作为“ localhost”,那么我什至无法连接SQL Server Management Studio。
“ The driver encountered an unknown error: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host nash-pc, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.”。
The driver encountered an unknown error: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host nash-pc, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.
我的JDBC连接字符串
司机: com.microsoft.sqlserver.jdbc.SQLServerDriver
com.microsoft.sqlserver.jdbc.SQLServerDriver
网址: jdbc:sqlserver://nash-pc\sqlexpress:1433;databaseName=jruby
jdbc:sqlserver://nash-pc\sqlexpress:1433;databaseName=jruby
http://www.webxpert.ro/andrei/2009/05/31/enable-tcpip-on-sql- server-2005-express-edition/