empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franci...@apache.org
Subject svn commit: r1158339 [5/5] - in /incubator/empire-db/trunk: ./ empire-db-codegen/src/main/java/org/apache/empire/db/codegen/ empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/ empire-db-examples/empire-db...
Date Tue, 16 Aug 2011 15:56:44 GMT
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java?rev=1158339&r1=1158338&r2=1158339&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java Tue Aug 16 15:56:41 2011
@@ -23,7 +23,6 @@ import java.sql.SQLException;
 import java.util.GregorianCalendar;
 import java.util.Iterator;
 
-import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.DBCmdType;
@@ -41,6 +40,11 @@ import org.apache.empire.db.DBSQLScript;
 import org.apache.empire.db.DBTable;
 import org.apache.empire.db.DBTableColumn;
 import org.apache.empire.db.DBView;
+import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.exceptions.InvalidArgumentException;
+import org.apache.empire.exceptions.NotImplementedException;
+import org.apache.empire.exceptions.NotSupportedException;
+import org.apache.empire.exceptions.InvalidPropertyException;
 
 
 /**
@@ -68,17 +72,15 @@ public class DBDatabaseDriverMySQL exten
         }
         
         @Override
-        public boolean limitRows(int numRows)
+        public void limitRows(int numRows)
         {
             limit = numRows;
-            return success();
         }
 
         @Override
-        public boolean skipRows(int numRows)
+        public void skipRows(int numRows)
         {
             skip = numRows;
-            return success();
         }
          
         @Override
@@ -89,10 +91,9 @@ public class DBDatabaseDriverMySQL exten
         }
         
         @Override
-        public boolean getSelect(StringBuilder buf)
+        public void getSelect(StringBuilder buf)
         {   // call base class
-            if (super.getSelect(buf)==false)
-                return false;
+            super.getSelect(buf);
             // add limit and offset
             if (limit>=0)
             {   buf.append("\r\nLIMIT ");
@@ -103,8 +104,6 @@ public class DBDatabaseDriverMySQL exten
                     buf.append(String.valueOf(skip));
                 }    
             }
-            // done
-            return success();
         }
     }
     
@@ -164,7 +163,7 @@ public class DBDatabaseDriverMySQL exten
     }
     
     /**
-     * returns whether a sequence table is used for record identiy management.<br>
+     * returns whether a sequence table is used for record identity management.<br>
      * Default is false. In this case the AutoIncrement feature of MySQL is used.
      * @return true if a sequence table is used instead of identity columns.
      */
@@ -175,7 +174,7 @@ public class DBDatabaseDriverMySQL exten
 
     /**
      * If set to true a special table is used for sequence number generation.<br>
-     * Otherwise the AutoIncrement feature of MySQL is used identiy fields. 
+     * Otherwise the AutoIncrement feature of MySQL is used identity fields. 
      * @param useSequenceTable true to use a sequence table or false otherwise.
      */
     public void setUseSequenceTable(boolean useSequenceTable)
@@ -208,7 +207,7 @@ public class DBDatabaseDriverMySQL exten
      * @see org.apache.empire.db.DBDatabaseDriver#openDatabase(org.apache.empire.db.DBDatabase, java.sql.Connection)
      */
     @Override
-    public boolean attachDatabase(DBDatabase db, Connection conn)
+    public void attachDatabase(DBDatabase db, Connection conn)
     {
         // Prepare
         try
@@ -219,11 +218,11 @@ public class DBDatabaseDriverMySQL exten
             if (useSequenceTable && db.getTable(sequenceTableName)==null)
                 new DBSeqTable(sequenceTableName, db);
             // call Base implementation
-            return super.attachDatabase(db, conn);
+            super.attachDatabase(db, conn);
             
-        } catch (SQLException e)
-        {
-            return error(e);
+        } catch (SQLException e) {
+            // throw exception
+            throw new InternalSQLException(this, e);
         }
     }
 
@@ -243,7 +242,7 @@ public class DBDatabaseDriverMySQL exten
 
     /**
      * Returns whether or not a particular feature is supported by this driver
-     * @param type type of requrested feature. @see DBDriverFeature
+     * @param type type of requested feature. @see DBDriverFeature
      * @return true if the features is supported or false otherwise
      */
     @Override
@@ -378,22 +377,24 @@ public class DBDatabaseDriverMySQL exten
      * @see DBDatabaseDriver#getDDLScript(DBCmdType, DBObject, DBSQLScript)  
      */
     @Override
-    public boolean getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
+    public void getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
     {
         // The Object's database must be attached to this driver
         if (dbo==null || dbo.getDatabase().getDriver()!=this)
-            return error(Errors.InvalidArg, dbo, "dbo");
+            throw new InvalidArgumentException("dbo", dbo);
         // Check Type of object
         if (dbo instanceof DBDatabase)
         { // Database
             switch (type)
             {
                 case CREATE:
-                    return createDatabase((DBDatabase) dbo, script, true);
+                    createDatabase((DBDatabase) dbo, script, true);
+                    return;
                 case DROP:
-                    return dropObject(((DBDatabase) dbo).getSchema(), "DATABASE", script);
+                    dropObject(((DBDatabase) dbo).getSchema(), "DATABASE", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBTable)
@@ -401,11 +402,13 @@ public class DBDatabaseDriverMySQL exten
             switch (type)
             {
                 case CREATE:
-                    return createTable((DBTable) dbo, script);
+                    createTable((DBTable) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBTable) dbo).getName(), "TABLE", script);
+                    dropObject(((DBTable) dbo).getName(), "TABLE", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBView)
@@ -413,11 +416,13 @@ public class DBDatabaseDriverMySQL exten
             switch (type)
             {
                 case CREATE:
-                    return createView((DBView) dbo, script);
+                    createView((DBView) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBView) dbo).getName(), "VIEW", script);
+                    dropObject(((DBView) dbo).getName(), "VIEW", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBRelation)
@@ -425,20 +430,23 @@ public class DBDatabaseDriverMySQL exten
             switch (type)
             {
                 case CREATE:
-                    return createRelation((DBRelation) dbo, script);
+                    createRelation((DBRelation) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
+                    dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBTableColumn)
         { // Table Column
-            return alterTable((DBTableColumn) dbo, type, script);
+            alterTable((DBTableColumn) dbo, type, script);
+            return;
         } 
         else
-        { // an invalid argument has been supplied
-            return error(Errors.InvalidArg, dbo, "dbo");
+        { // dll generation not supported for this type
+            throw new NotSupportedException(this, "getDDLScript() for "+dbo.getClass().getName());
         }
     }
 
@@ -458,13 +466,13 @@ public class DBDatabaseDriverMySQL exten
     /*
      * return the sql for creating a Database
      */
-    protected boolean createDatabase(DBDatabase db, DBSQLScript script, boolean createSchema)
+    protected void createDatabase(DBDatabase db, DBSQLScript script, boolean createSchema)
     {
         // User Master to create Database
         if (createSchema)
         {   // check database Name
             if (StringUtils.isEmpty(databaseName))
-                return error(Errors.InvalidProperty, "databaseName");
+                throw new InvalidPropertyException("databaseName", databaseName);
             // Create Database
             script.addStmt("CREATE DATABASE IF NOT EXISTS " + databaseName + " CHARACTER SET " + characterSet);
             script.addStmt("USE " + databaseName);
@@ -477,25 +485,20 @@ public class DBDatabaseDriverMySQL exten
         Iterator<DBTable> tables = db.getTables().iterator();
         while (tables.hasNext())
         {
-            if (!createTable(tables.next(), script))
-                return false;
+            createTable(tables.next(), script);
         }
         // Create Relations
         Iterator<DBRelation> relations = db.getRelations().iterator();
         while (relations.hasNext())
         {
-            if (!createRelation(relations.next(), script))
-                return false;
+            createRelation(relations.next(), script);
         }
         // Create Views
         Iterator<DBView> views = db.getViews().iterator();
         while (views.hasNext())
         {
-            if (!createView(views.next(), script))
-                return false;
+            createView(views.next(), script);
         }
-        // Done
-        return true;
     }
     
     /**
@@ -503,7 +506,7 @@ public class DBDatabaseDriverMySQL exten
      * 
      * @return true if the table has been created successfully
      */
-    protected boolean createTable(DBTable t, DBSQLScript script)
+    protected void createTable(DBTable t, DBSQLScript script)
     {
         StringBuilder sql = new StringBuilder();
         sql.append("-- creating table ");
@@ -554,8 +557,7 @@ public class DBDatabaseDriverMySQL exten
             sql.append("'");
         }
         // Create the table
-        if (script.addStmt(sql) == false)
-            return false;
+        script.addStmt(sql);
         // Create other Indexes (except primary key)
         Iterator<DBIndex> indexes = t.getIndexes().iterator();
         while (indexes.hasNext())
@@ -583,11 +585,8 @@ public class DBDatabaseDriverMySQL exten
             }
             sql.append(")");
             // Create Index
-            if (script.addStmt(sql) == false)
-                return false;
+            script.addStmt(sql);
         }
-        // done
-        return success();
     }
     
     /**
@@ -685,8 +684,8 @@ public class DBDatabaseDriverMySQL exten
                 sql.append("CHAR(36)");
                 break;
             case UNKNOWN:
-                 log.error("Cannot append column of Data-Type 'UNKNOWN'");
-                 return false;
+                log.warn("Cannot append column of Data-Type 'UNKNOWN'");
+                return false;
         }
         // Default Value
         if (isDDLColumnDefaults() && !c.isAutoGenerated() && c.getDefaultValue()!=null)
@@ -705,7 +704,7 @@ public class DBDatabaseDriverMySQL exten
      * 
      * @return true if the relation has been created successfully
      */
