This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Batch Execution in JDBC

 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 381
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a Lot!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic