Java – MYSQL – Prepared Statements – Insert Batch

//create prepared statement, bind it to db connection and SQL query.
PreparedStatement = dbConnection.prepareStatement(insertTableSQL);
//For each input value set input type, input position and value.
preparedStatement.set<inputType>(<index>, <value>);
preparedStatement.set<inputType>(<index>, <value>);

//For each new row to be inserted add it to batch 
//After adding to batch all rows to be inserted. 
//It's time to call execute batch.

For a complete example please see source.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s