empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1341904 - in /empire-db/trunk/empire-db/src/main/java/org/apache/empire/db: ./ exceptions/ mysql/ oracle/ postgresql/ sqlserver/
Date Wed, 23 May 2012 15:42:03 GMT
Author: doebele
Date: Wed May 23 15:42:02 2012
New Revision: 1341904

URL: http://svn.apache.org/viewvc?rev=1341904&view=rev
Log:
EMPIREDB-143

Added:
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/EmpireSQLException.java
      - copied, changed from r1341898, empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/InternalSQLException.java
Removed:
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/InternalSQLException.java
Modified:
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/QueryFailedException.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/StatementFailedException.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java?rev=1341904&r1=1341903&r2=1341904&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java Wed May 23
15:42:02 2012
@@ -34,7 +34,7 @@ import org.apache.empire.commons.Options
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.DBRelation.DBCascadeAction;
 import org.apache.empire.db.exceptions.DatabaseNotOpenException;
-import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.db.exceptions.EmpireSQLException;
 import org.apache.empire.db.exceptions.QueryFailedException;
 import org.apache.empire.db.exceptions.QueryNoResultException;
 import org.apache.empire.db.exceptions.StatementFailedException;
@@ -1240,7 +1240,7 @@ public abstract class DBDatabase extends
             return;
         } catch (SQLException sqle) { 
             // Commit failed!
-            throw new InternalSQLException(this, sqle);
+            throw new EmpireSQLException(this, sqle);
         }
     }
 
@@ -1264,7 +1264,7 @@ public abstract class DBDatabase extends
             return;
         } catch (SQLException sqle) { 
             // Commit failed!
-            throw new InternalSQLException(this, sqle);
+            throw new EmpireSQLException(this, sqle);
         }
     }
 
@@ -1284,7 +1284,7 @@ public abstract class DBDatabase extends
             return;
         } catch (SQLException sqle) { 
             // Commit failed!
-            throw new InternalSQLException(this, sqle);
+            throw new EmpireSQLException(this, sqle);
         }
     }
 
@@ -1312,7 +1312,7 @@ public abstract class DBDatabase extends
             return;
         } catch (SQLException sqle) { 
             // Commit failed!
-            throw new InternalSQLException(this, sqle);
+            throw new EmpireSQLException(this, sqle);
         }
     }
 

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java?rev=1341904&r1=1341903&r2=1341904&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java Wed
May 23 15:42:02 2012
@@ -38,7 +38,7 @@ import org.apache.empire.commons.ObjectU
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.DataMode;
 import org.apache.empire.data.DataType;
-import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.db.exceptions.EmpireSQLException;
 import org.apache.empire.exceptions.NotImplementedException;
 import org.apache.empire.exceptions.NotSupportedException;
 import org.slf4j.Logger;
@@ -223,7 +223,7 @@ public abstract class DBDatabaseDriver i
                 return new Long(seqValue);
             } catch (SQLException e) {
                 // throw exception
-                throw new InternalSQLException(this, e);
+                throw new EmpireSQLException(this, e);
             } finally
             { // Cleanup
                 db.closeStatement(stmt);

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java?rev=1341904&r1=1341903&r2=1341904&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java Wed May 23
15:42:02 2012
@@ -36,7 +36,7 @@ import org.apache.commons.beanutils.Cons
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.data.ColumnExpr;
 import org.apache.empire.data.DataType;
-import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.db.exceptions.EmpireSQLException;
 import org.apache.empire.db.exceptions.QueryNoResultException;
 import org.apache.empire.exceptions.BeanInstantiationException;
 import org.apache.empire.exceptions.InvalidArgumentException;
@@ -133,7 +133,7 @@ public class DBReader extends DBRecordDa
                 return true;
             } catch (SQLException e) {
                 // Error
-                throw new InternalSQLException(getDatabase(), e);
+                throw new EmpireSQLException(getDatabase(), e);
             }
         }
 
@@ -375,7 +375,7 @@ public class DBReader extends DBRecordDa
 
         } catch (SQLException e)
         { // Operation failed
-            throw new InternalSQLException(this, e);
+            throw new EmpireSQLException(this, e);
         }
     }
 