-    protected boolean createRelation(DBRelation r, DBSQLScript script)
+    protected void createRelation(DBRelation r, DBSQLScript script)
     {
         DBTable sourceTable = (DBTable) r.getReferences()[0].getSourceColumn().getRowSet();
         DBTable targetTable = (DBTable) r.getReferences()[0].getTargetColumn().getRowSet();
@@ -742,10 +741,7 @@ public class DBDatabaseDriverMySQL exten
         }
         // done
         sql.append(")");
-        if (script.addStmt(sql) == false)
-            return false;
-        // done
-        return success();
+        script.addStmt(sql);
     }
 
     /**
@@ -755,7 +751,7 @@ public class DBDatabaseDriverMySQL exten
      * @param script to which to append the sql statement to
      * @return true if the statement was successfully appended to the buffer
      */
-    protected boolean alterTable(DBTableColumn col, DBCmdType type, DBSQLScript script)
+    protected void alterTable(DBTableColumn col, DBCmdType type, DBSQLScript script)
     {
         StringBuilder sql = new StringBuilder();
         sql.append("ALTER TABLE ");
@@ -776,7 +772,7 @@ public class DBDatabaseDriverMySQL exten
                 break;
         }
         // done
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
 
     /**
@@ -784,17 +780,14 @@ public class DBDatabaseDriverMySQL exten
      * 
      * @return true if the view has been created successfully
      */
-    protected boolean createView(DBView v, DBSQLScript script)
+    protected void createView(DBView v, DBSQLScript script)
     {
         // Create the Command
         DBCommandExpr cmd = v.createCommand();
         if (cmd==null)
         {   // Check whether Error information is available
             log.error("No command has been supplied for view " + v.getName());
-            if (v.hasError())
-                return error(v);
-            // No error information available: Use Errors.NotImplemented
-            return error(Errors.NotImplemented, v.getName() + ".createCommand");
+            throw new NotImplementedException(this, v.getName() + ".createCommand");
         }
         // Make sure there is no OrderBy
         cmd.clearOrderBy();
@@ -817,7 +810,7 @@ public class DBDatabaseDriverMySQL exten
         sql.append(")\r\nAS\r\n");
         cmd.addSQL( sql, DBExpr.CTX_DEFAULT);
         // done
-        return script.addStmt(sql.toString());
+        script.addStmt(sql.toString());
     }
     
     /**
@@ -825,17 +818,17 @@ public class DBDatabaseDriverMySQL exten
      * 
      * @return true if the object has been dropped successfully
      */
-    protected boolean dropObject(String name, String objType, DBSQLScript script)
+    protected void dropObject(String name, String objType, DBSQLScript script)
     {
         if (name == null || name.length() == 0)
-            return error(Errors.InvalidArg, name, "name");
+            throw new InvalidArgumentException("name", name);
         // Create Drop Statement
         StringBuilder sql = new StringBuilder();
         sql.append("DROP ");
         sql.append(objType);
         sql.append(" ");
         appendElementName(sql, name);
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
 
 }

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBCommandOracle.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBCommandOracle.java?rev=1158339&r1=1158338&r2=1158339&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBCommandOracle.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBCommandOracle.java Tue Aug 16 15:56:41 2011
@@ -19,11 +19,11 @@
 package org.apache.empire.db.oracle;
 
 // Imports
-import org.apache.empire.commons.Errors;
 import org.apache.empire.db.DBCommand;
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBTable;
 import org.apache.empire.db.expr.compare.DBCompareExpr;
+import org.apache.empire.exceptions.ObjectNotValidException;
 
 /**
  * This class handles the special features of an oracle database.
@@ -94,13 +94,12 @@ public class DBCommandOracle extends DBC
     }
     
     @Override
-    public boolean limitRows(int numRows)
+    public void limitRows(int numRows)
     {
     	if (rowNumExpr==null)
     		rowNumExpr = new OracleRowNumExpr(getDatabase());
     	// Add the constraint
     	where(rowNumExpr.isLessOrEqual(numRows));
-        return success();
     }
      
     @Override
@@ -116,15 +115,15 @@ public class DBCommandOracle extends DBC
      * Creates the SQL statement the special characteristics of
      * the Oracle database are supported.
      * 
-     * @param buf the SQL statment
+     * @param buf the SQL statement
      * @return true if the creation was successful
      */
     @Override
-    public synchronized boolean getSelect(StringBuilder buf)
+    public synchronized void getSelect(StringBuilder buf)
     {
         resetParamUsage();
         if (select == null)
-            return error(Errors.ObjectNotValid, getClass().getName()); // invalid!
+            throw new ObjectNotValidException(this);
         // Prepares statement
         buf.append("SELECT ");
         if (optimizerHint != null)
@@ -164,8 +163,6 @@ public class DBCommandOracle extends DBC
             // Add List of Order By Expressions
             addListExpr(buf, orderBy, CTX_DEFAULT, ", ");
         }
-        // Done
-        return success();
     }
     
     /**

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java?rev=1158339&r1=1158338&r2=1158339&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java Tue Aug 16 15:56:41 2011
@@ -24,7 +24,6 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Iterator;
 
-import org.apache.empire.commons.Errors;
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.DBCmdType;
 import org.apache.empire.db.DBColumn;
@@ -42,6 +41,10 @@ import org.apache.empire.db.DBSQLScript;
 import org.apache.empire.db.DBTable;
 import org.apache.empire.db.DBTableColumn;
 import org.apache.empire.db.DBView;
+import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.exceptions.InvalidArgumentException;
+import org.apache.empire.exceptions.NotImplementedException;
+import org.apache.empire.exceptions.NotSupportedException;
 
 
 /**
@@ -97,7 +100,7 @@ public class DBDatabaseDriverOracle exte
 
     /**
      * Returns whether or not a particular feature is supported by this driver
-     * @param type type of requrested feature. @see DBDriverFeature
+     * @param type type of requested feature. @see DBDriverFeature
      * @return true if the features is supported or false otherwise
      */
     @Override
@@ -315,22 +318,24 @@ public class DBDatabaseDriverOracle exte
      * @see DBDatabaseDriver#getDDLScript(DBCmdType, DBObject, DBSQLScript)  
      */
     @Override
