Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

App not quitting

Status
Not open for further replies.

MartinF

Technical User
Sep 19, 2000
143
0
0
FR
Hi,

My app does not always seem to quit, i am using...

App.getApplication().exit();

The window will disappear, but the app will still be running in the background, but only sometimes.

I have determined that the cause is a database connection awaiting a response from the db server. At any one time in the app there could be either none, or many db connections awaiting responses.

The data is fetched from the DB by a method or thread creating an instance of a class that creates a connections and then uses a method in that class to submit a query and return the results.

My question is how do i access current instances of these classes? (that could be instantiaed from anywhere in the app, i.e. from within different forms)

If i can do this then i can create a flag that gets set when a query is in progress and then test all the flags in these instances before calling getApplication.exit();

One idea i did think of is adding some code to the DB connection class so that it adds itself to a Vector in the main app when it gets created so that i have easy access...any thoughts on this?

Thanks.
 
What's App and what does that exit method do? Is this a standalone application (I hope)?

Try System.exit, that shouldn't leave anything behind

Cheers,
Dian
 
App is my Application window that extends FrameView. It is a stand alone app, developed in Netbeans

The Application.exit() method supposedly gracefully exits the application.

I have also tried System.exit(0)...but this doesnt quit it either!!

I have also read online against the use of System.exit as it is too vicious!
 
Well, the correct way would be to implement each DB connection in a thread and destroy it after some timeout, but it's difficult for me to believe that a System.exit is not working, as it should terminate de JVM.

Do you have more than one Java instance running?

Cheers,
Dian
 
Hi again,

Would it be possible to send me some code to implement a DB timeout please? The issue is definately caused by the:

CreateStatement(...).executeQuery(...)

The app will not quit (even System.exit()) until the method has returned!!! incidently if you call System.exit() then window will disappear, but the app will not end and System.exit() does not return.

I have kind of messily gotten around it by building in a flag when ever a query is in progress, so that the app waits for all queries to complete before quitting, and this does seem to work, however if you lose the lan connection whilst a query is in progress then the query never returns (even when the connection is restored) and thus the app will never quit in this scenario with my new code!!!

Hence i think your timeout idea may be the better option.

Thanks again.
 
System.exit don't return and its use is legit in situations like yours: see this

Are you sure the method is actually being invocated and not queued in any background thread?

Cheers,
Dian
 
How can i tell if System.exit() is being queued in a background thread?
 
Well, it's a GUI app so you should know what's begin executed in the EVT and what not, but I guess a simple way would be a System.out.println before the System.exit call

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top