I want to connect to SSMS database from eclipse. when compiler reaches to DriverManager.getConnection(url)
line it throws error.I enable TCP/IP also but it giving error.
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("driver loaded successfully");
connection= DriverManager.getConnection( "jdbc:sqlserver://localhost\\MSSQLSERVER;user=sa;password=coder182");
System.out.println("Connection created successfully");
connection.setAutoCommit( autoCommit);
statement=connection.createStatement();
String query ="insert into User_information(name, card_no,amount)" + "values ('"+name+"','"+card_no+"', '"+amount+"');";
statement.executeUpdate(query);
System.out.println(query);
}catch(Throwable th){
th.printStackTrace();
}
}
Error:
com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the host localhost, named instance mssqlserver failed. Error: "java.net.SocketTimeoutException: Receive timed out". Verify the server and instance names and check that no firewall is blocking UDP traffic to port 1434. For SQL Server 2005 or later, verify that the SQL Server Browser Service is running on the host.
I want to connect it to database.