aspose file tools*
The moose likes JDBC and the fly likes Odd getConnection() issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Odd getConnection() issue" Watch "Odd getConnection() issue" New topic
Author

Odd getConnection() issue

Nathan Doe
Greenhorn

Joined: Oct 17, 2009
Posts: 24
Hi Everyone,

I am working on a simply little program that queries a remote database for information. To do this I go and create a standard connection using JDBC with:



This works flawlessly in Netbeans and I am able to go on and query the remote database. However, once I build the application into a jar file the program hangs infinitely on:



There are no exceptions thrown, it just sits there and doesn't do anything.

If anyone could help I would appreciate it!

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

My guess: you didn't set up the manifest of the jar to point to the JDBC driver jar correctly. (And that causes loading the class to fail, which throws an exception which you didn't notice, and the application ends abnormally. Or something like that... you didn't say what led you to believe that particular line of code to fail to terminate.)
Nathan Doe
Greenhorn

Joined: Oct 17, 2009
Posts: 24
Paul Clapham wrote:My guess: you didn't set up the manifest of the jar to point to the JDBC driver jar correctly. (And that causes loading the class to fail, which throws an exception which you didn't notice, and the application ends abnormally. Or something like that... you didn't say what led you to believe that particular line of code to fail to terminate.)


The reason that I believe it is that line because I put two System.out.println() statements around it and the first one prints to the console but nothing happens afterwards.

Another interesting thing that I just found out is that a previous program that I had written (using the same code) and worked perfectly as a jar file is now hanging at the same point. Do you think this could be something on the server side?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Nathan Doe wrote:The reason that I believe it is that line because I put two System.out.println() statements around it and the first one prints to the console but nothing happens afterwards.

That could also be because it throws an exception.
Another interesting thing that I just found out is that a previous program that I had written (using the same code) and worked perfectly as a jar file is now hanging at the same point. Do you think this could be something on the server side?

Not likely. Although you could fire up the original version in Netbeans which you said worked "flawlessly" and see if it now hangs. Still I would bet on network issues rather than the database server failing to respond.
Nathan Doe
Greenhorn

Joined: Oct 17, 2009
Posts: 24
It isn't throwing an exception, I have a try-catch block around it and it never gets to the catch. The other project that the jar used to work and now doesn't still does work in Netbeans.

Once the applications start running (when using the jar files) I can see them connect in the processes on my MS SQL Server so it looks like the application gets there at least. So i think it's been narrowed down to the pc side of things. Note: I am working on Windows 7 running in Parallells.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Odd getConnection() issue