Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions core/src/main/java/org/apache/hop/core/database/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -512,13 +512,12 @@ public synchronized void disconnect() {
try {
closeConnectionOnly();
} catch (
HopDatabaseException ignoredKde) { // The only exception thrown from closeConnectionOnly()
// cannot do anything about this but log it
HopDatabaseException hde) {
log.logError(
"Error disconnecting from database - closeConnectionOnly failed:"
+ Const.CR
+ ignoredKde.getMessage());
log.logError(Const.getStackTracker(ignoredKde));
+ hde.getMessage());
log.logError(Const.getStackTracker(hde));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,35 +135,56 @@ public void prepareExecution() throws HopException {
for (Database database : databases) {
// All fine? Commit!
//
if (result.getResult() && !result.isStopped() && result.getNrErrors() == 0) {
try {
if (result.getResult() && !result.isStopped() && result.getNrErrors() == 0) {
try {
database.commit(true);
pipeline
.getLogChannel()
.logBasic(
"All transactions of database connection '"
+ database.getDatabaseMeta().getName()
+ "' were committed at the end of the pipeline!");
} catch (HopDatabaseException e) {
throw new HopException(
"Error committing database connection "
+ database.getDatabaseMeta().getName(),
e);
}
} else {
try {
database.rollback(true);
pipeline
.getLogChannel()
.logBasic(
"All transactions of database connection '"
+ database.getDatabaseMeta().getName()
+ "' were rolled back at the end of the pipeline!");
} catch (HopDatabaseException e) {
throw new HopException(
"Error rolling back database connection "
+ database.getDatabaseMeta().getName(),
e);
}
}
} finally {
// Always close connection!
try {
database.commit(true);
database.closeConnectionOnly();
pipeline
.getLogChannel()
.logBasic(
"All transactions of database connection '"
.logDebug(
"Database connection '"
+ database.getDatabaseMeta().getName()
+ "' were committed at the end of the pipeline!");
} catch (HopDatabaseException e) {
throw new HopException(
"Error committing database connection "
+ database.getDatabaseMeta().getName(),
e);
}
} else {
try {
database.rollback(true);
+ "' closed successfully!");
} catch (HopDatabaseException hde) {
pipeline
.getLogChannel()
.logBasic(
"All transactions of database connection '"
+ database.getDatabaseMeta().getName()
+ "' were rolled back at the end of the pipeline!");
} catch (HopDatabaseException e) {
throw new HopException(
"Error rolling back database connection "
+ database.getDatabaseMeta().getName(),
e);
.logError(
"Error disconnecting from database - closeConnectionOnly failed:"
+ Const.CR
+ hde.getMessage());
pipeline.getLogChannel().logError(Const.getStackTracker(hde));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,42 +117,63 @@ public Result startExecution() {
for (Database database : databases) {
// All fine? Commit!
//
if (result.getResult() && !result.isStopped() && result.getNrErrors() == 0) {
try {
database.commit(true);
workflow
.getLogChannel()
.logBasic(
"All transactions of database connection '"
+ database.getDatabaseMeta().getName()
+ "' were committed at the end of the workflow!");
} catch (HopDatabaseException e) {
workflow
.getLogChannel()
.logError(
"Error committing database connection "
+ database.getDatabaseMeta().getName(),
e);
result.setNrErrors(result.getNrErrors() + 1);
try {
if (result.getResult() && !result.isStopped() && result.getNrErrors() == 0) {
try {
database.commit(true);
workflow
.getLogChannel()
.logBasic(
"All transactions of database connection '"
+ database.getDatabaseMeta().getName()
+ "' were committed at the end of the workflow!");
} catch (HopDatabaseException e) {
workflow
.getLogChannel()
.logError(
"Error committing database connection "
+ database.getDatabaseMeta().getName(),
e);
result.setNrErrors(result.getNrErrors() + 1);
}
} else {
// Error? Rollback!
try {
database.rollback(true);
workflow
.getLogChannel()
.logBasic(
"All transactions of database connection '"
+ database.getDatabaseMeta().getName()
+ "' were rolled back at the end of the workflow!");
} catch (HopDatabaseException e) {
workflow
.getLogChannel()
.logError(
"Error rolling back database connection "
+ database.getDatabaseMeta().getName(),
e);
result.setNrErrors(result.getNrErrors() + 1);
}
}
} else {
// Error? Rollback!
} finally {
// Always close connection!
try {
database.rollback(true);
database.closeConnectionOnly();
workflow
.getLogChannel()
.logBasic(
"All transactions of database connection '"
.logDebug(
"Database connection '"
+ database.getDatabaseMeta().getName()
+ "' were rolled back at the end of the workflow!");
} catch (HopDatabaseException e) {
workflow
+ "' closed successfully!");
} catch (HopDatabaseException hde) {
workflow
.getLogChannel()
.logError(
"Error rolling back database connection "
+ database.getDatabaseMeta().getName(),
e);
result.setNrErrors(result.getNrErrors() + 1);
"Error disconnecting from database - closeConnectionOnly failed:"
+ Const.CR
+ hde.getMessage());
workflow.getLogChannel().logError(Const.getStackTracker(hde));
}
}
}
Expand Down