JDBC Connection from Single Computer
Hello,
I’m having a problem with a JDBC connection to a remote SQL server. I’m taking a Java course and they have setup a remote server for us with a username and password. I am able to connect to the database fine from other computers but not the one that I use for development.
It goes as far as loading the driver but then hangs (without throwing an exception) when it reaches the DriverManager.getConnection() method. I tried the same code on two other computers (Windows and Mac) from within the same network and it worked fine.
The PC I’m having problems with is running Windows 7. I tried disabling the firewall and AVG anti-virus but not help. I’m running Eclipse.
Any advice on what I could try? Thanks very much!
Max
Re: JDBC Connection from Single Computer
Can U post Your Source Code Here,
Coding Part Use to Connect the DB
Re: JDBC Connection from Single Computer
Quote:
Originally Posted by
Salinda Anura
Can U post Your Source Code Here,
Coding Part Use to Connect the DB
Thank you for the reply, Salinda! As mentioned I'm not sure if the code is the problem because running the same project from another computer in the same network works just fine. I however, included it below, without the remote server and credentials obviously. Pretty simple:
Quote:
Class.forName(com.microsoft.sqlserver.jdbc.SQLServ erDriver);
System.out.println("Driver Loaded");
connection = DriverManager.getConnection(SQL_URL, SQL_USERNAME, SQL_PASSWORD);
System.out.println("Connection Established");
What happens on the computer that's being a problem is I can see the Driver Loaded message and then it just sits there. Ie: the windows mouse icon just starts spinning and nothing happens until I terminate the JVM. There is no exception thrown, nothing. If I run it from another computer, it connects and I can perform SQL DDL/DML no problem. I did a netstat and it is showing that a connection has been established to the Database URL but for some reason nothing is happening.
Thanks again.
Max
Re: JDBC Connection from Single Computer
Hi,
Are you using proper jar for that.
Core java
Re: JDBC Connection from Single Computer
Quote:
Originally Posted by
mr.miku
Hi,
Are you using proper jar for that.
Thanks for the reply! Yes I am using the correct JAR, as mentioned the code works on other computers.
I found out that there's a problem between one of the Microsoft patches and the latest Java 6 version. I downgraded to update 27 and it worked. Hopefully this helps someone else.
Thanks,
Max