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 Batch Execution in JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Batch Execution in JDBC" Watch "Batch Execution in JDBC" New topic
Author

Batch Execution in JDBC

Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
Hello Everybody,
How to use different PreparedStatements in a single batch?
e.g.
if i have a 1st prepared statemnt like
insert into emp values(?,?,?,?)
& second one:
delete from emp where empid=?

then how these statements could be added in a single batch & executed?


i hope the question is clear.

Shrinivas Mujumdar
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
You can't do that (have different prepared statements in one batch).

When you batch prepared statements it is the same statement each time only the parameters for the statement are batched.
Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
Hi,
That means it is the limitation of Batch Execution in JDBC & such issues can only be handled using Stored Procedures. Any other solution than that.?


Shrinivas

Annie Smith
Ranch Hand

Joined: Mar 05, 2005
Posts: 172
A stored procedure is usually a good choice if there are lesser calls to the procedure and much processing which could be handled on the DB end.
I am not sure if your case would exactly suit that. But I guess it would give you some (minor IMO) improvement in the performance.


Cheers!<br /><b>Annie</b>
Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
Thanks a Lot!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Batch Execution in JDBC