Skip to content

Commit

Permalink
0003825: Oracle bulk loader using SQL*Loader sqlldr
Browse files Browse the repository at this point in the history
  • Loading branch information
elong committed Dec 14, 2018
1 parent 151d5a2 commit afacba8
Showing 1 changed file with 25 additions and 8 deletions.
Expand Up @@ -116,7 +116,7 @@ public boolean start(Table table) {
}
}
}
if (dataResource == null) {
if (dataResource == null && !isFallBackToDefault()) {
createStagingFile();
}
return true;
Expand Down Expand Up @@ -227,6 +227,7 @@ protected void bulkWrite(CsvData data) {
}

protected void flush() {
boolean inError = false;
if (rows > 0) {
dataResource.close();
statistics.get(batch).startTimer(DataWriterStatisticConstants.LOADMILLIS);
Expand Down Expand Up @@ -259,22 +260,38 @@ protected void flush() {
} else if (rc != 0) {
throw new RuntimeException("Process builder returned " + rc);
}

dataResource.delete();
File absFile = controlResource.getFile().getAbsoluteFile();
new File(absFile.getPath().replace(".create", ".bad")).delete();
new File(absFile.getPath().replace(".create", ".log")).delete();
controlResource.delete();
} catch (Exception e) {
inError = true;
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new RuntimeException(e);
} finally {
statistics.get(batch).stopTimer(DataWriterStatisticConstants.LOADMILLIS);
dataResource = null;
cleanup(inError);
rows = 0;
}
} else {
cleanup(inError);
}
}

protected void cleanup(boolean inError) {
if (dataResource != null) {
dataResource.delete();
dataResource = null;
}
if (controlResource != null) {
if (!inError) {
File absFile = controlResource.getFile().getAbsoluteFile();
try {
new File(absFile.getPath().replace(".create", ".bad")).delete();
new File(absFile.getPath().replace(".create", ".log")).delete();
} catch (Exception e) {
}
controlResource.delete();
}
controlResource = null;
}
}

Expand Down

0 comments on commit afacba8

Please sign in to comment.