@@ -532,7 +532,7 @@ public class DBReader extends DBRecordDa
 
         } catch (SQLException e) {
             // an error occurred
-            throw new InternalSQLException(this, e);
+            throw new EmpireSQLException(this, e);
         }
     }
 
@@ -557,7 +557,7 @@ public class DBReader extends DBRecordDa
 
         } catch (SQLException e) {
             // an error occurred
-            throw new InternalSQLException(this, e);
+            throw new EmpireSQLException(this, e);
         }
     }
 

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java?rev=1341904&r1=1341903&r2=1341904&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java Wed May
23 15:42:02 2012
@@ -23,7 +23,7 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Iterator;
 
-import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.db.exceptions.EmpireSQLException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -123,7 +123,7 @@ public class DBSQLScript implements Iter
                 log.error(e.toString(), e);
                 if (ignoreErrors==false)
                 {   // forward exception
-                    throw new InternalSQLException(driver, e);
+                    throw new EmpireSQLException(driver, e);
                 }    
                 // continue
                 log.debug("Ignoring error. Continuing with script...");

Copied: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/EmpireSQLException.java
(from r1341898, empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/InternalSQLException.java)
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/EmpireSQLException.java?p2=empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/EmpireSQLException.java&p1=empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/InternalSQLException.java&r1=1341898&r2=1341904&rev=1341904&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/InternalSQLException.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/EmpireSQLException.java
Wed May 23 15:42:02 2012
@@ -25,7 +25,7 @@ import org.apache.empire.db.DBDatabaseDr
 import org.apache.empire.db.DBObject;
 import org.apache.empire.exceptions.EmpireException;
 