-    public boolean getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
+    public void getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
     {
         // The Object's database must be attached to this driver
         if (dbo==null || dbo.getDatabase().getDriver()!=this)
-            return error(Errors.InvalidArg, dbo, "dbo");
+            throw new InvalidArgumentException("dbo", dbo);
         // Check Type of object
         if (dbo instanceof DBDatabase)
         { // Database
             switch (type)
             {
                 case CREATE:
-                    return createDatabase((DBDatabase) dbo, script);
+                    createDatabase((DBDatabase) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBDatabase) dbo).getSchema(), "USER", script);
+                    dropObject(((DBDatabase) dbo).getSchema(), "USER", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBTable)
@@ -338,11 +343,13 @@ public class DBDatabaseDriverOracle exte
             switch (type)
             {
                 case CREATE:
-                    return createTable((DBTable) dbo, script);
+                    createTable((DBTable) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBTable) dbo).getName(), "TABLE", script);
+                    dropObject(((DBTable) dbo).getName(), "TABLE", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBView)
@@ -350,11 +357,13 @@ public class DBDatabaseDriverOracle exte
             switch (type)
             {
                 case CREATE:
-                    return createView((DBView) dbo, script);
+                    createView((DBView) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBView) dbo).getName(), "VIEW", script);
+                    dropObject(((DBView) dbo).getName(), "VIEW", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBRelation)
@@ -362,20 +371,23 @@ public class DBDatabaseDriverOracle exte
             switch (type)
             {
                 case CREATE:
-                    return createRelation((DBRelation) dbo, script);
+                    createRelation((DBRelation) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
+                    dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBTableColumn)
         { // Table Column
-            return alterTable((DBTableColumn) dbo, type, script);
+            alterTable((DBTableColumn) dbo, type, script);
+            return;
         } 
         else
-        { // an invalid argument has been supplied
-            return error(Errors.InvalidArg, dbo, "dbo");
+        { // dll generation not supported for this type
+            throw new NotSupportedException(this, "getDDLScript() for "+dbo.getClass().getName());
         }
     }
 
@@ -393,11 +405,9 @@ public class DBDatabaseDriverOracle exte
         {   // Oracle Timestamp query
             rs = executeQuery("select sysdate from dual", null, false, conn);
             return (rs.next() ? rs.getTimestamp(1) : null);
-        } catch (Exception e)
-        {
-            log.error("getUpdateTimestamp exception: " + e);
-            error(e);
-            return null;
+        } catch (SQLException e) {
+            // throw exception
+            throw new InternalSQLException(this, e);
         } finally
         { // Cleanup
             try
@@ -407,9 +417,9 @@ public class DBDatabaseDriverOracle exte
                     rs.close();
                 if (stmt != null)
                     stmt.close();
-            } catch (SQLException sqle)
-            {
-                log.error("getUpdateTimestamp close exception: " + sqle);
+            } catch (SQLException e) {
+                // throw exception
+                throw new InternalSQLException(this, e);
             }
         }
     }
@@ -419,7 +429,7 @@ public class DBDatabaseDriverOracle exte
      * 
      * @return true if the database has been created successfully
      */
-    protected boolean createDatabase(DBDatabase db, DBSQLScript script)
+    protected void createDatabase(DBDatabase db, DBSQLScript script)
     {
         // Create all Sequences
         Iterator<DBTable> seqtabs = db.getTables().iterator();
@@ -440,26 +450,26 @@ public class DBDatabaseDriverOracle exte
         Iterator<DBTable> tables = db.getTables().iterator();
         while (tables.hasNext())
         {
-            if (!createTable(tables.next(), script))
-                return false;
+            createTable(tables.next(), script);
         }
         // Create Relations
         Iterator<DBRelation> relations = db.getRelations().iterator();
         while (relations.hasNext())
         {
-            if (!createRelation(relations.next(), script))
-                return false;
+            createRelation(relations.next(), script);
         }
         // Create Views
         Iterator<DBView> views = db.getViews().iterator();
         while (views.hasNext())
         {
-            if (!createView(views.next(), script))
-                if (getErrorType()!=Errors.NotImplemented)
-                    return false;
+            try {
+                createView(views.next(), script);
+            } catch(NotImplementedException e) {
+                // View command not implemented
+                log.warn("Error creating the view {0}. This view will be ignored.");
+                continue;
+            }
         }
-        // Done
-        return true;
     }
 
     /**
@@ -467,7 +477,7 @@ public class DBDatabaseDriverOracle exte
      * 
      * @return true if the sequence has been created successfully
      */
-    protected boolean createSequence(DBDatabase db, DBTableColumn c, DBSQLScript script)
+    protected void createSequence(DBDatabase db, DBTableColumn c, DBSQLScript script)
     {
         Object defValue = c.getDefaultValue();
         String seqName = (defValue != null) ? defValue.toString() : c.toString();
@@ -480,14 +490,14 @@ public class DBDatabaseDriverOracle exte
         db.appendQualifiedName(sql, seqName, detectQuoteName(seqName));
         sql.append(" INCREMENT BY 1 START WITH 1 MINVALUE 0 NOCYCLE NOCACHE NOORDER");
         // executeDLL
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
     
     /**
      * Returns true if the table has been created successfully.
      * @return true if the table has been created successfully
      */
-    protected boolean createTable(DBTable t, DBSQLScript script)
+    protected void createTable(DBTable t, DBSQLScript script)
     {
         StringBuilder sql = new StringBuilder();
         sql.append("-- creating table ");
@@ -527,8 +537,7 @@ public class DBDatabaseDriverOracle exte
         sql.append(")");
         // Create the table
         DBDatabase db = t.getDatabase();
-        if (script.addStmt(sql) == false)
-            return false;
+        script.addStmt(sql);
         // Create other Indexes (except primary key)
         Iterator<DBIndex> indexes = t.getIndexes().iterator();
         while (indexes.hasNext())
@@ -557,8 +566,7 @@ public class DBDatabaseDriverOracle exte
             }
             sql.append(")");
             // Create Index
-            if (script.addStmt(sql) == false)
-                return false;
+            script.addStmt(sql);
         }
         // add Comments
         createComment(db, "TABLE", t, t.getComment(), script);
@@ -570,8 +578,6 @@ public class DBDatabaseDriverOracle exte
             if (com != null)
                 createComment(db, "COLUMN", c, com, script);
         }
-        // done
-        return success();
     }
     
     /**
@@ -652,7 +658,7 @@ public class DBDatabaseDriverOracle exte
                 sql.append("CHAR(36)");
                 break;
             case UNKNOWN:
-                log.error("Cannot append column of Data-Type 'UNKNOWN'");
+                log.warn("Cannot append column of Data-Type 'UNKNOWN'");
                 return false;
         }
         // Default Value
@@ -671,7 +677,7 @@ public class DBDatabaseDriverOracle exte
      * Create a sql string for creating a relation and appends it to the supplied buffer
      * @return true if the relation has been created successfully
      */
