The cause of the error is as follows:
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: Connect to host via port 1433 The TCP/IP connection to localhost failed. Error: "Connection refused:connect. Please verify the connection properties. And check that the instance of SQL Server is executing on the host and accept TCP/IP connections at this port, and also 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. Connection not on:
Check the configuration: Surface Area Configuration for services and connections
"Use TCP/IP and Named pipes (B) at the same time" is selected
Check the following again for 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 "IP Address" tab and the following "IPALL":
Here's the problem: I didn't set TCPPort, and after that I changed for example:
Then look at "SQL Native client Configuration":
Double-click "TCP/IP":
Everything is right.
Now restart the service:
Right-click SQL Server (SQLEXPRESS) and select Start again.
Go back to the command line. Type: telnet localhost 1433
Display a black screen, such as, the description has been successful!
Finally, use JDBC to connect under Eclipse. Be able to connect to SQL Server 2005 correctly.
Java JDBC Connection SQL Server2005 Error: TCP/IP connection to host localhost via port 1433 failed