-public class InternalSQLException extends EmpireException
+public class EmpireSQLException extends EmpireException
 {
     /**
      * Comment for <code>serialVersionUID</code>
@@ -33,31 +33,40 @@ public class InternalSQLException extend
     private static final long serialVersionUID = 1L;
     
     public static final ErrorType errorType = new ErrorType("error.db.sqlException", "The
database operation failed. Native error is: {0}");
+    
+    private final String nativeErrorMessage;
 
     protected static String messageFromSQLException(DBDatabaseDriver driver, SQLException
sqle)
     {   // Set the error Message
         return (driver!=null ? driver.extractErrorMessage(sqle) : sqle.getMessage());
     }
 
-    protected static DBDatabaseDriver driverFromObject(DBObject obj)
+	protected static DBDatabaseDriver driverFromObject(DBObject obj)
     {   // Set the error Message
         return (obj.getDatabase()!=null ? obj.getDatabase().getDriver() : (DBDatabaseDriver)null);
     }
     
-    public InternalSQLException(DBDatabaseDriver driver, SQLException cause)
+    public EmpireSQLException(DBDatabaseDriver driver, SQLException cause)
     {
         super(errorType, new String[] { messageFromSQLException(driver, cause) }, cause );
+        nativeErrorMessage = this.getErrorParams()[0];
     }
     
-    public InternalSQLException(DBObject obj, SQLException cause)
+    public EmpireSQLException(DBObject obj, SQLException cause)
     {
         this(driverFromObject(obj), cause);
     }
     
     // Derived classes only
-    protected InternalSQLException(ErrorType type, String[] params, SQLException cause)
+    protected EmpireSQLException(ErrorType type, String[] params, int nativeErrorIndex, SQLException
cause)
     {
         super(type, params, cause);
+        nativeErrorMessage = this.getErrorParams()[nativeErrorIndex];
     }
+
+    public String getNativeErrorMessage() 
+    {
+		return nativeErrorMessage;
+	}
     
 }

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/QueryFailedException.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/QueryFailedException.java?rev=1341904&r1=1341903&r2=1341904&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/QueryFailedException.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/QueryFailedException.java
Wed May 23 15:42:02 2012
@@ -25,7 +25,7 @@ import org.apache.empire.db.DBObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class QueryFailedException extends InternalSQLException
+public class QueryFailedException extends EmpireSQLException
 {
     // Logger
     private static final Logger log = LoggerFactory.getLogger(QueryFailedException.class);
@@ -40,7 +40,7 @@ public class QueryFailedException extend
     
     public QueryFailedException(DBObject obj, String sqlCmd, SQLException cause)
     {
-        super(QueryFailedException.errorType, new String[] { sqlCmd, messageFromSQLException(driverFromObject(obj),
cause) }, cause);
+        super(QueryFailedException.errorType, new String[] { sqlCmd, messageFromSQLException(driverFromObject(obj),
cause) }, 1, cause);
     }
     
     /**

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/StatementFailedException.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/StatementFailedException.java?rev=1341904&r1=1341903&r2=1341904&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/StatementFailedException.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/exceptions/StatementFailedException.java
Wed May 23 15:42:02 2012
@@ -25,7 +25,7 @@ import org.apache.empire.db.DBObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class StatementFailedException extends InternalSQLException
+public class StatementFailedException extends EmpireSQLException
 {
     // Logger
     private static final Logger log = LoggerFactory.getLogger(StatementFailedException.class);
@@ -40,7 +40,7 @@ public class StatementFailedException ex
     
     public StatementFailedException(DBObject obj, String sqlCmd, SQLException cause)
     {
-        super(StatementFailedException.errorType, new String[] { sqlCmd, messageFromSQLException(driverFromObject(obj),
cause) }, cause);
+        super(StatementFailedException.errorType, new String[] { sqlCmd, messageFromSQLException(driverFromObject(obj),
cause) }, 1, cause);
     }
     
     /**

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java?rev=1341904&r1=1341903&r2=1341904&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
Wed May 23 15:42:02 2012
@@ -35,7 +35,7 @@ import org.apache.empire.db.DBDriverFeat
 import org.apache.empire.db.DBObject;
 import org.apache.empire.db.DBSQLScript;
 import org.apache.empire.db.DBTable;
-import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.db.exceptions.EmpireSQLException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -229,7 +229,7 @@ public class DBDatabaseDriverMySQL exten
             
         } catch (SQLException e) {
             // throw exception
-            throw new InternalSQLException(this, e);
+            throw new EmpireSQLException(this, e);
         }
     }
 

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java?rev=1341904&r1=1341903&r2=1341904&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java
Wed May 23 15:42:02 2012
@@ -36,7 +36,7 @@ import org.apache.empire.db.DBReader;
 import org.apache.empire.db.DBSQLScript;
 import org.apache.empire.db.DBTable;
 import org.apache.empire.db.DBView;
-import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.db.exceptions.EmpireSQLException;
 import org.apache.empire.exceptions.InvalidArgumentException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -327,7 +327,7 @@ public class DBDatabaseDriverOracle exte
             return (rs.next() ? rs.getTimestamp(1) : null);
         } catch (SQLException e) {
             // throw exception
-            throw new InternalSQLException(this, e);
+            throw new EmpireSQLException(this, e);
         } finally
         { // Cleanup
             try
@@ -339,7 +339,7 @@ public class DBDatabaseDriverOracle exte
                     stmt.close();
             } catch (SQLException e) {
                 // throw exception
-                throw new InternalSQLException(this, e);
+                throw new EmpireSQLException(this, e);
             }
         }
     }

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java?rev=1341904&r1=1341903&r2=1341904&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
Wed May 23 15:42:02 2012
@@ -32,7 +32,7 @@ import org.apache.empire.db.DBDatabaseDr
 import org.apache.empire.db.DBDriverFeature;
 import org.apache.empire.db.DBObject;
 import org.apache.empire.db.DBSQLScript;
-import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.db.exceptions.EmpireSQLException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -273,7 +273,7 @@ public class DBDatabaseDriverPostgreSQL 
             executeSQL(CREATE_REVERSE_FUNCTION, null, conn, null);
         } catch(SQLException e) {
             log.error("Unable to create reverse function!", e);
-            throw new InternalSQLException(this, e);
+            throw new EmpireSQLException(this, e);
         }
     }
     

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java?rev=1341904&r1=1341903&r2=1341904&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java
Wed May 23 15:42:02 2012
@@ -34,7 +34,7 @@ import org.apache.empire.db.DBObject;
 import org.apache.empire.db.DBSQLScript;
 import org.apache.empire.db.DBTable;
 import org.apache.empire.db.DBTableColumn;
-import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.db.exceptions.EmpireSQLException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -218,7 +218,7 @@ public class DBDatabaseDriverMSSQL exten
             
         } catch (SQLException e) {
             // throw exception
-            throw new InternalSQLException(this, e);
+            throw new EmpireSQLException(this, e);
         }
     }
 



Mime
View raw message