-    protected boolean createRelation(DBRelation r, DBSQLScript script)
+    protected void createRelation(DBRelation r, DBSQLScript script)
     {
         DBTable sourceTable = (DBTable) r.getReferences()[0].getSourceColumn().getRowSet();
         DBTable targetTable = (DBTable) r.getReferences()[0].getTargetColumn().getRowSet();
@@ -709,7 +715,7 @@ public class DBDatabaseDriverOracle exte
         // done
         sql.append(")");
         // done
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
 
     /**
@@ -719,7 +725,7 @@ public class DBDatabaseDriverOracle exte
      * @param script to which to append the sql statement to
      * @return true if the statement was successfully appended to the buffer
      */
-    protected boolean alterTable(DBTableColumn col, DBCmdType type, DBSQLScript script)
+    protected void alterTable(DBTableColumn col, DBCmdType type, DBSQLScript script)
     {
         StringBuilder sql = new StringBuilder();
         sql.append("ALTER TABLE ");
@@ -740,7 +746,7 @@ public class DBDatabaseDriverOracle exte
                 break;
         }
         // done
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
     
     /**
@@ -748,17 +754,14 @@ public class DBDatabaseDriverOracle exte
      * 
      * @return true if the view has been created successfully
      */
-    protected boolean createView(DBView v, DBSQLScript script)
+    protected void createView(DBView v, DBSQLScript script)
     {
         // Create the Command
         DBCommandExpr cmd = v.createCommand();
         if (cmd==null)
         {   // Check whether Error information is available
             log.error("No command has been supplied for view " + v.getName());
-            if (v.hasError())
-                return error(v);
-            // No error information available: Use Errors.NotImplemented
-            return error(Errors.NotImplemented, v.getName() + ".createCommand");
+            throw new NotImplementedException(this, v.getName() + ".createCommand");
         }
         // Make sure there is no OrderBy
         cmd.clearOrderBy();
@@ -781,7 +784,7 @@ public class DBDatabaseDriverOracle exte
         sql.append(")\r\nAS\r\n");
         cmd.addSQL( sql, DBExpr.CTX_DEFAULT);
         // done
-        return script.addStmt(sql.toString());
+        script.addStmt(sql.toString());
     }
 
     /**
@@ -789,10 +792,10 @@ public class DBDatabaseDriverOracle exte
      * 
      * @return true if the comment has been created successfully
      */
-    protected boolean createComment(DBDatabase db, String type, DBExpr expr, String comment, DBSQLScript script)
+    protected void createComment(DBDatabase db, String type, DBExpr expr, String comment, DBSQLScript script)
     {
         if (comment==null || comment.length()==0)
-            return true;
+            return; // Nothing to do
         StringBuilder sql = new StringBuilder();
         sql.append("COMMENT ON ");
         sql.append(type);
@@ -808,7 +811,7 @@ public class DBDatabaseDriverOracle exte
         sql.append(comment);
         sql.append("'");
         // Create Index
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
     
     /**
@@ -816,17 +819,17 @@ public class DBDatabaseDriverOracle exte
      * 
      * @return true if the object has been dropped successfully
      */
-    protected boolean dropObject(String name, String objType, DBSQLScript script)
+    protected void dropObject(String name, String objType, DBSQLScript script)
     {
         if (name == null || name.length() == 0)
-            return error(Errors.InvalidArg, name, "name");
+            throw new InvalidArgumentException("name", name);
         // Create Drop Statement
         StringBuilder sql = new StringBuilder();
         sql.append("DROP ");
         sql.append(objType);
         sql.append(" ");
         appendElementName(sql, name);
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
 
     
@@ -836,12 +839,12 @@ public class DBDatabaseDriverOracle exte
      * @return true if the database definition matches the real database structure.
      */
     @Override
-    public boolean checkDatabase(DBDatabase db, String owner, Connection conn)
+    public void checkDatabase(DBDatabase db, String owner, Connection conn)
     {
         // Check Params
         if (owner==null || owner.length()==0)
-            return error(Errors.InvalidArg, owner, "owner");
-        // Datebase definition
+            throw new InvalidArgumentException("owner", owner);
+        // Database definition
         OracleSYSDatabase sysDB = new OracleSYSDatabase(this);
         // Check Columns
         DBCommand sysDBCommand = sysDB.createCommand();
@@ -852,78 +855,74 @@ public class DBDatabaseDriverOracle exte
         DBReader rd = new DBReader();
         try
         {
-            if (rd.open(sysDBCommand, conn))
+            rd.open(sysDBCommand, conn);
+            // read all
+            log.info("---------------------------------------------------------------------------------");
+            log.info("checkDatabase start: " + db.getClass().getName());
+            String skipTable = "";
+            while (rd.moveNext())
             {
-                log.info("---------------------------------------------------------------------------------");
-                log.info("checkDatabase start: " + db.getClass().getName());
-                String skipTable = "";
-                while (rd.moveNext())
-                {
-                    String tableName = rd.getString(sysDB.CI.C_TABLE_NAME);
-
-                    // if a table wasn't found before, skip it
-                    if (tableName.equals(skipTable))
-                        continue;
+                String tableName = rd.getString(sysDB.CI.C_TABLE_NAME);
 
-                    // check if the found table exists in the DBDatabase object
-                    String columnName = rd.getString(sysDB.CI.C_COLUMN_NAME);
-                    DBTable dbTable = db.getTable(tableName);
-                    DBView  dbView  = db.getView(tableName);
-                    
-                    String dataType = rd.getString(sysDB.CI.C_DATA_TYPE);
-                    int charLength = rd.getInt(sysDB.CI.C_CHAR_LENGTH);
-                    int dataLength = rd.getInt(sysDB.CI.C_DATA_LENGTH);
-                    int dataPrecision = rd.getInt(sysDB.CI.C_DATA_PRECISION);
-                    int dataScale = rd.getInt(sysDB.CI.C_DATA_SCALE);
-                    String nullable = rd.getString(sysDB.CI.C_NULLABLE);
-                    
-                    dataDictionnary.fillDataDictionnary(tableName, columnName, dataType, 
-                                                        charLength, dataLength, dataPrecision, dataScale, nullable);
+                // if a table wasn't found before, skip it
+                if (tableName.equals(skipTable))
+                    continue;
+
+                // check if the found table exists in the DBDatabase object
+                String columnName = rd.getString(sysDB.CI.C_COLUMN_NAME);
+                DBTable dbTable = db.getTable(tableName);
+                DBView  dbView  = db.getView(tableName);
+                
+                String dataType = rd.getString(sysDB.CI.C_DATA_TYPE);
+                int charLength = rd.getInt(sysDB.CI.C_CHAR_LENGTH);
+                int dataLength = rd.getInt(sysDB.CI.C_DATA_LENGTH);
+                int dataPrecision = rd.getInt(sysDB.CI.C_DATA_PRECISION);
+                int dataScale = rd.getInt(sysDB.CI.C_DATA_SCALE);
+                String nullable = rd.getString(sysDB.CI.C_NULLABLE);
+                
+                dataDictionnary.fillDataDictionnary(tableName, columnName, dataType, 
+                                                    charLength, dataLength, dataPrecision, dataScale, nullable);
+                
+                if (dbTable != null)
+                {
                     
-                    if (dbTable != null)
-                    {
-                        
-                        // check if the found column exists in the found DBTable
-                        DBColumn col = dbTable.getColumn(columnName);
-                        if (col == null)
-                        {
-                            log.warn("COLUMN NOT FOUND IN " + db.getClass().getName() + "\t: [" + tableName + "]["
-                                           + columnName + "][" + dataType + "][" + dataLength + "]");
-                            continue;
-                        }
-                        /*
-                        else
-                        {   // check the DBTableColumn definition
-                            int length = (charLength>0) ? charLength : dataLength;
-                            dataDictionnary.checkColumnDefinition(col, dataType, length, dataPrecision, dataScale, nullable.equals("N"));
-                        }
-                        */
-                    } 
-                    else if (dbView!=null)
-                    {
-                        log.debug("Column check for view " + tableName + " not yet implemented.");
-                    } 
-                    else
+                    // check if the found column exists in the found DBTable
+                    DBColumn col = dbTable.getColumn(columnName);
+                    if (col == null)
                     {
-                        log.debug("TABLE OR VIEW NOT FOUND IN " + db.getClass().getName() + "\t: [" + tableName + "]");
-                        // skip this table
-                        skipTable = tableName;
+                        log.warn("COLUMN NOT FOUND IN " + db.getClass().getName() + "\t: [" + tableName + "]["
+                                       + columnName + "][" + dataType + "][" + dataLength + "]");
                         continue;
                     }
+                    /*
+                    else
+                    {   // check the DBTableColumn definition
+                        int length = (charLength>0) ? charLength : dataLength;
+                        dataDictionnary.checkColumnDefinition(col, dataType, length, dataPrecision, dataScale, nullable.equals("N"));
+                    }
+                    */
+                } 
+                else if (dbView!=null)
+                {
+                    log.debug("Column check for view " + tableName + " not yet implemented.");
+                } 
+                else
+                {
+                    log.debug("TABLE OR VIEW NOT FOUND IN " + db.getClass().getName() + "\t: [" + tableName + "]");
+                    // skip this table
+                    skipTable = tableName;
+                    continue;
                 }
-                // check Tables
-                dataDictionnary.checkDBTableDefinition(db.getTables());
-                // check Views
-                dataDictionnary.checkDBViewDefinition (db.getViews()); 
-            }
-            else {
-                return error(Errors.NotAuthorized);
             }
+            // check Tables
+            dataDictionnary.checkDBTableDefinition(db.getTables());
+            // check Views
+            dataDictionnary.checkDBViewDefinition (db.getViews());
+            // done
             log.info("checkDatabase end: " + db.getClass().getName());
             log.info("---------------------------------------------------------------------------------");
-            return success();
-        } finally
-        {
+        } finally {
+            // close
             rd.close();
         }
     }

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java?rev=1158339&r1=1158338&r2=1158339&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java Tue Aug 16 15:56:41 2011
@@ -23,7 +23,6 @@ import java.sql.SQLException;
 import java.util.GregorianCalendar;
 import java.util.Iterator;
 
-import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.DBCmdType;
@@ -41,6 +40,10 @@ import org.apache.empire.db.DBSQLScript;
 import org.apache.empire.db.DBTable;
 import org.apache.empire.db.DBTableColumn;
 import org.apache.empire.db.DBView;
+import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.exceptions.InvalidArgumentException;
+import org.apache.empire.exceptions.NotImplementedException;
+import org.apache.empire.exceptions.NotSupportedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -92,17 +95,15 @@ public class DBDatabaseDriverPostgreSQL 
         }
         
         @Override
-        public boolean limitRows(int numRows)
+        public void limitRows(int numRows)
         {
             limit = numRows;
-            return success();
         }
 
         @Override
-        public boolean skipRows(int numRows)
+        public void skipRows(int numRows)
         {
             skip = numRows;
-            return success();
         }
          
         @Override
@@ -113,10 +114,9 @@ public class DBDatabaseDriverPostgreSQL 
         }
         
         @Override
-        public boolean getSelect(StringBuilder buf)
+        public void getSelect(StringBuilder buf)
         {   // call base class
-            if (super.getSelect(buf)==false)
-                return false;
+            super.getSelect(buf);
             // add limit and offset
             if (limit>=0)
             {   buf.append("\r\nLIMIT ");
@@ -127,11 +127,7 @@ public class DBDatabaseDriverPostgreSQL 
                     buf.append(String.valueOf(skip));
                 }    
             }
-            // done
-            return success();
         }
-        
-        
     }
     
     private String databaseName;
