I know this is a recurring question. I found very similar questions and solutions for them, but still I am amazed at this.
I am using eclipse to connect my java application with a Microsoft SQL Server 2008 database. Below is my code
import java.sql.*; public class ConnectionTest2 { public static void main(String [] args) { try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); String connectionUrl = "jdbc:sqlserver://localhost:1433;databaseName=Sample;integratedSecurity=true"; Connection con = DriverManager.getConnection(connectionUrl,"",""); System.out.println("Connected"); } catch (SQLException e) { System.out.println("SQL Exception: "+ e.toString()); } catch (ClassNotFoundException cE) { System.out.println("Class Not Found Exception: "+ cE.toString()); } } }
I enabled tcp / ip and VIA by going to the sql server configuration configurator and setting the port number to 1433 under IPALL.
I tried in many ways, but I can not find a solution to the following error
SQL exception: com.microsoft.sqlserver.jdbc.SQLServerException: TCP / IP connection to the local host, port 1433 failed. Error: "Connection refused: connect. Check the connection properties. Make sure that the instance of SQL Server is running on the host and accepting TCP / IP connections on the port. Make sure that TCP connections to the port are not blocked by the firewall.".
I also turned off Windows Firewall, but could not connect.
Please help me.
java sql-server-2008 jdbc
user1074122 Apr 05 2018-12-12T00: 00Z
source share