Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Odd getConnection() issue

 
Nathan Doe
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21566
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21566
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic