使用 PreparedStatement 进行批处理

Batch processing using PreparedStatement

当我说我只能使用 1 个字符串 sql 查询在 Java 中使用 PreparedStatement 进行批处理时,我说得对吗?

例如,这是我要使用 PreparedStatement:

处理的批次
INSERT INTO tbl_Customer VALUES(?,?,?,?)
INSERT INTO tbl_Order VALUES(?,?,?,?,?)

有什么办法可以批量处理这些语句吗?抱歉我的英语不好。

您是以下模板:

PreparedStatement ps = null;

ps = conn.prepareStatement("INSERT INTO tbl_Customer VALUES(?,?,?,?)");
while () { 
    ...
    ps.addBatch();
}
result = ps.executeBatch();