Ending a Thread

B

Bill Dennis

I've got an application that connects to a DB2 database as follows:

java.util.Properties info = new java.util.Properties();
info.put("user", user);
info.put("password", password);
Connection con = dbDriver.connect(url, info);

Sometimes, however, the DB2 driver never returns from the call to
..connect() and after some period of time, I'd like to kill the thread
that's trying to do the connection. I know that Thread.stop()
shouldn't be used. Any suggestions? Would Thread.interrupt() work?

Thanks.

Bill Dennis
 
C

Clemens Martin

Hi,

Bill Dennis said:
I've got an application that connects to a DB2 database as follows:

java.util.Properties info = new java.util.Properties();
info.put("user", user);
info.put("password", password);
Connection con = dbDriver.connect(url, info);

Which class is dbDriver instance of?
Sometimes, however, the DB2 driver never returns from the call to
.connect() and after some period of time, I'd like to kill the thread
that's trying to do the connection. I know that Thread.stop()
shouldn't be used. Any suggestions? Would Thread.interrupt() work?
Killing a thread doesnt work... in general you should quit the run() by
checking a variable.
In your case, you cant check, coz connect() doesnt return. There are 2
things i would try:

1) Maybe you can set a connect timeout property for the DB2 JDBC-Driver
(info.put....) read DB2 Docs
2) I dont know what "dbDriver" variable is of... maybe a method (in a
watchdog thread) could stop connecting

Greetings
Clemens Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top