JDBC connection working on co-worker's computer not mine
-
25-05-2021 - |
Pregunta
The following java code prints Hello World on my co-worker's computer:
public void testJDBC() throws Exception
{
String url = "jdbc:sqlserver://myremoteserver.mycorp.net:1433;DatabaseName=mydb";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection(url, "myuser", "mypwd");
System.out.println("Hello world");
}
On debugging, the getConnection
step does not return. I can connect to myserver.mycorp.net,1433 using SQL Server Management Studio.
I even changed myremoteserver.mycorp.net
to 127.0.0.1,5802
(local database). And again with 127.0.0.1,5802
under Server Name in the Connect to Database step in SQL Server Management studio I can connect to the database, but the getConnection
step does not return. No error message/exception either.
Specs: Eclipse Indigo, SQL Server 2008, Windows 7 Enterprise
Solución
I solved the problem by upgrading the Java version for the eclipse project from JDK 6 to JDK 7.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow