简体   繁体   English

使用PreparedStatement进行批处理

[英]Batch processing using PreparedStatement

Am I right when I say that I can only use 1 string sql query for batch processing using PreparedStatement in Java? 我说我只能在Java中使用PreparedStatement进行批处理时使用1个字符串sql查询,对吗?

For example, this is the batch I want to process using PreparedStatement : 例如,这是我要使用PreparedStatement处理的批次:

INSERT INTO tbl_Customer VALUES(?,?,?,?)
INSERT INTO tbl_Order VALUES(?,?,?,?,?)

Is there any way to process these statements as a batch? 有什么办法可以批量处理这些语句? Sorry for my bad English. 对不起,我的英语不好。

You the following template: 您以下模板:

PreparedStatement ps = null;

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM