java 下怎么执行mysql 批量插入语句
String sqlstr="insert into jp117 (a,b,c,d) values ('11699','2786','923','696'),('11699','2787','923','696')";
con.prepareStatement(sqlstr,PreparedStatement.RETURN_GENERATED_KEYS);
Statement stmt=(Statement) con.createStatement();
stmt.executeUpdate(sqlstr);
无法插入数据??
可是语句放在mysql 里执行是可以插入的
------解决方案--------------------
1000次插入方法的比较。
方法1:
Java code
conn = DriverManager.getConnection(JDBC_URL, JDBC_USER, JDBC_PASS);
pstmt = conn.prepareStatement("insert into loadtest (id, data) values (?, ?)");
for (int i = 1; i <= COUNT; i++) {
pstmt.clearParameters();
pstmt.setInt(1, i);
pstmt.setString(2, DATA);
pstmt.execute();
}