aspose file tools
The moose likes JDBC and the fly likes Batch updates of preparedstatement Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Batch updates of preparedstatement" Watch "Batch updates of preparedstatement" New topic
Author

Batch updates of preparedstatement

Alok Pota
Ranch Hand

Joined: Mar 07, 2001
Posts: 185
How do we use batch updates with PreparedStatements.. ? more specifically how do I bind variables t a bunch of preparedstatements added to a batch
is it something like this:-
Statement stmt = conn.createStatement();
stmt.addBatch("update test set id = ? where id = ?");
stmt.addBatch("delete from test1 where id = ?");
stmt.addBatch("insert into test values(?,?,?)");
stmt.setString(1,"hjghj");
stmt.setInt(2,55);
stmt.setString(3,"ghj");
stmt.setString(4,"hjghj");
stmt.setInt(5,55);
stmt.setString(6,"ghj");
stmt.executeBatch();
Would the above work?
 
jQuery in Action, 2nd edition
 
subject: Batch updates of preparedstatement
 
Similar Threads
JDBC addBatch problem
Java - Mysql connectivity
PreparedStatement always returns {-2, -2, -2,...}
Can I use a single statement while autocommit is false.
Regarding Bulk insert