11. Understanding JDBC Connectivity : JDBC Implementation Considerations : Batch Statement Execution : Batch Statement Execution Example
 
Share this page                  
Batch Statement Execution Example
Here is a Java code segment that shows batched inserts using prepared statements:
PreparedStatement prep = conn.prepareStatement( "insert into emp( id, name ) values( ?, ? )" );
 
 
prep.setInt( 1, 1001 );
 
prep.setString( 2, "Adam Anderson" );
 
prep.addBatch();
 
 
...
 
 
prep.setInt( 1, 1099 );
 
prep.setInt( 2, "Barry Bradley" );
 
prep.addBatch();
 
 
 
int results[] = prep.executeBatch()