Solution for Java Connection not to sq server Express

Source: Internet
Author: User
Tags microsoft sql server microsoft sql server 2005 management studio sql server management sql server management studio oracle database

ERROR: TCP/IP connection to host localhost via port 1433 failed. Error: "Connection refused:connect. Verify the connection properties and check that instances of SQL Server are running on the host and that the TCP/IP connection is accepted on this port, and that the firewall does not block TCP connections to this port. ”。

Recently to learn the database, the teacher with Microsoft SQL Server 2005, I was learning Java, has been JDBC to connect to the Oracle database, this time I installed Microsoft SQL Server 2005, want to use JDBC to connect Microsoft SQL Server 2005 did not come up with such a problem:

com.microsoft.sqlserver.jdbc.sqlserverexception:  connects to the host via port  1433   localhost  TCP/IP  connection failed for  . Error: "Connection refused:connect. Verify the connection properties and check that an instance of  sql server  is running on the host and that the port accepts  TCP/IP  connections, and that the firewall does not block  TCP  connections to this port. ”。
at Com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError (sqlserverexception.java:171)
at Com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper (sqlserverconnection.java:1033)
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:582)
at Java.sql.DriverManager.getConnection ( drivermanager.java:185)
at Com.luoying.TestSQLServer2.main (testsqlserver2.java:15)

The reason: the TCP/IP protocol for the SQ server Express version is disabled by default, so the SQL Server Management Studio client can connect, but the Java program connection fails.

Workaround: Enable the TCP/IP protocol


Note: If you cannot find the SQL Server Configuration Management (Configuration Management tool), follow these steps:

to open SQL Server Configuration Manager, in the Search Super button, under Application, type SQLSERVERMANAGER11.MSC (for SQL Server 2012) or Sqlservermanager10.msc (for SQL Server 2008), and then press the ENTER key. As shown in the following illustration:



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.