Java JDBC Connection SQL Server 2005 Error: TCP/IP Connection Failed to Connect to Host localhost via Port 1433

Keywords: Java Hibernate JDBC SQL

The reasons for the error are as follows:

Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(
at org.hibernate.exception.JDBCExceptionHelper.convert(
at org.hibernate.exception.JDBCExceptionHelper.convert(
at org.hibernate.jdbc.ConnectionManager.openConnection(
at org.hibernate.jdbc.ConnectionManager.getConnection(
at org.hibernate.jdbc.JDBCContext.connection(
at org.hibernate.transaction.JDBCTransaction.begin(
at org.hibernate.impl.SessionImpl.beginTransaction(
at vo.NewsManager.main(
    Caused by: Connect to the host via port 1433 localhost Of TCP/IP Connection failed. error:"Connection refused: connect. Verify the connection properties and check SQL Server Instances are running on the host and accepted on this port TCP/IP Connect, and make sure that the firewall does not block access to this port TCP Connect.
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(
at org.hibernate.jdbc.ConnectionManager.openConnection(

On the command line, enter telnet localhost 1433, which cannot be connected:

Check Configuration: Peripheral Application Configurator for Services and Connections

"Use TCP/IP and named pipes(B)" has been selected.

Next, check the SQL Server Configuration Manager

TCP/IP under the instance name "SQLEXPRESS" has been started:

Right-click "TCP/IP" to select "Properties" (or double-click "TCP/IP") and select the "IP Address" tab, with "IPALL" at the bottom:

Here's the problem: I haven't set up a TCP port. After that, the following figure is shown:

Look at the "SQL Native Client Configuration":

Double-click "TCP/IP":

Everything is right. Now restart the service:

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

Go back to the command line and type: telnet localhost 1433

Display black screen, as shown above, shows that it has been successful! ____________

Finally, the JDBC connection under Eclipse can be correctly connected to SQL Server 2005.


Screen software: QQ

Image editing software: mspaint

Posted by strangebeer on Sun, 10 Feb 2019 18:54:18 -0800