@@ -280,14 +276,14 @@ public class DBDatabaseDriverPostgreSQL 
      * @param conn a valid database connection
      * @return true if the reverse function was created successfully or false otherwise
      */
-    public boolean createReverseFunction(Connection conn)
+    public void createReverseFunction(Connection conn)
     {
         try {
             log.info("Creating reverse function: " + CREATE_REVERSE_FUNCTION);
-            return (executeSQL(CREATE_REVERSE_FUNCTION, null, conn, null)>=0);
+            executeSQL(CREATE_REVERSE_FUNCTION, null, conn, null);
         } catch(SQLException e) {
             log.error("Unable to create reverse function!", e);
-            return error(e);
+            throw new InternalSQLException(this, e);
         }
     }
     
@@ -307,7 +303,7 @@ public class DBDatabaseDriverPostgreSQL 
 
     /**
      * Returns whether or not a particular feature is supported by this driver
-     * @param type type of requrested feature. @see DBDriverFeature
+     * @param type type of requested feature. @see DBDriverFeature
      * @return true if the features is supported or false otherwise
      */
     @Override
@@ -444,22 +440,24 @@ public class DBDatabaseDriverPostgreSQL 
      * @see DBDatabaseDriver#getDDLScript(DBCmdType, DBObject, DBSQLScript)  
      */
     @Override
-    public boolean getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
+    public void getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
     {
         // The Object's database must be attached to this driver
         if (dbo==null || dbo.getDatabase().getDriver()!=this)
-            return error(Errors.InvalidArg, dbo, "dbo");
+            throw new InvalidArgumentException("dbo", dbo);
         // Check Type of object
         if (dbo instanceof DBDatabase)
         { // Database
             switch (type)
             {
                 case CREATE:
-                    return createDatabase((DBDatabase) dbo, script);
+                    createDatabase((DBDatabase) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBDatabase) dbo).getSchema(), "DATABASE", script);
+                    dropObject(((DBDatabase) dbo).getSchema(), "DATABASE", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript."+dbo.getClass().getName()+"."+String.valueOf(type));
+                    throw new NotImplementedException(this, "getDDLScript."+dbo.getClass().getName()+"."+String.valueOf(type));
             }
         } 
         else if (dbo instanceof DBTable)
@@ -467,11 +465,13 @@ public class DBDatabaseDriverPostgreSQL 
             switch (type)
             {
                 case CREATE:
-                    return createTable((DBTable) dbo, script);
+                    createTable((DBTable) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBTable) dbo).getName(), "TABLE", script);
+                    dropObject(((DBTable) dbo).getName(), "TABLE", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBView)
@@ -479,11 +479,13 @@ public class DBDatabaseDriverPostgreSQL 
             switch (type)
             {
                 case CREATE:
-                    return createView((DBView) dbo, script);
+                    createView((DBView) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBView) dbo).getName(), "VIEW", script);
+                    dropObject(((DBView) dbo).getName(), "VIEW", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBRelation)
@@ -491,20 +493,23 @@ public class DBDatabaseDriverPostgreSQL 
             switch (type)
             {
                 case CREATE:
-                    return createRelation((DBRelation) dbo, script);
+                    createRelation((DBRelation) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
+                    dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBTableColumn)
         { // Table Column
-            return alterTable((DBTableColumn) dbo, type, script);
+            alterTable((DBTableColumn) dbo, type, script);
+            return;
         } 
         else
-        { // an invalid argument has been supplied
-            return error(Errors.InvalidArg, dbo, "dbo");
+        { // dll generation not supported for this type
+            throw new NotSupportedException(this, "getDDLScript() for "+dbo.getClass().getName());
         }
     }
 
@@ -546,22 +551,19 @@ public class DBDatabaseDriverPostgreSQL 
         Iterator<DBTable> tables = db.getTables().iterator();
         while (tables.hasNext())
         {
-            if (!createTable(tables.next(), script))
-                return false;
+            createTable(tables.next(), script);
         }
         // Create Relations
         Iterator<DBRelation> relations = db.getRelations().iterator();
         while (relations.hasNext())
         {
-            if (!createRelation(relations.next(), script))
-                return false;
+            createRelation(relations.next(), script);
         }
         // Create Views
         Iterator<DBView> views = db.getViews().iterator();
         while (views.hasNext())
         {
-            if (!createView(views.next(), script))
-                return false;
+            createView(views.next(), script);
         }
         // Done
         return true;
@@ -577,7 +579,7 @@ public class DBDatabaseDriverPostgreSQL 
      * 
      * @return true if the sequence has been created successfully
      */
-    protected boolean createSequence(DBDatabase db, DBTableColumn c, DBSQLScript script)
+    protected void createSequence(DBDatabase db, DBTableColumn c, DBSQLScript script)
     {
     	String seqName = createSequenceName(c);
         // createSQL
@@ -594,7 +596,7 @@ public class DBDatabaseDriverPostgreSQL 
         
         sql.append(" INCREMENT BY 1 START WITH 1 MINVALUE 0");
         // executeDLL
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
     
     /**
@@ -602,7 +604,7 @@ public class DBDatabaseDriverPostgreSQL 
      * 
      * @return true if the table has been created successfully
      */
-    protected boolean createTable(DBTable t, DBSQLScript script)
+    protected void createTable(DBTable t, DBSQLScript script)
     {
         StringBuilder sql = new StringBuilder();
         sql.append("-- creating table ");
@@ -647,8 +649,7 @@ public class DBDatabaseDriverPostgreSQL 
             sql.append("'");
         }
         // Create the table
-        if (script.addStmt(sql) == false)
-            return false;
+        script.addStmt(sql);
         // Create other Indexes (except primary key)
         Iterator<DBIndex> indexes = t.getIndexes().iterator();
         while (indexes.hasNext())
@@ -676,11 +677,8 @@ public class DBDatabaseDriverPostgreSQL 
             }
             sql.append(")");
             // Create Index
-            if (script.addStmt(sql) == false)
-                return false;
+            script.addStmt(sql);
         }
-        // done
-        return success();
     }
     
     /**
@@ -790,8 +788,8 @@ public class DBDatabaseDriverPostgreSQL 
                 sql.append("CHAR(36)");
                 break;
             case UNKNOWN:
-                 //log.error("Cannot append column of Data-Type 'UNKNOWN'");
-                 return false;
+                log.warn("Cannot append column of Data-Type 'UNKNOWN'");
+                return false;
         }
         // Default Value
         if (isDDLColumnDefaults() && !c.isAutoGenerated() && c.getDefaultValue()!=null)
@@ -810,7 +808,7 @@ public class DBDatabaseDriverPostgreSQL 
      * 
      * @return true if the relation has been created successfully
      */
-    protected boolean createRelation(DBRelation r, DBSQLScript script)
+    protected void createRelation(DBRelation r, DBSQLScript script)
     {
         DBTable sourceTable = (DBTable) r.getReferences()[0].getSourceColumn().getRowSet();
         DBTable targetTable = (DBTable) r.getReferences()[0].getTargetColumn().getRowSet();
@@ -847,10 +845,7 @@ public class DBDatabaseDriverPostgreSQL 
         }
         // done
         sql.append(")");
-        if (script.addStmt(sql) == false)
-            return false;
-        // done
-        return success();
+        script.addStmt(sql);
     }
     
     /**
@@ -860,7 +855,7 @@ public class DBDatabaseDriverPostgreSQL 
      * @param script to which to append the sql statement to
      * @return true if the statement was successfully appended to the buffer
      */
-    protected boolean alterTable(DBTableColumn col, DBCmdType type, DBSQLScript script)
+    protected void alterTable(DBTableColumn col, DBCmdType type, DBSQLScript script)
     {
         StringBuilder sql = new StringBuilder();
         sql.append("ALTER TABLE ");
@@ -881,7 +876,7 @@ public class DBDatabaseDriverPostgreSQL 
                 break;
         }
         // done
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
     
     
@@ -891,17 +886,14 @@ public class DBDatabaseDriverPostgreSQL 
      * 
      * @return true if the view has been created successfully
      */
