@@ -98,6 +98,15 @@ public void open(int taskNumber, int numTasks) throws IOException {
9898 establishConnection ();
9999 initMetric ();
100100
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+
101110 if (batchWaitInterval > 0 ) {
102111 LOG .info ("open batch wait interval scheduled, interval is {} ms" , batchWaitInterval );
103112
@@ -108,15 +117,6 @@ public void open(int taskNumber, int numTasks) throws IOException {
108117
109118 }
110119
111- if (dbConn .getMetaData ().getTables (null , null , tableName , null ).next ()) {
112- if (isReplaceInsertQuery ()) {
113- insertQuery = dbSink .buildUpdateSql (tableName , Arrays .asList (dbSink .getFieldNames ()), realIndexes , fullField );
114- }
115- upload = dbConn .prepareStatement (insertQuery );
116- } else {
117- throw new SQLException ("Table " + tableName + " doesn't exist" );
118- }
119-
120120 } catch (SQLException sqe ) {
121121 LOG .error ("" , sqe );
122122 throw new IllegalArgumentException ("open() failed." , sqe );
0 commit comments