ruanwenjun commented on code in PR #1791:
URL:
https://github.com/apache/incubator-seatunnel/pull/1791#discussion_r865697793
##########
seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-jdbc/src/main/java/org/apache/seatunnel/flink/jdbc/sink/JdbcSink.java:
##########
@@ -151,4 +178,44 @@ public void outputBatch(FlinkEnvironment env, DataSet<Row>
dataSet) {
.finish();
dataSet.output(format);
}
+
+ @Override
+ public void close() throws Exception {
+ executePostSql();
+ }
+
+ private void executePreSql() {
+ if (!StringUtils.isNotBlank(preSql)) {
Review Comment:
```suggestion
if (StringUtils.isNotBlank(preSql)) {
```
##########
seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-jdbc/src/main/java/org/apache/seatunnel/flink/jdbc/sink/JdbcSink.java:
##########
@@ -151,4 +178,44 @@ public void outputBatch(FlinkEnvironment env, DataSet<Row>
dataSet) {
.finish();
dataSet.output(format);
}
+
+ @Override
+ public void close() throws Exception {
+ executePostSql();
+ }
+
+ private void executePreSql() {
+ if (!StringUtils.isNotBlank(preSql)) {
+ LOGGER.info("Starting to execute pre sql: \n {}", preSql);
+ try {
+ executeSql(preSql);
+ } catch (SQLException e) {
+ LOGGER.error(String.format("Execute pre sql failed, pre sql is
: \n %s \n", preSql), e);
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private void executePostSql() {
+ if (!StringUtils.isNotBlank(postSql)) {
Review Comment:
```suggestion
if (StringUtils.isNotBlank(postSql)) {
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]