File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Statement Reuse? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Statement Reuse?" Watch "Statement Reuse?" New topic
Author

Statement Reuse?

Aum Tao
Ranch Hand

Joined: Feb 14, 2006
Posts: 210
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?


SCJP 1.4 85%
aleem khan
Ranch Hand

Joined: Aug 07, 2008
Posts: 94
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


SCJP(1.4), SCWCD, Oracle 9i SQL certified, Oracle PLSQL Developer Certified Associate
aleem khan
Ranch Hand

Joined: Aug 07, 2008
Posts: 94
sorry typo mistake, it is "not instance of Connection" , it is of type Statement
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Statement Reuse?
 
Similar Threads
Statement Object
JDBC Transaction Setting
Transactions
Please help me the problem in rs.previous
jsp polling