• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DriverManager.getConnection hangs from actionPerformed

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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().


 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
Mac Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic