This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring 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