Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Number of commands in a batch

 
Tom Field
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,

I use a PreparedStatemen as such: I compile a sql in the PreparedStatement. I set the parameters, Add them to the batch using addBatch() method, set the parameters, addBatch, ....
After a while I would like to see how many of these commands(the set of parameters) are currently in the batch. I mean before I execute the executeBatch method.
I would think this would be a method on PreparedStatement (or Statement), but I can't find any solution except keeping a counter for each PreparedStatement.
I don't like this very much so I was wondering if there isn't another method to achieve this.

Thanks in advance!

Greetz,
Tom
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom Field wrote:but I can't find any solution except keeping a counter for each PreparedStatement.

That's what I would do too.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesn't the collection from which you get the parameters for setting in the preparedstatement have a method which returns the size?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic