This problem was encountered when I first used Java to connect to SqlServer2008. I have searched many articles on this issue on the Internet. Com. microsoft. sqlserver. jdbc. SQLServerException: connection to the TCPIP of the host localhost through port 1433 fails. Error: "Connectionrefused: connect. Verify connection
This problem was encountered when I first used Java to connect to SqlServer 2008. I have searched many articles on this issue on the Internet. Com. microsoft. sqlserver. jdbc. SQLServerException: The TCP/IP connection to the host localhost through port 1433 fails. Error: "Connection refused: connect. Verify connection
This problem occurs when I first used Java to connect to SQL Server 2008. I have searched many articles on this issue on the Internet.
Com. microsoft. sqlserver. jdbc. SQLServerException: The TCP/IP connection to the host localhost through port 1433 fails. Error: "Connection refused: connect. Verify the Connection Properties, check that the SQL Server instance is running on the host, accept the TCP/IP connection on this port, and ensure that the firewall does not block the TCP connection 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 (Unknown Source)
At java. SQL. DriverManager. getConnection (Unknown Source)
At TestSql. main (TestSql. java: 11)
The general solution is as follows:
SQL Server Configuration Manager → SQL Server network configuration → set the TCP/IP protocol status to started, right-click the TCP/IP protocol → properties → IP address → the last option IPALL, set the TCP port to 1433 (this can also be another port, but it must correspond to it in the program, generally 1433 ). Restart the SQL Server service.
In addition, pay attention to reference jdbc4.jar When referencing the driver package.