Java JDBC Connection SQL Server2005 Error: TCP/IP connection to host localhost via port 1433 failed

Source: Internet
Author: User

Turn from: 6668966

Also available for reference: 72123979

The reasons for the error are:

Exception in thread "main" Org.hibernate.exception.JDBCConnectionException:Cannot open Connectionat Org.hibernate.exception.SQLStateConverter.convert (sqlstateconverter.java:99) at Org.hibernate.exception.JDBCExceptionHelper.convert (jdbcexceptionhelper.java:66) at Org.hibernate.exception.JDBCExceptionHelper.convert (jdbcexceptionhelper.java:52) at Org.hibernate.jdbc.ConnectionManager.openConnection (connectionmanager.java:449) at Org.hibernate.jdbc.ConnectionManager.getConnection (connectionmanager.java:167) at Org.hibernate.jdbc.JDBCContext.connection (jdbccontext.java:160) at Org.hibernate.transaction.JDBCTransaction.begin (jdbctransaction.java:81) at Org.hibernate.impl.SessionImpl.beginTransaction (sessionimpl.java:1473) at Vo. Newsmanager.main (newsmanager.java:17) caused by:com.microsoft.sqlserver.jdbc.SQLServerException: connecting to host via port 1433 The TCP/IP connection to localhost failed. Error: "Connection refused:connect. Verify the connection properties and check that the instance of SQL Server is running on the host, accept TCP/IP connections on this port, and make sure 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:154) at Org.hibernate.connection.DriverManagerConnectionProvider.getConnection ( drivermanagerconnectionprovider.java:133) at Org.hibernate.jdbc.ConnectionManager.openConnection ( connectionmanager.java:446)

On the command line, enter: Telnet localhost 1433, not connected:

Check the configuration: Surface Area Configuration for services and connections

"Using both TCP/IP and Named pipes (B)" is already selected

Then check the SQL Server Configuration Manager

TCP/IP is turned on for instance named "SQLEXPRESS":

Right-click TCP/IP to select Properties (or double-click TCP/IP), select the IPs tab, and at the bottom there is a "IPALL":

Here's the problem: I didn't set up the TCP port, and after that I changed it:

Then look at "SQL Native client Configuration":

Double-click "TCP/IP":

Everything is right. Restart the service now:

Right-click SQL Server (SQLEXPRESS), and select Restart.

Then go back to the command line, type: telnet localhost 1433

Display a black screen, such as, the description has been successful!

Finally, with JDBC connection under Eclipse, you can connect to SQL Server 2005 correctly.

Note:

Software: QQ

Photo editing software: MSPaint

Java JDBC Connection SQL Server2005 Error: TCP/IP connection to host localhost via port 1433 failed

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.