String[] query = { "insert into Gericht (classification,date,name,preisExtern,preisIntern) values (?,?,?,?,?)",
"test" };
PreparedStatement stmt;
for (String str : query) {
stmt = c.prepareStatement(str);
stmt.addBatch();
}
stmt.executeBatch();
here is an example on how to use batch. if its not what you want, please tell me so.
as wished:
@XtremeBaumer how about when the parameters in prepared statement change? how can you change it dynamically?
Answer:
you can't. if you want several different queries to be executed at once, you can only use fixed statement, otherwise your code will be very large, and then you can do it manually by setting the parameters and adding it to a batch. batches are good if you have 1 query that gets different parameters and you want to add all at once