Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Moin!

Ich programmiere ein Migrationstool, das eine Oracle-Datenbank auf die gewünschte Versionierung bringen soll. Dazu werden SQL-Skripte aufgerufen, die teilweise mehrere DML- und DDL-Kommandos enthalten. Ein Skript gilt als eine Transaktion und es soll daher im Falle eines Fehlers ein Rollback erfolgen, wird das Skript aber erfolgreich ausgeführt, wird die DB-Versionsnummer geupdatet, es sei denn, das Tool läuft im Validationsmodus, dann erfolgt auch bei Erfolg ein Rollback.

Ich verwende JDBC und setzte AutoCommit auf false. Leider hat Oracle die blöde Eigenschaft, dass alle DDL-Statements automatisch commited werden, unabhängig vom AutoCommit-flag. Daher möchte ich gerne SavePoints setzen. Wenn ich es richtig verstehe, wird die DB im Falle eines rollback(savepoint) auf genau diesen Zustand zurückgesetzt, also auch alle DDL-Statements, oder?

Genau dies tue ich in den beiden folgenden Methode. Bevor ich ein Skript ausführe, setze ich einen Savepoint, denn ich dann im Falle eines rollbacks mit übergebe. Allerdings erhalte ich jedesmal die Fehlermeldung

"ORA-01086: Savepoint 'ORACLE_SVPT_3' wurde nicht festgelegt".

Hat irgendmand eine Idee, woran das liegen könnte? Übersehe ich einen dummen Fehler im Code?

Tausend Dank...

-------------------------

public boolean executeSQLScript (File script)

{

Savepoint save = setSavepoint();

boolean success = save == null? false : true;

boolean executed = false;

for (String sqlCommand : sqlCommands)

{

if (success)

{

if (!sqlCommand.contains("DBVERSION"))

{

success = executeSQL(sqlCommand);

executed = true;

}

}

}

if (success)

{

if (app.isValidate())

{

success = executed ? rollbackTransaction(save) : success;

}

else

{

success = updateDBVersion(newVersion);

}

}

else

{

if (app.isValidate())

{

MigrationToolApplication.LOGGER.output("Validation of script " + script.getName() + " couldn't be finished. Some errors occured.");

}

else

{

MigrationToolApplication.LOGGER.output("Execution of script " + script.getName() + " incorrect. Some errors occured.");

}

MigrationToolApplication.LOGGER.output("Rolling back transactions...");

rollbackTransaction(save);

}

return success;

}

private Savepoint setSavepoint()

{

try

{

MigrationToolApplication.LOGGER.output("Setting savepoint of data base for commit/rollback.");

return connect.setSavepoint();

}

catch (SQLException e)

{

MigrationToolApplication.LOGGER.output("Error during savepoint setting.");

MigrationToolApplication.LOGGER.output(e.getMessage());

return null;

}

}

Also sind Savepoints in diesem Fall so oder so sinnlos, sehe ich das richtig?

Das ist ja ätzend... :-(

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.