Renamed MConnectionSqlException to MSqlConnectionFailureException.
authorMarco Zanon <info@marcozanon.com>
Thu, 22 Oct 2015 13:08:48 +0000 (13:08 +0000)
committerMarco Zanon <info@marcozanon.com>
Thu, 22 Oct 2015 13:08:48 +0000 (13:08 +0000)
4.x/src/java/com/marcozanon/macaco/logging/MLogDatabaseTable.java
4.x/src/java/com/marcozanon/macaco/sql/MConnectionSqlException.java [deleted file]
4.x/src/java/com/marcozanon/macaco/sql/MSqlConnection.java
4.x/src/java/com/marcozanon/macaco/sql/MSqlConnectionFailureException.java [new file with mode: 0644]
4.x/src/java/com/marcozanon/macaco/sql/MSqlConnectionGenerator.java
4.x/src/java/com/marcozanon/macaco/sql/MSqlStatementResults.java

index d4cb2a4a43746f914960e967605d4a74b9627f79..2922b411d4db84ae5edb56513371f8acf481f0fb 100644 (file)
@@ -6,8 +6,8 @@
 
 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;
@@ -54,7 +54,7 @@ public class MLogDatabaseTable extends MLogTarget {
         try {
             this.getSqlConnectionReference().close();
         }
-        catch (MConnectionSqlException exception) {
+        catch (MSqlConnectionFailureException exception) {
             throw new MLoggingException("Could not close Sql connection.", exception);
         }
     }
@@ -115,7 +115,7 @@ public class MLogDatabaseTable extends MLogTarget {
             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) {
diff --git a/4.x/src/java/com/marcozanon/macaco/sql/MConnectionSqlException.java b/4.x/src/java/com/marcozanon/macaco/sql/MConnectionSqlException.java
deleted file mode 100644 (file)
index 6f7f33a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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);
-    }
-
-}
index 44ee45361a91e07883b76f8c74db01f006e5a1aa..a78045450ce737bb51868295c21072aa6e32076a 100644 (file)
@@ -33,7 +33,7 @@ public class MSqlConnection extends MObject {
 
     /* */
 
-    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)) {
@@ -58,36 +58,36 @@ public class MSqlConnection extends MObject {
             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);
         }
     }
 
diff --git a/4.x/src/java/com/marcozanon/macaco/sql/MSqlConnectionFailureException.java b/4.x/src/java/com/marcozanon/macaco/sql/MSqlConnectionFailureException.java
new file mode 100644 (file)
index 0000000..fd0636b
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * 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);
+    }
+
+}
index e141ebc5e60c22bd8d0728009e3516a41662cf39..574d1f1bf021527f84e8fe4d8079f0b7a9faa142 100644 (file)
@@ -66,7 +66,7 @@ public class MSqlConnectionGenerator extends MObject {
 
     /* Generator */
 
-    public MSqlConnection getConnection() throws MConnectionSqlException {
+    public MSqlConnection getConnection() throws MSqlConnectionFailureException {
         return new MSqlConnection(this.getDriver(), this.getUrl(), this.getUsername(), this.getPassword());
     }
 
index 0cd11803a5b9426bdc6a6f3bed4840f876b8e248..84e943a27533a0f32347cb70bad1a0a9e020f814 100644 (file)
@@ -67,7 +67,7 @@ public class MSqlStatementResults extends MObject {
         }
     }
 
-    public void close() throws MConnectionSqlException {
+    public void close() throws MSqlConnectionFailureException {
         try {
             if (null != this.getResultSetReference()) {
                 this.getResultSetReference().close();
@@ -75,7 +75,7 @@ public class MSqlStatementResults extends MObject {
             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);
         }
     }