Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Statement for more then one insert quries  RSS feed

 
ehsan ulhaq dar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2628
17
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ehsan,

You can reuse the object.
Regards, Jan
 
Scott Selikoff
author
Bartender
Posts: 4083
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!