throw new MTransactionSqlException("Nested transactions not allowed.");
}
try {
- this.getConnectionReference().createStatement().executeUpdate("START TRANSACTION");
+ this.getConnectionReference().setAutoCommit(false);
this.setTransactionStatus(MSqlConnection.TransactionStatus.SUCCESSFUL);
}
catch (SQLException exception) {
public void rollBackTransaction() throws MTransactionSqlException {
if (MSqlConnection.TransactionStatus.CLOSED == this.getTransactionStatus()) {
- throw new MTransactionSqlException("Could not find transaction.");
+ throw new MTransactionSqlException("Transaction not started.");
}
try {
- this.getConnectionReference().createStatement().executeUpdate("ROLLBACK");
+ this.getConnectionReference().rollback();
this.setTransactionStatus(MSqlConnection.TransactionStatus.CLOSED);
}
catch (SQLException exception) {
switch (this.getTransactionStatus()) {
case SUCCESSFUL:
try {
- this.getConnectionReference().createStatement().executeUpdate("COMMIT");
+ this.getConnectionReference().commit();
this.setTransactionStatus(MSqlConnection.TransactionStatus.CLOSED);
return MSqlConnection.TransactionStatus.SUCCESSFUL;
}
this.rollBackTransaction();
return MSqlConnection.TransactionStatus.FAILED;
default: // instead of "case CLOSED:" (necessary to avoid Java compilation errors)
- throw new MTransactionSqlException("Could not find transaction.");
+ throw new MTransactionSqlException("Transaction not started.");
}
}