}
}
+ protected void check() {
+ try {
+ this.getConnection().prepareStatement("/* ping */ SELECT 1", PreparedStatement.RETURN_GENERATED_KEYS);
+ }
+ catch (SQLException exception) {
+ try {
+ this.initialize();
+ }
+ catch (MDatabaseConnectionFailureException exception2) { // should not happen
+ }
+ }
+ }
+
public void close() throws MDatabaseConnectionFailureException {
try {
this.getConnection().close();
throw new MSqlTransactionException("Nested transactions not allowed.");
}
try {
+ // Check the connection.
+ this.check();
+ // Start the transaction.
this.getConnection().setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
this.getConnection().setAutoCommit(false);
this.setTransactionStatus(MDatabaseConnection.TransactionStatus.SUCCESSFUL);
throw new MSqlTransactionException("Transaction not started.");
}
try {
+/*
+ // Check the connection.
+ this.check();
+*/
+ // Cancel the transaction.
this.getConnection().rollback();
this.getConnection().setAutoCommit(true);
this.setTransactionStatus(MDatabaseConnection.TransactionStatus.CLOSED);
switch (this.getTransactionStatus()) {
case SUCCESSFUL:
try {
+/*
+ // Check the connection.
+ this.check();
+*/
+ // Commit the transaction.
this.getConnection().commit();
this.getConnection().setAutoCommit(true);
this.setTransactionStatus(MDatabaseConnection.TransactionStatus.CLOSED);
PreparedStatement preparedStatement = null;
try {
// Check the connection.
- try {
- preparedStatement = this.getConnection().prepareStatement("/* ping */ SELECT 1", PreparedStatement.RETURN_GENERATED_KEYS);
- }
- catch (SQLException exception) {
- this.initialize();
- }
+ this.check();
// Prepare the statement.
preparedStatement = this.getConnection().prepareStatement(statement, PreparedStatement.RETURN_GENERATED_KEYS);
for (int p = 0; parameters.size() > p; p++) {