I want to send two different prepared statements in one single batch.
Currently I am doing this in two as you can see in the commented lines and it works,
You can try execute the two statement is a single transaction, like this:
connection.setAutoCommit(false);
try {
stmt1.execute();
stmt2.execute();
connection.commit();
} catch (Exception ex) {
connection.rollback();
}
The issue is that addBatch works on a single prepared statement, see this is how you can use multiple sql statements with addBatch.