package com.marcozanon.macaco.logging;
-import com.marcozanon.macaco.sql.MConnectionSqlException;
import com.marcozanon.macaco.sql.MSqlConnection;
+import com.marcozanon.macaco.sql.MSqlConnectionFailureException;
import com.marcozanon.macaco.sql.MSqlConnectionGenerator;
import com.marcozanon.macaco.sql.MSqlTable;
import com.marcozanon.macaco.sql.MStatementSqlException;
try {
this.getSqlConnectionReference().close();
}
- catch (MConnectionSqlException exception) {
+ catch (MSqlConnectionFailureException exception) {
throw new MLoggingException("Could not close Sql connection.", exception);
}
}
p.put(this.getLogDatabaseField(), timestamp + separator + message);
(new MSqlTable(this.getSqlConnectionReference(), this.getLogDatabaseTable(), this.getLogDatabaseTablePrimaryKey())).setRecord(p, null);
}
- catch (MConnectionSqlException exception) {
+ catch (MSqlConnectionFailureException exception) {
throw new MLoggingException("Could not write to database table.", exception);
}
catch (MStatementSqlException exception) {
+++ /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 MConnectionSqlException extends MSqlException {
-
- /* */
-
- public MConnectionSqlException() {
- super();
- }
-
- public MConnectionSqlException(String message) {
- super(message);
- }
-
- public MConnectionSqlException(Throwable error) {
- super(error);
- }
-
- public MConnectionSqlException(String message, Throwable error) {
- super(message, error);
- }
-
-}
/* */
- public MSqlConnection(String driver, String url, String username, String password) throws MConnectionSqlException {
+ public MSqlConnection(String driver, String url, String username, String password) throws MSqlConnectionFailureException {
super();
//
if (MText.isBlank(driver)) {
Class.forName(this.getDriver()).newInstance();
}
catch (ClassNotFoundException exception) {
- throw new MConnectionSqlException("Could not load driver.", exception);
+ throw new MSqlConnectionFailureException("Could not load driver.", exception);
}
catch (IllegalAccessException exception) {
- throw new MConnectionSqlException("Could not load driver.", exception);
+ throw new MSqlConnectionFailureException("Could not load driver.", exception);
}
catch (InstantiationException exception) {
- throw new MConnectionSqlException("Could not load driver.", exception);
+ throw new MSqlConnectionFailureException("Could not load driver.", exception);
}
// establish connection
try {
this.connection = DriverManager.getConnection(this.getUrl(), this.getUsername(), this.getPassword());
}
catch (SQLException exception) {
- throw new MConnectionSqlException("Could not get connection.", exception);
+ throw new MSqlConnectionFailureException("Could not get connection.", exception);
}
// set SQL mode
try {
this.getConnectionReference().createStatement().executeUpdate("SET SQL_MODE='ANSI'");
}
catch (SQLException exception) {
- throw new MConnectionSqlException("Could not set SQL mode to ANSI.", exception);
+ throw new MSqlConnectionFailureException("Could not set SQL mode to ANSI.", exception);
}
}
- public void close() throws MConnectionSqlException {
+ public void close() throws MSqlConnectionFailureException {
try {
this.getConnectionReference().close();
}
catch (SQLException exception) {
- throw new MConnectionSqlException("Could not close connection.", exception);
+ throw new MSqlConnectionFailureException("Could not close connection.", exception);
}
}
--- /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 MSqlConnectionFailureException extends MSqlException {
+
+ /* */
+
+ public MSqlConnectionFailureException() {
+ super();
+ }
+
+ public MSqlConnectionFailureException(String message) {
+ super(message);
+ }
+
+ public MSqlConnectionFailureException(Throwable error) {
+ super(error);
+ }
+
+ public MSqlConnectionFailureException(String message, Throwable error) {
+ super(message, error);
+ }
+
+}
/* Generator */
- public MSqlConnection getConnection() throws MConnectionSqlException {
+ public MSqlConnection getConnection() throws MSqlConnectionFailureException {
return new MSqlConnection(this.getDriver(), this.getUrl(), this.getUsername(), this.getPassword());
}
}
}
- public void close() throws MConnectionSqlException {
+ public void close() throws MSqlConnectionFailureException {
try {
if (null != this.getResultSetReference()) {
this.getResultSetReference().close();
this.getPreparedStatementReference().close();
}
catch (SQLException exception) {
- throw new MConnectionSqlException("Could not close statement and/or result set references.", exception);
+ throw new MSqlConnectionFailureException("Could not close statement and/or result set references.", exception);
}
}