This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Customer Requirements for Developers and have Marcho Behler on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Statement for more then one insert quries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Statement for more then one insert quries" Watch "Statement for more then one insert quries" New topic
Author

Statement for more then one insert quries

ehsan ulhaq dar
Greenhorn

Joined: Jun 04, 2008
Posts: 19
In my bean class i execute more then one insert quries. Whether i use only one statement object to execute these quries or i used separate statement object for separate qury? What is sun recommendation?
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2541
    
  10

Hi Ehsan,

You can reuse the object.
Regards, Jan


OCUP UML fundamental and ITIL foundation
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3740
    
  10

Statements can be re-used although unless the queries are strongly related its often a better design to close and finish your first statement and open a new statement elsewhere. In other words, don't keep a single statement for the entire JDBC application, as your likely to have issues with opening/closing it if an exception occurs.


[OCA 8 Book] [Blog]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Statement for more then one insert quries
 
It's not a secret anymore!