4040import java .util .concurrent .atomic .AtomicInteger ;
4141
4242import com .dtstack .flink .sql .sink .MetricOutputFormat ;
43+ import sun .rmi .runtime .Log ;
4344
4445/**
4546 * OutputFormat to write tuples into a database.
@@ -97,6 +98,15 @@ public void open(int taskNumber, int numTasks) throws IOException {
9798 establishConnection ();
9899 initMetric ();
99100
101+ if (dbConn .getMetaData ().getTables (null , null , tableName , null ).next ()) {
102+ if (isReplaceInsertQuery ()) {
103+ insertQuery = dbSink .buildUpdateSql (tableName , Arrays .asList (dbSink .getFieldNames ()), realIndexes , fullField );
104+ }
105+ upload = dbConn .prepareStatement (insertQuery );
106+ } else {
107+ throw new SQLException ("Table " + tableName + " doesn't exist" );
108+ }
109+
100110 if (batchWaitInterval > 0 ) {
101111 LOG .info ("open batch wait interval scheduled, interval is {} ms" , batchWaitInterval );
102112
@@ -107,18 +117,11 @@ public void open(int taskNumber, int numTasks) throws IOException {
107117
108118 }
109119
110- if (dbConn .getMetaData ().getTables (null , null , tableName , null ).next ()) {
111- if (isReplaceInsertQuery ()) {
112- insertQuery = dbSink .buildUpdateSql (tableName , Arrays .asList (dbSink .getFieldNames ()), realIndexes , fullField );
113- }
114- upload = dbConn .prepareStatement (insertQuery );
115- } else {
116- throw new SQLException ("Table " + tableName + " doesn't exist" );
117- }
118-
119120 } catch (SQLException sqe ) {
121+ LOG .error ("" , sqe );
120122 throw new IllegalArgumentException ("open() failed." , sqe );
121123 } catch (ClassNotFoundException cnfe ) {
124+ LOG .error ("" , cnfe );
122125 throw new IllegalArgumentException ("JDBC driver class not found." , cnfe );
123126 }
124127 }
@@ -271,6 +274,7 @@ private void updatePreparedStmt(Row row, PreparedStatement pstmt) throws SQLExce
271274
272275 private synchronized void submitExecuteBatch () {
273276 try {
277+ LOG .info ("submitExecuteBatch start......" );
274278 this .upload .executeBatch ();
275279 this .batchCount .set (0 );
276280 } catch (SQLException e ) {
0 commit comments