Skip to content
Permalink
Browse files

0003825: Oracle bulk loader using SQL*Loader sqlldr

  • Loading branch information...
elong
elong committed Dec 14, 2018
1 parent 151d5a2 commit afacba8dabdf7e93e87cbc6e8daea516d081f3c9
@@ -116,7 +116,7 @@ public boolean start(Table table) {
}
}
}
if (dataResource == null) {
if (dataResource == null && !isFallBackToDefault()) {
createStagingFile();
}
return true;
@@ -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);
@@ -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;
}
}

0 comments on commit afacba8

Please sign in to comment.
You can’t perform that action at this time.