import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; /** * */ /** * @author Todd * */ public class Bug27652 { public static String INSERT_SQL = ""; public static int NUM = 0; public static final String URL1 = "jdbc:mysql://localhost:3306/bug27652?rewriteBatchedStatements=true"; private static final String uid = "root"; private static final String pwd = null; public static int MAX_ITERATIONS = 100; public static int MAX_BATCH = 1000; /** * @param args */ public static void main(String[] args) throws Exception { Connection conn = null; Statement stmt = null; try { Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(URL1, uid, pwd); buildInsertString(); for(int i = 0; i < MAX_ITERATIONS; i++) { stmt = conn.createStatement(); for(int j = 0; j < MAX_BATCH; j++) { stmt.addBatch(INSERT_SQL); } stmt.executeBatch(); stmt.clearBatch(); stmt.close(); } conn.close(); } catch (SQLException e) { e.printStackTrace(); } System.exit(0); } public static void buildInsertString() { StringBuffer sb = new StringBuffer("INSERT INTO test VALUES ("); boolean first = true; for(int i = 1; i <= 5; i++) { for(int j = 1; j <= 26; j++) { if(!first) sb.append(", "); sb.append(i * j); first = false; } } sb.append(")"); INSERT_SQL = sb.toString(); } }