This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Swing Application freezes in DriverManager.getConnection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing Application freezes in DriverManager.getConnection" Watch "Swing Application freezes in DriverManager.getConnection" New topic
Author

Swing Application freezes in DriverManager.getConnection

Eby George
Greenhorn

Joined: Aug 13, 2012
Posts: 3
Hi all,
I am a newbie to Swing and Java World. I wanted to create a small swing application(as part of my project requirement) which will pull some details from the Oracle DB and display it to the user. The window just freezes on DriverManager.getConnection call and then nothing happens for a long time,until i terminate the application. The program is running fine as a stand alone Java program. But it is failing when the same is implemented in Swing. I have pasted the relevant codes. I gogled around and found several threads but could not find a solution. I am using

Netbeans 6.7.1.
Java version "1.6.0_16"
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi(the server is located on a remote Unix box).

Please let me know if any other information is needed.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3573
    
  14

Hi Ebi, welcome to CodeRanch! Please UseCodeTags. I added them for you this time.

Eby George wrote:I am a newbie to Swing and Java World. [...] I am using Netbeans 6.7.1.


Here's the problem. First learn Swing before you learn how to make a Swing program in an IDE. Writing a Swing application is incredibly hard to get right if your IDE adds all sorts of code and you don't know what it does.

Have you read Oracle's Swing tutorial yet?
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

To avoid GUI freezing, the code that connects to database should be executed in a separate thread, other than in the event dispatching thread.


PM Me If You Want to get Urgent Help on Java Programming
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

In other words, read Concurrency in Swing.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Eby George
Greenhorn

Joined: Aug 13, 2012
Posts: 3
Wow and I thot, learning Swing will be easier/faster with an IDE. Will try launching it in a seperate thread and get back with the results.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

The Swing Application Framework (org.jdesktop... classes) isn't part of Swing. Learn to use the core Java classes first. The SAF (JSR-296) may be useful for large Swing applications, but it has its own learning curve.


luck, db
There are no new questions, but there may be new answers.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Swing Application freezes in DriverManager.getConnection
 
Similar Threads
.equals() and "==" what is the output of the following code and why?
How to return class instance?
JDBC - Applet - Swing
No class def found error on other computers
need to transfer productID from url to action class in struts 2