I have the following code.
try {
PreparedStatement preSt = null;
try {
preSt = conn.prepareStatement("insert into table values (?)");
preSt.setBigDecimal(1, bdVal);
preSt.addBatch();
while (condition) {
preSt.setBigDecimal(1, bdVal1);
preSt.addBatch();
}
while (condtiton2) {
preSt.setBigDecimal(1, bdVal2);
preSt.addBatch();
}
preSt.executeBatch();
}
}
I want to insert different values into the table based on the condition using prepared statements. Would the above solution work? Is there any documentation/examples available for the same?