Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB2 Connection

 
Matthew Lee
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic