String str = req.getParameter("data");
JSONObject jo = JSONObject.fromObject(str);
Connection connection = DataProxool.getOneConnection();// 获取一个连接池
PreparedStatement cmd = null;
try {
connection.setAutoCommit(false);
cmd = connection.prepareStatement("INSERT INTO BN_OFFLINE_IMPORT(NETBAR_ID,IDENTITY_ID,IMPORT_MONEY) values(?,?,?)");
long netbarId = jo.getLong("netbarId");
JSONArray json = JSONArray.fromObject(jo.get("data")); // 首先把字符串转成 JSONArray 对象
if(null!=json && 0 < json.size()){
for(int i=0;i<json.size();i++){
JSONObject job = json.getJSONObject(i);
cmd.setLong(1, netbarId);
cmd.setString(2, job.getString("idCard"));
cmd.setDouble(3, job.getDouble("money"));
try {
cmd.executeUpdate();
} catch (SQLException e) {
}
}
}
connection.setAutoCommit(true);
connection.commit();
cmd.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
JSONObject jo = JSONObject.fromObject(str);
Connection connection = DataProxool.getOneConnection();// 获取一个连接池
PreparedStatement cmd = null;
try {
connection.setAutoCommit(false);
cmd = connection.prepareStatement("INSERT INTO BN_OFFLINE_IMPORT(NETBAR_ID,IDENTITY_ID,IMPORT_MONEY) values(?,?,?)");
long netbarId = jo.getLong("netbarId");
JSONArray json = JSONArray.fromObject(jo.get("data")); // 首先把字符串转成 JSONArray 对象
if(null!=json && 0 < json.size()){
for(int i=0;i<json.size();i++){
JSONObject job = json.getJSONObject(i);
cmd.setLong(1, netbarId);
cmd.setString(2, job.getString("idCard"));
cmd.setDouble(3, job.getDouble("money"));
try {
cmd.executeUpdate();
} catch (SQLException e) {
}
}
}
connection.setAutoCommit(true);
connection.commit();
cmd.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
}