return this.transactionStatus;
}
- public void startTransaction() throws MTransactionSqlException {
+ public void startTransaction() throws MSqlTransactionException {
if (MSqlConnection.TransactionStatus.CLOSED != this.getTransactionStatus()) {
- throw new MTransactionSqlException("Nested transactions not allowed.");
+ throw new MSqlTransactionException("Nested transactions not allowed.");
}
try {
this.getConnectionReference().setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
this.setTransactionStatus(MSqlConnection.TransactionStatus.SUCCESSFUL);
}
catch (SQLException exception) {
- throw new MTransactionSqlException("Could not start transaction.", exception);
+ throw new MSqlTransactionException("Could not start transaction.", exception);
}
}
- public void rollBackTransaction() throws MTransactionSqlException {
+ public void rollBackTransaction() throws MSqlTransactionException {
if (MSqlConnection.TransactionStatus.CLOSED == this.getTransactionStatus()) {
- throw new MTransactionSqlException("Transaction not started.");
+ throw new MSqlTransactionException("Transaction not started.");
}
try {
this.getConnectionReference().rollback();
}
catch (SQLException exception) {
this.setTransactionStatus(MSqlConnection.TransactionStatus.FAILED);
- throw new MTransactionSqlException("Could not roll back transaction.", exception);
+ throw new MSqlTransactionException("Could not roll back transaction.", exception);
}
}
- public MSqlConnection.TransactionStatus commitTransaction() throws MTransactionSqlException {
+ public MSqlConnection.TransactionStatus commitTransaction() throws MSqlTransactionException {
switch (this.getTransactionStatus()) {
case SUCCESSFUL:
try {
this.rollBackTransaction();
return MSqlConnection.TransactionStatus.FAILED;
default: // instead of "case CLOSED:" (necessary to avoid Java compilation errors)
- throw new MTransactionSqlException("Transaction not started.");
+ throw new MSqlTransactionException("Transaction not started.");
}
}
--- /dev/null
+/**
+ * Macaco
+ * Copyright (c) 2009-2015 Marco Zanon <info@marcozanon.com>.
+ * Released under MIT license (see LICENSE for details).
+ */
+
+package com.marcozanon.macaco.sql;
+
+@SuppressWarnings("serial")
+public class MSqlTransactionException extends MSqlException {
+
+ /* */
+
+ public MSqlTransactionException() {
+ super();
+ }
+
+ public MSqlTransactionException(String message) {
+ super(message);
+ }
+
+ public MSqlTransactionException(Throwable error) {
+ super(error);
+ }
+
+ public MSqlTransactionException(String message, Throwable error) {
+ super(message, error);
+ }
+
+}
+++ /dev/null
-/**
- * Macaco
- * Copyright (c) 2009-2015 Marco Zanon <info@marcozanon.com>.
- * Released under MIT license (see LICENSE for details).
- */
-
-package com.marcozanon.macaco.sql;
-
-@SuppressWarnings("serial")
-public class MTransactionSqlException extends MSqlException {
-
- /* */
-
- public MTransactionSqlException() {
- super();
- }
-
- public MTransactionSqlException(String message) {
- super(message);
- }
-
- public MTransactionSqlException(Throwable error) {
- super(error);
- }
-
- public MTransactionSqlException(String message, Throwable error) {
- super(message, error);
- }
-
-}