File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing Application freezes in DriverManager.getConnection" Watch "Swing Application freezes in DriverManager.getConnection" New topic

Swing Application freezes in DriverManager.getConnection

Eby George

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 - 64bi(the server is located on a remote Unix box).

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

Joined: Sep 20, 2010
Posts: 4639

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?

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 502

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

Joined: Oct 27, 2005
Posts: 20279

In other words, read Concurrency in Swing.

How To Ask Questions How To Answer Questions
Eby George

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

Joined: May 03, 2008
Posts: 5115

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.
I agree. Here's the link:
subject: Swing Application freezes in DriverManager.getConnection
jQuery in Action, 3rd edition