您好,欢迎来到爱站旅游。
搜索
您的当前位置:首页PreparedStatement批处理

PreparedStatement批处理

来源:爱站旅游

PreparedStatement批量更新关键代码 无 import java.sql.Connection;import java.sql.PreparedStatement; //...String sql = "insert into employee (name, city, phone) values (?, ?, ?)";Connection connection = new getConnection();PreparedStatement p

PreparedStatement批量更新关键代码 <无> $velocityCount-->
import java.sql.Connection;
import java.sql.PreparedStatement;
 //...
String sql = "insert into employee (name, city, phone) values (?, ?, ?)";
Connection connection = new getConnection();
PreparedStatement ps = connection.prepareStatement(sql);
 for (Employee employee: employees) {
 ps.setString(1, employee.getName());
 ps.setString(2, employee.getCity());
 ps.setString(3, employee.getPhone());
 ps.addBatch();
}
ps.executeBatch();
ps.close();
connection.close();

Copyright © 2019- azee.cn 版权所有

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务