Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Statement Reuse?

 
Aum Tao
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to know if we can reuse the same Statement object for executing more than one query. Or, should we create a new statement for different queries.

For example,


In the above case, is there any harm in using the same statement st1 for both the executeUpdate() queries?
 
aleem khan
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can use the same statement object, after all it is just as instance of class Connection. And with that instance you are invoking the method executeUpdate(). If it behaves differently then the basic OO Concepts itself is incorrect
 
aleem khan
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry typo mistake, it is "not instance of Connection" , it is of type Statement
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic