Hi All,
I want to insert a large set of data to a table. I am following the below process.
con.setAutoCommit(false);
for(int i=0;i<100;i++){
stmt.addBatch();
stmt.addBatch();
stmt.addBatch();
stmt.addBatch();
stmt.executeBatch();
if(m%5==0){
con.commit();
}
}
con.commit();
con.setAutoCommit(true);
I can use the same statement in adding batches. Now if you see I want to use the same statements in a single transaction too. Can I do that? I mean each transaction contains 5 statements to be executed. So is it compulsory that I should use 5 different instances for statements by calling con.createStatement or is it ok to have a single instance(and it is handled by the
jdbc itself)?
Hope I have clearly explained my idea.
Thanks in advance.