-    protected boolean createView(DBView v, DBSQLScript script)
+    protected void createView(DBView v, DBSQLScript script)
     {
         // Create the Command
         DBCommandExpr cmd = v.createCommand();
         if (cmd==null)
         {   // Check whether Error information is available
             log.error("No command has been supplied for view " + v.getName());
-            if (v.hasError())
-                return error(v);
-            // No error information available: Use Errors.NotImplemented
-            return error(Errors.NotImplemented, v.getName() + ".createCommand");
+            throw new NotImplementedException(this, v.getName() + ".createCommand");
         }
         // Make sure there is no OrderBy
         cmd.clearOrderBy();
@@ -924,7 +916,7 @@ public class DBDatabaseDriverPostgreSQL 
         sql.append(")\r\nAS\r\n");
         cmd.addSQL( sql, DBExpr.CTX_DEFAULT);
         // done
-        return script.addStmt(sql.toString());
+        script.addStmt(sql.toString());
     }
     
     /**
@@ -932,17 +924,17 @@ public class DBDatabaseDriverPostgreSQL 
      * 
      * @return true if the object has been dropped successfully
      */
-    protected boolean dropObject(String name, String objType, DBSQLScript script)
+    protected void dropObject(String name, String objType, DBSQLScript script)
     {
         if (name == null || name.length() == 0)
-            return error(Errors.InvalidArg, name, "name");
+            throw new InvalidArgumentException("name", name);
         // Create Drop Statement
         StringBuilder sql = new StringBuilder();
         sql.append("DROP ");
         sql.append(objType);
         sql.append(" ");
         appendElementName(sql, name);
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
     
 }

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java?rev=1158339&r1=1158338&r2=1158339&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java Tue Aug 16 15:56:41 2011
@@ -23,7 +23,6 @@ import java.sql.SQLException;
 import java.util.GregorianCalendar;
 import java.util.Iterator;
 
-import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.DataType;
@@ -42,6 +41,11 @@ import org.apache.empire.db.DBSQLScript;
 import org.apache.empire.db.DBTable;
 import org.apache.empire.db.DBTableColumn;
 import org.apache.empire.db.DBView;
+import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.exceptions.InvalidArgumentException;
+import org.apache.empire.exceptions.NotImplementedException;
+import org.apache.empire.exceptions.NotSupportedException;
+import org.apache.empire.exceptions.InvalidPropertyException;
 
 
 /**
@@ -68,10 +72,9 @@ public class DBDatabaseDriverMSSQL exten
     	}
         
         @Override
-        public boolean limitRows(int numRows)
+        public void limitRows(int numRows)
         {
             limit = numRows;
-            return success();
         }
          
         @Override
@@ -104,7 +107,7 @@ public class DBDatabaseDriverMSSQL exten
     private String objectOwner = "dbo";
     private String sequenceTableName = "Sequences";
     // Sequence treatment
-    // When set to 'false' (default) MySQL's autoincrement feature is used.
+    // When set to 'false' (default) MySQL's auto-increment feature is used.
     private boolean useSequenceTable = false;
     
     /**
@@ -175,7 +178,7 @@ public class DBDatabaseDriverMSSQL exten
 
     /** {@inheritDoc} */
     @Override
-    public boolean attachDatabase(DBDatabase db, Connection conn)
+    public void attachDatabase(DBDatabase db, Connection conn)
     {
         // Prepare
         try
@@ -194,11 +197,11 @@ public class DBDatabaseDriverMSSQL exten
                 db.setSchema(schema + "." + objectOwner);
             }
             // call Base implementation
-            return super.attachDatabase(db, conn);
+            super.attachDatabase(db, conn);
             
-        } catch (SQLException e)
-        {
-            return error(e);
+        } catch (SQLException e) {
+            // throw exception
+            throw new InternalSQLException(this, e);
         }
     }
 
@@ -377,22 +380,24 @@ public class DBDatabaseDriverMSSQL exten
      * @see DBDatabaseDriver#getDDLScript(DBCmdType, DBObject, DBSQLScript)  
      */
     @Override
-    public boolean getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
+    public void getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
     {
         // The Object's database must be attached to this driver
         if (dbo==null || dbo.getDatabase().getDriver()!=this)
-            return error(Errors.InvalidArg, dbo, "dbo");
+            throw new InvalidArgumentException("dbo", dbo);
         // Check Type of object
         if (dbo instanceof DBDatabase)
         { // Database
             switch (type)
             {
                 case CREATE:
-                    return createDatabase((DBDatabase) dbo, script, true);
+                    createDatabase((DBDatabase) dbo, script, true);
+                    return;
                 case DROP:
-                    return dropObject(((DBDatabase) dbo).getSchema(), "DATABASE", script);
+                    dropObject(((DBDatabase) dbo).getSchema(), "DATABASE", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBTable)
@@ -400,11 +405,13 @@ public class DBDatabaseDriverMSSQL exten
             switch (type)
             {
                 case CREATE:
-                    return createTable((DBTable) dbo, script);
+                    createTable((DBTable) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBTable) dbo).getName(), "TABLE", script);
+                    dropObject(((DBTable) dbo).getName(), "TABLE", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBView)
@@ -412,11 +419,13 @@ public class DBDatabaseDriverMSSQL exten
             switch (type)
             {
                 case CREATE:
-                    return createView((DBView) dbo, script);
+                    createView((DBView) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBView) dbo).getName(), "VIEW", script);
+                    dropObject(((DBView) dbo).getName(), "VIEW", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBRelation)
@@ -424,20 +433,23 @@ public class DBDatabaseDriverMSSQL exten
             switch (type)
             {
                 case CREATE:
-                    return createRelation((DBRelation) dbo, script);
+                    createRelation((DBRelation) dbo, script);
+                    return;
                 case DROP:
-                    return dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
+                    dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
+                    return;
                 default:
-                    return error(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
             }
         } 
         else if (dbo instanceof DBTableColumn)
         { // Table Column
-            return alterTable((DBTableColumn) dbo, type, script);
+            alterTable((DBTableColumn) dbo, type, script);
+            return;
         } 
         else
-        { // an invalid argument has been supplied
-            return error(Errors.InvalidArg, dbo, "dbo");
+        { // dll generation not supported for this type
+            throw new NotSupportedException(this, "getDDLScript() for "+dbo.getClass().getName());
         }
     }
 
@@ -463,7 +475,7 @@ public class DBDatabaseDriverMSSQL exten
         if (createSchema)
         {   // check database Name
             if (StringUtils.isEmpty(databaseName))
-                return error(Errors.InvalidProperty, "databaseName");
+                throw new InvalidPropertyException("databaseName", databaseName);
             // Create Database
             script.addStmt("USE master");
             script.addStmt("IF NOT EXISTS(SELECT * FROM sys.databases WHERE name = '" + databaseName + "') CREATE DATABASE " + databaseName);
@@ -477,22 +489,19 @@ public class DBDatabaseDriverMSSQL exten
         Iterator<DBTable> tables = db.getTables().iterator();
         while (tables.hasNext())
         {
-            if (!createTable(tables.next(), script))
-                return false;
+            createTable(tables.next(), script);
         }
         // Create Relations
         Iterator<DBRelation> relations = db.getRelations().iterator();
         while (relations.hasNext())
         {
-            if (!createRelation(relations.next(), script))
-                return false;
+            createRelation(relations.next(), script);
         }
         // Create Views
         Iterator<DBView> views = db.getViews().iterator();
         while (views.hasNext())
         {
-            if (!createView(views.next(), script))
-                return false;
+            createView(views.next(), script);
         }
         // Done
         return true;
@@ -503,7 +512,7 @@ public class DBDatabaseDriverMSSQL exten
      * 
      * @return true if the table has been created successfully
      */
-    protected boolean createTable(DBTable t, DBSQLScript script)
+    protected void createTable(DBTable t, DBSQLScript script)
     {
         StringBuilder sql = new StringBuilder();
         sql.append("-- creating table ");
@@ -542,8 +551,7 @@ public class DBDatabaseDriverMSSQL exten
         }
         sql.append(")");
         // Create the table
-        if (script.addStmt(sql) == false)
-            return false;
+        script.addStmt(sql);
         // Create other Indexes (except primary key)
         Iterator<DBIndex> indexes = t.getIndexes().iterator();
         while (indexes.hasNext())
@@ -572,11 +580,8 @@ public class DBDatabaseDriverMSSQL exten
             }
             sql.append(")");
             // Create Index
-            if (script.addStmt(sql) == false)
-                return false;
+            script.addStmt(sql);
         }
-        // done
-        return success();
     }
     
     /**
@@ -684,7 +689,7 @@ public class DBDatabaseDriverMSSQL exten
      * 
      * @return true if the relation has been created successfully
      */
-    protected boolean createRelation(DBRelation r, DBSQLScript script)
+    protected void createRelation(DBRelation r, DBSQLScript script)
     {
         DBTable sourceTable = (DBTable) r.getReferences()[0].getSourceColumn().getRowSet();
         DBTable targetTable = (DBTable) r.getReferences()[0].getTargetColumn().getRowSet();
@@ -721,10 +726,7 @@ public class DBDatabaseDriverMSSQL exten
         }
         // done
         sql.append(")");
