aspose file tools*
The moose likes JDBC and the fly likes Number of commands in a batch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Number of commands in a batch" Watch "Number of commands in a batch" New topic
Author

Number of commands in a batch

Tom Field
Greenhorn

Joined: Feb 18, 2009
Posts: 1
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

Joined: May 26, 2003
Posts: 31062
    
232

Tom Field wrote:but I can't find any solution except keeping a counter for each PreparedStatement.

That's what I would do too.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Doesn't the collection from which you get the parameters for setting in the preparedstatement have a method which returns the size?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number of commands in a batch