F
Felix Roberto
any one knows how to do a
prepared statement batch insert, and when you get a pk exception
instead of breaking
the batch, keep going with the rest?
this is a simplyfied example of what i do
problem is i can get as much as 1500 record that are generated.
so how can i insert them into the db with out much performance
sacrifice?
and garantee that if a record allready exists it just keeps going with
the rest of the
group.
PreparedStatement pstm = con.crearPreparedStatement(
"INSERT INTO "+TABLE+" ("+PK_1+","+PK_2+") VALUES (?,?)");
for(int x=0;x<record1.length;x++){
for(int y=0;y<record2.length;y++){
pstm.setString(1, record1[x]);
pstm.setString(2, record2[y]);
pstm.addBatch();
}
}
pstm.executeBatch();
prepared statement batch insert, and when you get a pk exception
instead of breaking
the batch, keep going with the rest?
this is a simplyfied example of what i do
problem is i can get as much as 1500 record that are generated.
so how can i insert them into the db with out much performance
sacrifice?
and garantee that if a record allready exists it just keeps going with
the rest of the
group.
PreparedStatement pstm = con.crearPreparedStatement(
"INSERT INTO "+TABLE+" ("+PK_1+","+PK_2+") VALUES (?,?)");
for(int x=0;x<record1.length;x++){
for(int y=0;y<record2.length;y++){
pstm.setString(1, record1[x]);
pstm.setString(2, record2[y]);
pstm.addBatch();
}
}
pstm.executeBatch();