File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DriverManager.getConnection hangs from actionPerformed

 
faisal hameed
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am using oracle 11g and jdk 1.6 and ojdbc6 driver.
I have created GUI in netbeans GUI builder with DND.
I want to make a db connection from JButton actionPerformed method but it hangs on DriverManager.getConnection().
what is wrong with the following code.I have called this method from actionPerformed DataBase.createConnection1().


 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is with your swing code. You should put your DB code on a separate thread.
Recommended reading http://download.oracle.com/javase/tutorial/uiswing/concurrency/
 
faisal hameed
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply.
I have tried this code on 10 different PC's on same environment but it creates problem on only 2,3 PC's and hangs.
If it is my swing code issu then why it is running on some PC's.
I have also tried to make connection in differenct thread but same problem.
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you be more specific on what you mean on "hang"
GUI is unresponsive (thats what I was thinking when I posted my previous reply)
Takes too much time to connect to the DB.
Anything else?
 
Rob Spoor
Sheriff
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the PCs on which there is no problem can connect to the database very quickly then you will not notice anything. But if the other PCs cannot connect at all, it can take quite a while for the connection attempt to timeout, and the GUI will not respond for this entire duration.
 
Kevin Parsons
Greenhorn
Posts: 1
Mac Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having the same issue.

Using either NetBeans 6.9.1 or 7.0.1, Java 1.6 and Oracle 11g. I have the oracle JDBC jar files (ojdbc6_g.jar) within my project's library and when I run just the database connection code (no GUI interface), I'm able connect with no issues. As soon as I try to connect from within a GUI created by Netbeans (New Java Desktop Application Project), the thread blocks on...




If anyone has any suggestions or ideas I'd really appreciate it.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic