reprint: Java JDBC Connection SQL Server2005 Error: TCP/IP connection to host localhost via port 1433 failed
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.
Where is the surface area configurator for SQL Server 2008?
In SQL Server 2005, Microsoft has added some new tools, one of which is the "surface area Configurator", which is primarily designed to ensure the default security of the server.
However, this tool has not been found in SQL Server 2008. It was merged into a so-called "aspect" tool.
On the server node, right-click, select Facets, and you can see a lot of settings, one of which is the surface area Configurator
The benefit of doing so is that it can be exported as a policy and then reused. It's mostly easy to manage.
Right-click to "Evaluate"
Java JDBC Connection SQL Server2005 Error: TCP/IP connection to host localhost via port 1433 failed and sql2008 perimeter server