You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/07/31 12:20:15 UTC
[GitHub] [inlong] leosanqing commented on a diff in pull request #5280: [INLONG-5279][Manager] Optimize the creation code of databases and tables
leosanqing commented on code in PR #5280:
URL: https://github.com/apache/inlong/pull/5280#discussion_r933978195
##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/resource/sink/oracle/OracleJdbcUtils.java:
##########
@@ -108,14 +108,16 @@ public static ResultSet executeQuerySql(Connection conn, String sql)
* @param sqls SQL string to be executed
* @throws Exception on get execute SQL batch error
*/
- public static void executeSqlBatch(Connection conn, List<String> sqls)
- throws Exception {
+ public static void executeSqlBatch(Connection conn, List<String> sqls) throws Exception {
+ conn.setAutoCommit(false);
Statement stmt = conn.createStatement();
for (String entry : sqls) {
stmt.execute(entry);
}
+ conn.commit();
+ conn.setAutoCommit(true);
+ LOG.info("execute batch sql [{}] success", sqls);
stmt.close();
Review Comment:
It would be better to use Try-with-resources,or close the stream in finally, the commit commit throws an exception, and the stream cannot be closed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org