I have two arraylists to insert into 2 columns in a database table as follows:
arraylist1: 123444, 324555, 6423643, 532326
arraylist2: jkfdsl, nkjfsdlj, jdsl
Insert more than one record:
public String saveOrder(ArrayList insertList){
System.out.println("SaveOrder DAO Method is calling " +insertList.size());
Connection con=null;
PreparedStatement ps2=null;
try {
con=open();
con.setAutoCommit(false);
con.getTransactionIsolation();
ps2=con.prepareStatement(sql1);
Iterator it=insertList.iterator();
while(it.hasNext()){
KIT0053MBean order=(KIT0053MBean)it.next();
ps2.setString(1, model.getCustomerid());
ps2.setString(2, model.getSerialid());
ps2.addBatch();
}
int i[]=ps2.executeBatch();
System.out.println("###### insertion1### row "+i.length);
con.commit();
con.setAutoCommit(true);
} catch (Exception e)
{
System.out.println(e.getMessage());
}finally{
close(con);
close(ps2);
}
}