*
The moose likes JDBC and the fly likes Batch updates using PreparedStatement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Batch updates using PreparedStatement " Watch "Batch updates using PreparedStatement " New topic
Author

Batch updates using PreparedStatement

Alok Pota
Ranch Hand

Joined: Mar 07, 2001
Posts: 185
I have an insert statement that inserts a BLOB into the table, and this statement is executed in a loop for about 100 times. I would like to be able to batch the individual
statements. Can it be done?
Will it be faster than issuing 100 different statements to the connection.
karim qazi
Greenhorn

Joined: Mar 22, 2001
Posts: 20
you can try something like this...
Statement statement = connection.createStatement();
//whatever you are looping through
while(true){
String sqlString = "Insert into table (name)values
('" + name + "')";
statement.addBatch(sqlString);
}
statement.executeBatch();
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Batch updates using PreparedStatement
 
Similar Threads
Batch Execution Solution
transaction size and commit
problems with batch update
executeBatch
Batch Execution in JDBC