php prepare 批量,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批量更新關鍵代碼
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();
本文原創發布php中文網,轉載請注明出處,感謝您的尊重!
總結
以上是生活随笔為你收集整理的php prepare 批量,PreparedStatement批处理的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java线程6种状态转换,Java线程的
- 下一篇: java 泛型 .net_Java泛型