• Post Reply Bookmark Topic Watch Topic
  • New Topic

Number of commands in a batch  RSS feed

 
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
 
author & internet detective
Marshal
Posts: 37693
575
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.
 
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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!