aspose file tools*
The moose likes JDBC and the fly likes DB2 Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DB2 Connection" Watch "DB2 Connection" New topic
Author

DB2 Connection

Matthew Lee
Greenhorn

Joined: Apr 04, 2001
Posts: 1
When you put the statement.executeQuery(String) in the run() function for a thread does this use a different connection to the database or does it use the same Connection object?
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
It will use whatever Connection you used to create the Statement - unless you closed the connection, in which case it will throw an exception at you.
The Thread concerns me a bit, though. You are aware that JDBC connections aren't threadsafe? You would have to know exactly what you're doing, carefully establish responsibilities (which class & thread will close the connection and when, etc). It sounds like a refactoring candidate. But that's just a kneejerk reaction.
- Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DB2 Connection
 
Similar Threads
JavaBean in Servlet?
closing the database connection
Dirty read (?) problem
PreparedStatement with Connection Pooling
datasource?