使用JDBC的addBatch()方法提高数据库插入更新效率

 String sql = "INSERT INTO tab1 values(?,?,?)";
   pstmt = conn.prepareStatement(sql);
   for (int i = 0; i < 6; i ++) {  
    pstmt.setString(1, UUID);
    pstmt.setString(2, "字段");
    pstmt.setString(3, "字段");
    pstmt.addBatch();
   }
   pstmt.executeBatch();

你可能感兴趣的:(java,sql,jdbc)