'Is it possible to use addBatch() for preparedStatements in the following way?
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?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
