@Test public void testCreateMultiInsertSql() { int paramsSize = 1; String result = DaoUtil.createMultiInsertSql("insert into test values", "(?, ?, ?, now())", paramsSize); System.out.println("testCreateMultiInsertSql paramsSize:" + paramsSize + ", result:" + result); Assert.assertEquals("insert into test values(?, ?, ?, now())", result); paramsSize = 3; result = DaoUtil.createMultiInsertSql("insert ignore into test values", "(?, ?, ?, now())", paramsSize); System.out.println("testCreateMultiInsertSql paramsSize:" + paramsSize + ", result:" + result); Assert.assertEquals("insert ignore into test values(?, ?, ?, now()), (?, ?, ?, now()), (?, ?, ?, now())", result); }
public static String createMultiInsertSql(String sqlPrefix, String sqlSuffix, int valuesSize) { StringBuilder sb = new StringBuilder(sqlPrefix).append(sqlSuffix); for (int i = 1; i < valuesSize; i++) { sb.append(", "); sb.append(sqlSuffix); } return sb.toString(); }
DaoUtil { public static String createMultiInsertSql(String sqlPrefix, String sqlSuffix, int valuesSize) { StringBuilder sb = new StringBuilder(sqlPrefix).append(sqlSuffix); for (int i = 1; i < valuesSize; i++) { sb.append(", "); sb.append(sqlSuffix); } return sb.toString(); } }
DaoUtil { public static String createMultiInsertSql(String sqlPrefix, String sqlSuffix, int valuesSize) { StringBuilder sb = new StringBuilder(sqlPrefix).append(sqlSuffix); for (int i = 1; i < valuesSize; i++) { sb.append(", "); sb.append(sqlSuffix); } return sb.toString(); }  }
DaoUtil { public static String createMultiInsertSql(String sqlPrefix, String sqlSuffix, int valuesSize) { StringBuilder sb = new StringBuilder(sqlPrefix).append(sqlSuffix); for (int i = 1; i < valuesSize; i++) { sb.append(", "); sb.append(sqlSuffix); } return sb.toString(); }  static String createMutiGetEncodedSql(String sql, int paramsSize); static String createMutiGetSql(String sql, int paramsSize); static String expendMultiGetSql(String sql, Object[] params); static Object[] expendMultiGetParams(Object[] params); static String createMultiInsertSql(String sqlPrefix, String sqlSuffix, int valuesSize); static String buildSql(String rawSql, String db, String table); }
DaoUtil { public static String createMultiInsertSql(String sqlPrefix, String sqlSuffix, int valuesSize) { StringBuilder sb = new StringBuilder(sqlPrefix).append(sqlSuffix); for (int i = 1; i < valuesSize; i++) { sb.append(", "); sb.append(sqlSuffix); } return sb.toString(); }  static String createMutiGetEncodedSql(String sql, int paramsSize); static String createMutiGetSql(String sql, int paramsSize); static String expendMultiGetSql(String sql, Object[] params); static Object[] expendMultiGetParams(Object[] params); static String createMultiInsertSql(String sqlPrefix, String sqlSuffix, int valuesSize); static String buildSql(String rawSql, String db, String table);  }