-        if (script.addStmt(sql) == false)
-            return false;
-        // done
-        return success();
+        script.addStmt(sql);
     }
 
     /**
@@ -734,7 +736,7 @@ public class DBDatabaseDriverMSSQL exten
      * @param script to which to append the sql statement to
      * @return true if the statement was successfully appended to the buffer
      */
-    protected boolean alterTable(DBTableColumn col, DBCmdType type, DBSQLScript script)
+    protected void alterTable(DBTableColumn col, DBCmdType type, DBSQLScript script)
     {
         StringBuilder sql = new StringBuilder();
         sql.append("ALTER TABLE ");
@@ -755,7 +757,7 @@ public class DBDatabaseDriverMSSQL exten
                 break;
         }
         // done
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
 
     /**
@@ -763,17 +765,14 @@ public class DBDatabaseDriverMSSQL exten
      * 
      * @return true if the view has been created successfully
      */
-    protected boolean createView(DBView v, DBSQLScript script)
+    protected void createView(DBView v, DBSQLScript script)
     {
         // Create the Command
         DBCommandExpr cmd = v.createCommand();
         if (cmd==null)
         {   // Check whether Error information is available
             log.error("No command has been supplied for view " + v.getName());
-            if (v.hasError())
-                return error(v);
-            // No error information available: Use Errors.NotImplemented
-            return error(Errors.NotImplemented, v.getName() + ".createCommand");
+            throw new NotImplementedException(this, v.getName() + ".createCommand");
         }
         // Make sure there is no OrderBy
         cmd.clearOrderBy();
@@ -796,7 +795,7 @@ public class DBDatabaseDriverMSSQL exten
         sql.append(")\r\nAS\r\n");
         cmd.addSQL( sql, DBExpr.CTX_DEFAULT);
         // done
-        return script.addStmt(sql.toString());
+        script.addStmt(sql.toString());
     }
         
     /**
@@ -804,17 +803,17 @@ public class DBDatabaseDriverMSSQL exten
      * 
      * @return true if the object has been dropped successfully
      */
-    protected boolean dropObject(String name, String objType, DBSQLScript script)
+    protected void dropObject(String name, String objType, DBSQLScript script)
     {
         if (name == null || name.length() == 0)
-            return error(Errors.InvalidArg, name, "name");
+            throw new InvalidArgumentException("name", name);
         // Create Drop Statement
         StringBuilder sql = new StringBuilder();
         sql.append("DROP ");
         sql.append(objType);
         sql.append(" ");
         appendElementName(sql, name);
-        return script.addStmt(sql);
+        script.addStmt(sql);
     }
 
 }

Propchange: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/exceptions/
------------------------------------------------------------------------------
    eol-style = native

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java?rev=1158339&r1=1158338&r2=1158339&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java Tue Aug 16 15:56:41 2011
@@ -30,10 +30,14 @@ import javax.xml.parsers.DocumentBuilder
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.commons.beanutils.BeanUtils;
-import org.apache.empire.commons.ErrorObject;
-import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.StringUtils;
+import org.apache.empire.exceptions.FileParseException;
+import org.apache.empire.exceptions.FileReadException;
+import org.apache.empire.exceptions.InternalException;
+import org.apache.empire.exceptions.InvalidArgumentException;
+import org.apache.empire.exceptions.ItemNotFoundException;
+import org.apache.empire.exceptions.ObjectNotValidException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -51,7 +55,7 @@ import org.xml.sax.SAXException;
  * </PRE>
  *
  */
-public class XMLConfiguration extends ErrorObject
+public class XMLConfiguration
 {
     private static final Logger log = LoggerFactory.getLogger(XMLConfiguration.class);
 
@@ -65,13 +69,10 @@ public class XMLConfiguration extends Er
      * 
      * @return true on success
      */
-    public boolean init(String filename, boolean fromResource)
+    public void init(String filename, boolean fromResource)
     {
         // Read the properties file
-        if (readConfiguration(filename, fromResource) == false)
-            return false;
-        // Done
-        return success();
+        readConfiguration(filename, fromResource);
     }
     
     /**
@@ -86,7 +87,7 @@ public class XMLConfiguration extends Er
     /**
      * Reads the configuration file and parses the XML Configuration.
      */
-    protected boolean readConfiguration(String fileName, boolean fromResource)
+    protected void readConfiguration(String fileName, boolean fromResource)
     {
         FileReader reader = null;
         InputStream inputStream = null;
@@ -110,23 +111,22 @@ public class XMLConfiguration extends Er
             }
             // Get Root Element
             configRootNode = doc.getDocumentElement();
-            return success();
         } catch (FileNotFoundException e)
         {
             log.error("Configuration file {} not found!", fileName, e);
-            return error(Errors.FileNotFound, fileName);
+            throw new FileReadException(fileName, e);
         } catch (IOException e)
         {
             log.error("Error reading configuration file {}", fileName, e);
-            return error(Errors.FileReadError, fileName);
+            throw new FileReadException(fileName, e);
         } catch (SAXException e)
         {
             log.error("Invalid XML in configuration file {}", fileName, e);
-            return error(e);
+            throw new FileParseException(fileName, e);
         } catch (ParserConfigurationException e)
         {
             log.error("ParserConfigurationException: {}", e.getMessage(), e);
-            return error(e);
+            throw new InternalException(e);
         } finally
         { 
         	close(reader);
@@ -140,30 +140,30 @@ public class XMLConfiguration extends Er
      * @param propertiesNodeName the name of the properties node below the root element
      * @return true of successful or false otherwise
      */
-    public boolean readProperties(Object bean, String... propertiesNodeNames)
+    public void readProperties(Object bean, String... propertiesNodeNames)
     {
         // Check state
         if (configRootNode == null)
-            return error(Errors.ObjectNotValid, getClass().getName());
+            throw new ObjectNotValidException(this);
         // Check arguments
         if (bean == null)
-            return error(Errors.InvalidArg, null, "bean");
+            throw new InvalidArgumentException("bean", bean);
         
         Element propertiesNode = configRootNode;  
         for(String nodeName : propertiesNodeNames)
         {
             if (StringUtils.isEmpty(nodeName))
-                return error(Errors.InvalidArg, null, "propertiesNodeNames");
+                throw new InvalidArgumentException("propertiesNodeNames", null);
             // Get configuration node
             propertiesNode = XMLUtil.findFirstChild(propertiesNode, nodeName);
             if (propertiesNode == null)
             { // Configuration
                 log.error("Property-Node {} has not been found.", nodeName);
-                return error(Errors.ItemNotFound, nodeName);
+                throw new ItemNotFoundException(nodeName);
             }
         }
         // read the properties
-        return readProperties(bean, propertiesNode);
+        readProperties(bean, propertiesNode);
     }
 
     /**
@@ -172,13 +172,13 @@ public class XMLConfiguration extends Er
      * @param propertiesNode the properties node
      * @return true of successful or false otherwise
      */
-    public boolean readProperties(Object bean, Element propertiesNode)
+    public void readProperties(Object bean, Element propertiesNode)
     {
         // Check arguments
         if (propertiesNode == null)
-            return error(Errors.InvalidArg, null, "propertiesNode");
+            throw new InvalidArgumentException("propertiesNode", propertiesNode);
         if (bean == null)
-            return error(Errors.InvalidArg, null, "bean");
+            throw new InvalidArgumentException("bean", bean);
         // apply configuration
         log.info("reading bean properties from node: {}", propertiesNode.getNodeName());
         NodeList nodeList = propertiesNode.getChildNodes();
@@ -190,8 +190,6 @@ public class XMLConfiguration extends Er
             // Get the Text and set the Property
             setPropertyValue(bean, item);
         }
-        // done
-        return success();
     }
     
     protected void setPropertyValue(Object bean, Node item)

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLWriter.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLWriter.java?rev=1158339&r1=1158338&r2=1158339&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLWriter.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLWriter.java Tue Aug 16 15:56:41 2011
@@ -35,7 +35,6 @@ import javax.xml.transform.stream.Stream
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.empire.commons.ErrorObject;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
@@ -49,7 +48,7 @@ import org.w3c.dom.NodeList;
  * 
  *
  */
