提交 80da64e4 编写于 作者: clevertension's avatar clevertension

update autcommit and remove rollback to storage data as much as possible

上级 f1423649
......@@ -105,14 +105,13 @@ public class H2Client implements Client {
boolean flag;
Connection conn = getConnection();
try (PreparedStatement statement = conn.prepareStatement(sql)) {
conn.setAutoCommit(false);
conn.setAutoCommit(true);
if (params != null) {
for (int i = 0; i < params.length; i++) {
statement.setObject(i + 1, params[i]);
}
}
flag = statement.execute();
conn.commit();
} catch (SQLException e) {
throw new H2ClientException(e.getMessage(), e);
}
......
......@@ -45,7 +45,7 @@ public class BatchH2DAO extends H2DAO implements IBatchDAO {
final Map<String, PreparedStatement> batchSqls = new HashMap<>();
try {
conn = getClient().getConnection();
conn.setAutoCommit(false);
conn.setAutoCommit(true);
PreparedStatement ps;
for (Object entity : batchCollection) {
H2SqlEntity e = getH2SqlEntity(entity);
......@@ -70,14 +70,8 @@ public class BatchH2DAO extends H2DAO implements IBatchDAO {
for (String k : batchSqls.keySet()) {
batchSqls.get(k).executeBatch();
}
conn.commit();
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
try {
conn.rollback();
} catch (SQLException e1) {
logger.error(e.getMessage(), e1);
}
}
batchSqls.clear();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册