@Test
public void baseInsertJDBCTest() throws SQLException {
System.out.println("--->>baseInsertJDBCTest<<--");
//
AppContext app = Hasor.createAppContext("net/test/simple/db/jdbc-config.xml", new OneDataSourceWarp());
JdbcTemplate jdbc = app.getInstance(JdbcTemplate.class);
//
String batchInsert = "insert into TB_User values(:ID,:Name,:Account,:Pwd,:Email,:RegTime);";
//
showUserCount(jdbc);//显示当前用户总数
int count = 10;
Map<String, Object>[] batchValues = new Map[count];
for (int i = 0; i < count; i++) {
batchValues[i] = new HashMap<String, Object>();
batchValues[i].put("ID", UUID.randomUUID().toString());
batchValues[i].put("Name", String.format("默认用户_%s", i));
batchValues[i].put("Account", String.format("acc_%s", i));
batchValues[i].put("Pwd", String.format("pwd_%s", i));
batchValues[i].put("Email", String.format("autoUser_%s@hasor.net", i));
batchValues[i].put("RegTime", new Date());
}
jdbc.batchUpdate(batchInsert, batchValues);//批量执行执行插入语句
HasorUnit.printMapList(jdbc.queryForList("select * from TB_User"));
//
showUserCount(jdbc);//显示当前用户总数
}