Browse Source

[BUG-6331][WorkerServer] fix preparedStatement auto close by try with resource (#6334)

Co-authored-by: caishunfeng <534328519@qq.com>
caishunfeng 3 years ago
parent
commit
61c6461994

+ 2 - 1
dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java

@@ -372,7 +372,8 @@ public class SqlTask extends AbstractTaskExecutor {
         // is the timeout set
         boolean timeoutFlag = taskExecutionContext.getTaskTimeoutStrategy() == TaskTimeoutStrategy.FAILED
                 || taskExecutionContext.getTaskTimeoutStrategy() == TaskTimeoutStrategy.WARNFAILED;
-        try (PreparedStatement stmt = connection.prepareStatement(sqlBinds.getSql())) {
+        try {
+            PreparedStatement stmt = connection.prepareStatement(sqlBinds.getSql());
             if (timeoutFlag) {
                 stmt.setQueryTimeout(taskExecutionContext.getTaskTimeout());
             }