-public class XMLWriter extends ErrorObject
+public class XMLWriter
 {
     // Logger
     protected static final Logger    log                  = LoggerFactory.getLogger(XMLWriter.class);

Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/ErrorsTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/ErrorsTest.java?rev=1158339&r1=1158338&r2=1158339&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/ErrorsTest.java (original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/ErrorsTest.java Tue Aug 16 15:56:41 2011
@@ -18,77 +18,92 @@
  */
 package org.apache.empire.commons;
 
-import org.junit.Test;
-
 import static org.junit.Assert.assertEquals;
 
+import org.apache.empire.exceptions.EmpireException;
+import org.apache.empire.exceptions.InternalException;
+import org.apache.empire.exceptions.InvalidArgumentException;
+import org.junit.Before;
+import org.junit.Test;
+
 public class ErrorsTest
 {
+    private static final String ROOT_EXCEPTION_MSG = "This is the root exception message!"; 
 
-	
+    private Throwable cause;
+
+    @Before
+    public void setupException()
+    {
+        cause = new RuntimeException(ROOT_EXCEPTION_MSG);
+    }
+    
+    @Test
+    public void testInvalidArgumentException()
+    {
+        try {
+            // Test InvalidArg
+            throw new InvalidArgumentException("testparam", "testvalue");
+            
+        } catch (EmpireException e) {
+            
+            assertEquals(e.getMessage(), "Invalid Argument testvalue for parameter testparam.");
+        }
+    }    
+    
+    @Test
+    public void testInternalException()
+    {
+        try {
+            // Test InvalidArg
+            throw new InternalException(cause);
+            
+        } catch (EmpireException e) {
+            
+            assertEquals(e.getErrorParams()[0], "RuntimeException");
+            assertEquals(e.getErrorParams()[1], ROOT_EXCEPTION_MSG);
+        }
+    }    
+
+    /*
+   
+    private static final String NATIVE_ERROR_MSG = "This is the native error message!"; 
+    
 	@Test
 	public void testGetErrorMessage()
 	{
-		
-		ErrorInfo info = new DummyErrorInfo(true, Errors.InvalidArg, new Object[]{"test", "testparam"});
-		assertEquals("Invalid Argument test for parameter testparam.", Errors.getErrorMessage(info));
-		
-		// TODO should we fail in this case?
-		// TODO find a way to force the correct number of params at compiletime
-		info = new DummyErrorInfo(true, Errors.InvalidArg, new Object[]{"test"});
-		assertEquals("Invalid Argument test for parameter {1}.", Errors.getErrorMessage(info));
-	
-		assertEquals("", Errors.getErrorMessage(null));		
-		
-		info = new DummyErrorInfo(false, Errors.Internal, null);
-		assertEquals("", Errors.getErrorMessage(info));
-		
-		info = new DummyErrorInfo(true, null, null);
-		assertEquals("", Errors.getErrorMessage(info));
-		
-		info = new DummyErrorInfo(true, Errors.None, null);
-		assertEquals("", Errors.getErrorMessage(info));
+        Throwable cause = new RuntimeException(ROOT_EXCEPTION_MSG);
+        
+	    try {
+	        // Test InvalidArg
+	        throw new EmpireException(Errors.InvalidArg, "test", "testparam");
+	        
+	    } catch (EmpireException e) {
+	        
+            assertEquals(e.getErrorType(), Errors.InvalidArg);
+	        assertEquals(e.getMessage(), "Invalid Argument 'test' for parameter 'testparam'.");
+	    }
+
+        try {
+            // Test Throwable wrapper
+            throw new EmpireException(cause);
+            
+        } catch (EmpireException e) {
+
+            assertEquals(e.getErrorParams()[0], "RuntimeException");
+            assertEquals(e.getErrorParams()[1], ROOT_EXCEPTION_MSG);
+        }
+
+        try {
+            // Test SQLException
+            throw new EmpireException(DBErrors.SQLException, new Object[] { NATIVE_ERROR_MSG }, cause);
+            
+        } catch (EmpireException e) {
+
+            assertEquals(e.getErrorParams()[0], NATIVE_ERROR_MSG);
+            
+        }
 	}
-	
-	private final class DummyErrorInfo implements ErrorInfo
-	{
-		private final boolean hasErrror;
-		private final ErrorType type;
-		private final Object[] params;
-		
-		public DummyErrorInfo(final boolean hasError, final ErrorType type, final Object[] params)
-		{
-			this.hasErrror = hasError;
-			this.type = type;
-			this.params = params;
-		}
-		
-		public Object[] getErrorParams()
-		{
-			return params;
-		}
-
-		public String getErrorSource()
-		{
-			return "JUnit";
-		}
-
-		public ErrorType getErrorType()
-		{
-			return type;
-		}
-
-		public boolean hasError()
-		{
-			return hasErrror;
-		}
-
-    public String getErrorMessage()
-    {
-      return null;
-    }
-  }
-
-	
+	*/
 
 }

Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java?rev=1158339&r1=1158338&r2=1158339&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java (original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/commons/StringUtilsTest.java Tue Aug 16 15:56:41 2011
@@ -18,7 +18,9 @@
  */
 package org.apache.empire.commons;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 
@@ -61,7 +63,7 @@ public class StringUtilsTest
 	@Test
 	public void testValueOfObject()
 	{
-		assertEquals("",StringUtils.valueOf(null));
+		assertEquals("null",StringUtils.valueOf((Object)null));
 		assertEquals("",StringUtils.valueOf(""));
 		assertEquals("123",StringUtils.valueOf(Long.valueOf("123")));
 	}
@@ -69,8 +71,8 @@ public class StringUtilsTest
 	@Test
 	public void testValueOfObjectArray()
 	{
-		assertEquals("",StringUtils.valueOf(null));
-		assertEquals("",StringUtils.valueOf(new Object[]{}));
+		assertEquals("null",StringUtils.valueOf((Object[])null));
+		assertEquals("null",StringUtils.valueOf(new Object[]{}));
 		assertEquals("123/12.3",StringUtils.valueOf(new Number[]{Integer.valueOf("123"), Double.valueOf("12.3")}));
 	}
 

Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java?rev=1158339&r1=1158338&r2=1158339&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java (original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java Tue Aug 16 15:56:41 2011
@@ -85,9 +85,9 @@ public class DBCommandTest
         }
 
         @Override
-        public boolean checkValue(Object value)
+        public void checkValue(Object value)
         {
-            return false;
+            return;
         }
 
         @Override

Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/IntegerTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/IntegerTest.java?rev=1158339&r1=1158338&r2=1158339&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/IntegerTest.java (original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/IntegerTest.java Tue Aug 16 15:56:41 2011
@@ -26,7 +26,6 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.empire.commons.ErrorObject;
 import org.apache.empire.data.DataMode;
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.derby.DBDatabaseDriverDerby;
@@ -36,7 +35,6 @@ import org.apache.empire.db.mysql.DBData
 import org.apache.empire.db.oracle.DBDatabaseDriverOracle;
 import org.apache.empire.db.postgresql.DBDatabaseDriverPostgreSQL;
 import org.apache.empire.db.sqlserver.DBDatabaseDriverMSSQL;
-import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -49,11 +47,6 @@ import org.slf4j.LoggerFactory;
 public class IntegerTest {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(IntegerTest.class);
-
-    @Before
-    public void enableExceptions(){
-        ErrorObject.setExceptionsEnabled(true);
-    }
     
     @Test
     public void testHsqldb() {

Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java?rev=1158339&r1=1158338&r2=1158339&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java (original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java Tue Aug 16 15:56:41 2011
@@ -26,7 +26,6 @@ import java.sql.Connection;
 
 import org.apache.empire.DBResource;
 import org.apache.empire.DBResource.DB;
-import org.apache.empire.commons.ErrorObject;
 import org.apache.empire.db.DBCommand.DBCommandParam;
 import org.junit.Rule;
 import org.junit.Test;
@@ -40,8 +39,6 @@ public class PreparedStatementTest{
     @Test
     public void testPreparedStatement()
     {
-        ErrorObject.setExceptionsEnabled(true);
-        
         Connection conn = dbResource.getConnection();
         
         DBDatabaseDriver driver = dbResource.newDriver();

Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java?rev=1158339&r1=1158338&r2=1158339&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java (original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java Tue Aug 16 15:56:41 2011
@@ -27,7 +27,6 @@ import java.util.Date;
 
 import org.apache.empire.DBResource;
 import org.apache.empire.DBResource.DB;
-import org.apache.empire.commons.ErrorObject;
 import org.apache.empire.db.CompanyDB;
 import org.apache.empire.db.DBCmdType;
 import org.apache.empire.db.DBDatabaseDriver;
@@ -45,8 +44,6 @@ public class DBDatabaseDriverHSqlTest{
     @Test
     public void test()
     {
-        ErrorObject.setExceptionsEnabled(true);
-        
         Connection conn = dbResource.getConnection();
      
         DBDatabaseDriver driver = dbResource.newDriver();



Mime
View raw message