wuchong commented on a change in pull request #12427:
URL: https://github.com/apache/flink/pull/12427#discussion_r435711642



##########
File path: 
flink-connectors/flink-connector-jdbc/src/main/java/org/apache/flink/connector/jdbc/internal/executor/InsertOrUpdateJdbcExecutor.java
##########
@@ -83,6 +88,21 @@ public void open(Connection connection) throws SQLException {
                updateStatement = connection.prepareStatement(updateSQL);
        }
 
+       @Override
+       public void reopen(Connection connection) throws SQLException {
+               try {
+                       existStatement.close();
+                       insertStatement.close();
+                       updateStatement.close();
+               } catch (SQLException e) {
+                       LOG.info("PreparedStatement close failed.", e);
+               }
+
+               existStatement = connection.prepareStatement(existSQL);
+               insertStatement = connection.prepareStatement(insertSQL);
+               updateStatement = connection.prepareStatement(updateSQL);

Review comment:
       > Thanks for review, @wuchong . Yes, move the `batch` map into 
constructor looks better. However, I think it will confuse people if change 
`open` to `openConnection`. Because in `open`, we just init `PrepareStatement`, 
and at this moment the JDBC connection is already open. `openConnection` will 
confuse people with "open JDBC connecton".
   
   Then I suggest to call them `prepareStatements(Connection)` and 
`closeStatements(Connection)`.
   
   
   > Hi @wuchong , I have checked the implementation of `open` and `close`. The 
`reopen` is not the simple combination of `close` and `open`. The difference is 
that `close` will clear the `batch` map. It's not what we wan't.
   > 
   > So we need to introduce a new `reopen` interface.
   
   I know currently we have an additional `batch` map initializatino in the 
`open`, that's why I suggest to move it into constructor in the previous 
comment. 
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to