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();