File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Batch updates using PreparedStatement
 
Similar Threads
transaction size and commit
executeBatch
problems with batch update
Batch Execution in JDBC
Batch Execution Solution