Oracleaddbatch()使用详细的解释

Oracle addbatch()使用详细的解释

preparedstatement.addbatch(的使用)



声明和PreparedStatement的区别不是很多废话,直接谈最重要的addbatch使用PreparedStatement()结构。

1。建立链接




连接= getConnection();


2。非自动提交




connection.setautocommit(假);


三.预编译的SQL语句,只编译一回哦,效率高




PreparedStatement语句= connection.preparestatement(插入附表X值(,));

1 记录
(1, 1)statement.setint;
statement.setstring(2,狗);
statement.addbatch();

2 记录
(1, 2)statement.setint;
Statement.setString (2, Fred);
statement.addbatch();

3 记录
(1, 3)statement.setint;
statement.setstring(2,马克);
statement.addbatch();

批执行3以上语句。
int { } = statement.executebatch(计数);

将其提交到(db)




以上是Oracle addbatch使用()。如有任何疑问,请留言或与当地社区交换意见。谢谢你的阅读。我们希望能帮助你。感谢您对本站的支持。