You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2011/07/19 18:53:41 UTC

svn commit: r1148444 [1/4] - in /incubator/empire-db/branches/EMPIREDB-99/empire-db/src: main/java/org/apache/empire/ main/java/org/apache/empire/commons/ main/java/org/apache/empire/data/ main/java/org/apache/empire/data/bean/ main/java/org/apache/emp...

Author: doebele
Date: Tue Jul 19 16:53:34 2011
New Revision: 1148444

URL: http://svn.apache.org/viewvc?rev=1148444&view=rev
Log:
basic changes (not yet complete!)

Modified:
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/EmpireException.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/commons/ErrorObject.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/Record.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/RecordData.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/bean/BeanRecordProxy.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBColumn.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBErrors.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBObject.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBQuery.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBReader.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBTable.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBView.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/derby/DBDatabaseDriverDerby.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/h2/DBDatabaseDriverH2.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/hsql/DBDatabaseDriverHSql.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/oracle/DBCommandOracle.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/IntegerTest.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java
    incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/EmpireException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/EmpireException.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/EmpireException.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/EmpireException.java Tue Jul 19 16:53:34 2011
@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
  * Exceptions will only be thrown if exceptions are enabled in the ErrorObject.
  * @see ErrorObject#setExceptionsEnabled(boolean)
  */
-public final class EmpireException extends RuntimeException
+public class EmpireException extends RuntimeException
 {
     // Logger
     private static final Logger log = LoggerFactory.getLogger(ErrorObject.class);
@@ -99,30 +99,32 @@ public final class EmpireException exten
     }
 
     /**
-     * Constructor
+     * Constructor for derived classes
      * @param errType
      * @param params
+     * @param cause
      */
-    public EmpireException(final ErrorType errType, final Object... params)
+    public EmpireException(final ErrorType errType, final Object[] params, final Throwable cause)
     {
-        super(formatErrorMessage(errType, params));
+        super(formatErrorMessage(errType, params), cause);
         // save type and params for custom message formatting
         this.errorType = errType;
-        this.errorParams = normalizeParams(params);
+        this.errorParams = params;
         // done
         log();
     }
 
     /**
      * Constructor
-     * @param other
+     * @param errType
+     * @param params
      */
-    public EmpireException(final EmpireException other)
+    public EmpireException(final ErrorType errType, final Object... params)
     {
-        super(other.getMessage(), other);
+        super(formatErrorMessage(errType, params));
         // save type and params for custom message formatting
-        this.errorType   = other.getErrorType();
-        this.errorParams = other.getErrorParams(); 
+        this.errorType = errType;
+        this.errorParams = normalizeParams(params);
         // done
         log();
     }
@@ -140,6 +142,20 @@ public final class EmpireException exten
         // done
         log();
     }
+
+    /**
+     * Constructor
+     * @param other
+     */
+    public EmpireException(final EmpireException other)
+    {
+        super(other.getMessage(), other);
+        // save type and params for custom message formatting
+        this.errorType   = other.getErrorType();
+        this.errorParams = other.getErrorParams(); 
+        // done
+        log();
+    }
     
     private void log()
     {

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/commons/ErrorObject.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/commons/ErrorObject.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/commons/ErrorObject.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/commons/ErrorObject.java Tue Jul 19 16:53:34 2011
@@ -18,13 +18,13 @@
  */
 package org.apache.empire.commons;
 
+import java.text.MessageFormat;
+import java.util.WeakHashMap;
+
 import org.apache.empire.EmpireException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.text.MessageFormat;
-import java.util.WeakHashMap;
-
 
 /**
  * This class holds and provides information about the last error that occured on an object.
@@ -50,7 +50,7 @@ public abstract class ErrorObject implem
      * If disabled (default) the functions' return values will indicate success or failure<BR> 
      * @return true if Exceptions are enable or false otherwise
      */
-    public static boolean isExceptionsEnabled()
+    private static boolean isExceptionsEnabled()
     {
         return exceptionsEnabled;
     }
@@ -61,7 +61,7 @@ public abstract class ErrorObject implem
      * Instead the functions' return values will indicate success or failure<BR> 
      * @param enableExceptions true to enable exceptions or false to disable
      */
-    public static void setExceptionsEnabled(boolean enableExceptions)
+    private static void setExceptionsEnabled(boolean enableExceptions)
     {
         ErrorObject.exceptionsEnabled = enableExceptions;
     }
@@ -105,7 +105,7 @@ public abstract class ErrorObject implem
      * @param error the error information for which to obtain an error message
      * @return the error message or an empty string if no error has been set.
      */
-    public static String getMessage(ErrorInfo error)
+    private static String getMessage(ErrorInfo error)
     {
         if (error==null)
             return "";
@@ -143,7 +143,7 @@ public abstract class ErrorObject implem
     /**
      * getErrorInfo
      */
-    protected ObjectErrorInfo getErrorInfo(boolean create)
+    private ObjectErrorInfo getErrorInfo(boolean create)
     {
         WeakHashMap<ErrorObject, ObjectErrorInfo> map = errorMap.get();
         if (map==null)
@@ -161,7 +161,7 @@ public abstract class ErrorObject implem
     /**
      * Clears the ErrorInfo.
      */
-    protected void clearErrorInfo()
+    private void clearErrorInfo()
     {
         WeakHashMap<ErrorObject, ObjectErrorInfo> map = errorMap.get();
         if (map!=null)
@@ -212,19 +212,19 @@ public abstract class ErrorObject implem
         return ((info!=null) ? info.errParams : null);
     }
     
+    public final String getErrorMessage()
+    {
+        return getMessage(this);
+    }
+    
     /**
      * Clears the error for this object.
      */
-    public final void clearError()
+    private final void clearError()
     {
         internalSetError(Errors.None, null, null);
     }
     
-    public final String getErrorMessage()
-    {
-        return getMessage(this);
-    }
-    
     /**
      * Sets the last error and the corresponding error message on this object.
      * 
@@ -233,7 +233,7 @@ public abstract class ErrorObject implem
      * @param source object from which this error originated from.
      * @return always false except if the errType is of Type Errors.None
      */
-    protected boolean internalSetError(final ErrorType errType, final Object[] params, final ErrorInfo source)
+    private boolean internalSetError(final ErrorType errType, final Object[] params, final ErrorInfo source)
     { 	// setError
         if (errType == Errors.None )
         {   // No Error
@@ -253,9 +253,9 @@ public abstract class ErrorObject implem
     }
     
     /** returns true */
-    protected final boolean success()
+    private final void success()
     {
-        return internalSetError(Errors.None, null, null);
+        // return internalSetError(Errors.None, null, null);
     }
 
     /**
@@ -265,13 +265,13 @@ public abstract class ErrorObject implem
      * @param params array of parameters for the error message if any.
      * @return always false except if the errType is of Type Errors.None
      */
-    protected final boolean error(final ErrorType errType, final Object... params)
+    private final void error(final ErrorType errType, final Object... params)
     {
         // check error code
         if (errType == Errors.None)
         {	// Must supply a valid error code
             log.error("error function called with invalid error Code.");
-            return true; 
+            return; 
         }
         // Check parameter count
         int paramCount = (params!=null) ? params.length : 0;
@@ -306,7 +306,7 @@ public abstract class ErrorObject implem
             log.error("Unable to log error message.", e);
         }
         // Set the Error
-        return internalSetError(errType, params, null);
+        internalSetError(errType, params, null);
     }
 
     /**
@@ -314,9 +314,9 @@ public abstract class ErrorObject implem
      * 
      * @return always false except if the errType is of Type Errors.None
      */
-    protected final boolean error(final ErrorType errType)
+    private final void error(final ErrorType errType)
     {
-        return error(errType, (Object[])null);
+        error(errType, (Object[])null);
     }
 
     /**
@@ -326,11 +326,11 @@ public abstract class ErrorObject implem
      * @param exptn Exception from witch the error message is copied.
      * @return always false except if the errType is of Type Errors.None
      */
-    protected final boolean error(final ErrorType errType, final Throwable exptn)
+    private final void error(final ErrorType errType, final Throwable exptn)
     {
         if (exptn==null)
         {   log.warn("Cannot set exception error with param of null!");
-            return true; // No Error
+            return; // No Error
         }
         // Exception
         String type  = exptn.getClass().getName();
@@ -342,7 +342,7 @@ public abstract class ErrorObject implem
         StackTraceElement[] stack = exptn.getStackTrace();
         String pos = (stack!=null) ? stack[0].toString() : getClass().getName();
         // Create Error
-        return error(errType, new Object[] { type, msg, pos });
+        error(errType, new Object[] { type, msg, pos });
     }
 
     /**
@@ -351,9 +351,9 @@ public abstract class ErrorObject implem
      * @param exptn Exception from witch the error message is copied.
      * @return always false except if the errType is of Type Errors.None
      */
-    protected final boolean error(final Throwable exptn)
+    private final void error(final Throwable exptn)
     {
-        return error(Errors.Exception, exptn);
+        error(Errors.Exception, exptn);
     }
 
     /**
@@ -362,9 +362,8 @@ public abstract class ErrorObject implem
      * @param other the object from which to copy the error.
      * @return always false except if the errType is of Type Errors.None
      */
-    protected final boolean error(final ErrorInfo other)
+    private final void error(final ErrorInfo other)
     {   // copy other error
-        return internalSetError(other.getErrorType(),
-                                other.getErrorParams(), other);
+        internalSetError(other.getErrorType(), other.getErrorParams(), other);
     }
 }
\ No newline at end of file

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/Record.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/Record.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/Record.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/Record.java Tue Jul 19 16:53:34 2011
@@ -30,7 +30,7 @@ import org.apache.empire.commons.Options
  * <P>
  * This interface inherits from RecordData which provides further data access methods.
  * <P>
- * The Record interface is implmented by the class {@link org.apache.empire.db.DBRecord}
+ * The Record interface is implemented by the class {@link org.apache.empire.db.DBRecord}
  * <P>
  */
 public interface Record extends RecordData
@@ -94,17 +94,15 @@ public interface Record extends RecordDa
      * sets a record value based on the field index.
      * @param i index of the field for which to set the value
      * @param value the new field value
-     * @return true if value has been set or false if the value cannot be set for this field
      */
-    boolean setValue(int i, Object value);
+    void setValue(int i, Object value);
 
     /**
      * sets a record value based on a column.
      * @param column the requested column
      * @param value the new record value for the given column
-     * @return true if value has been set or false if the value cannot be set for this column
      */
-    boolean setValue(Column column, Object value);
+    void setValue(Column column, Object value);
 
     /**
      * checks whether or not the field for the given column has been modified since it has been loaded.
@@ -125,9 +123,9 @@ public interface Record extends RecordDa
      * <P>
      * @param bean the Java Bean from which to read the value from
      * @param ignoreList list of column to ignore
-     * @return true if at least one field value has been successfully set    
+     * @return the number of fields that have been set    
      */
-    boolean setBeanValues(Object bean, Collection<Column> ignoreList);
+    int setBeanValues(Object bean, Collection<Column> ignoreList);
 
     /**
      * sets all record values from a particular bean.
@@ -135,8 +133,8 @@ public interface Record extends RecordDa
      * The bean must provide corresponding getter functions for all desired column.
      * <P>
      * @param bean the Java Bean from which to read the value from
-     * @return true if at least one field value has been successfully set    
+     * @return the number of fields that have been set    
      */
-    boolean setBeanValues(Object bean);
+    int setBeanValues(Object bean);
 
 }

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/RecordData.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/RecordData.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/RecordData.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/RecordData.java Tue Jul 19 16:53:34 2011
@@ -23,7 +23,7 @@ import java.util.Collection;
 /**
  * The RecordData interface provides methods for accessing data and context specific metadata.
  * <P>
- * The Record interface is implmented by the classes {@link org.apache.empire.db.DBReader}
+ * The Record interface is implemented by the classes {@link org.apache.empire.db.DBReader}
  * and {@link org.apache.empire.db.DBRecord}.
  * <P>
  */
@@ -37,7 +37,7 @@ public interface RecordData
 
     /**
      * returns the index of the given column expression
-     * Indexed operations provide better performace for bulk processing  
+     * Indexed operations provide better performance for bulk processing  
      * @param column the column for which to return the index
      * @return the field index of the given column
      */
@@ -60,7 +60,7 @@ public interface RecordData
 
     /**
      * returns the value of the field at the given index position 
-     * Indexed operations provide better performace for bulk processing compared to getValue(ColumnExpr)  
+     * Indexed operations provide better performance for bulk processing compared to getValue(ColumnExpr)  
      * @param index the field index for which to return the value
      * @return the record value for the given field
      */
@@ -75,7 +75,7 @@ public interface RecordData
     
     /**
      * checks if the field at the given index position contains no value (null) 
-     * Indexed operations provide better performace for bulk processing compared to isNull(ColumnExpr)  
+     * Indexed operations provide better performance for bulk processing compared to isNull(ColumnExpr)  
      * @param index the field index
      * @return true if the field value is null or false otherwise
      */
@@ -91,24 +91,22 @@ public interface RecordData
     // ------- Java Bean Support -------
 
     /**
-     * writes all field values into a static Java Bean.
+     * copies all field values into a static Java Bean.
      * <P>
      * In order to map column names to property names 
      * the property name is detected by ColumnExpr.getBeanPropertyName()     
      * @param bean the Java Bean for which to set the properties
      * @param ignoreList list of columns to skip (optional)
-     * @return true if at least one property has been successfully set
      */
-    boolean getBeanProperties(Object bean, Collection<ColumnExpr> ignoreList);
+    int getBeanProperties(Object bean, Collection<ColumnExpr> ignoreList);
 
     /**
-     * writes all field values into a static Java Bean.
+     * copies all field values into a static Java Bean.
      * <P>
      * In order to map column names to property names 
      * the property name is detected by ColumnExpr.getBeanPropertyName()     
      * @param bean the Java Bean for which to set the properties
-     * @return true if at least one property has been successfully set
      */
-    boolean getBeanProperties(Object bean);
+    int getBeanProperties(Object bean);
 
 }

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/bean/BeanRecordProxy.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/bean/BeanRecordProxy.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/bean/BeanRecordProxy.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/data/bean/BeanRecordProxy.java Tue Jul 19 16:53:34 2011
@@ -25,8 +25,7 @@ import java.util.List;
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.beanutils.BeanUtilsBean;
 import org.apache.commons.beanutils.PropertyUtilsBean;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.ErrorObject;
 import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.ObjectUtils;
@@ -34,6 +33,8 @@ import org.apache.empire.commons.Options
 import org.apache.empire.data.Column;
 import org.apache.empire.data.ColumnExpr;
 import org.apache.empire.data.Record;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -173,9 +174,8 @@ public class BeanRecordProxy<T> extends 
     public boolean isNew()
     {
         if (!isValid())
-            return error(Errors.InvalidProperty, "bean");
+            throw new EmpireException(Errors.InvalidProperty, "bean");
         // Record is new until all key fields have been supplied
-        clearError();
         if (keyColumns!=null)
         {   // Check all Key Columns
             for (int i=0; i<keyColumns.length; i++)
@@ -199,9 +199,8 @@ public class BeanRecordProxy<T> extends 
     public Object getValue(ColumnExpr column)
     {
         if (!isValid())
-        {   error(Errors.InvalidProperty, "bean");
-            return null;
-        }
+            throw new EmpireException(Errors.InvalidProperty, "bean");
+        // getBeanPropertyValue 
         return getBeanPropertyValue(data, column);
     }
 
@@ -223,10 +222,10 @@ public class BeanRecordProxy<T> extends 
     /**
      * sets the value of a field.
      */
-    public boolean setValue(Column column, Object value)
+    public void setValue(Column column, Object value)
     {
         if (!isValid())
-            return error(Errors.InvalidProperty, "bean");
+            throw new EmpireException(Errors.InvalidProperty, "bean");
         // Track modification status
         if (ObjectUtils.compareEqual(getValue(column), value)==false)
         {
@@ -235,15 +234,15 @@ public class BeanRecordProxy<T> extends 
             modified[getFieldIndex(column)] = true;
         }
         // Set Value
-        return setBeanPropertyValue(data, column, value);
+        setBeanPropertyValue(data, column, value);
     }
 
     /**
      * sets the value of a field.
      */
-    public boolean setValue(int i, Object value)
+    public void setValue(int i, Object value)
     {
-        return setValue(getColumn(i), value);
+        setValue(getColumn(i), value);
     }
 
     /**
@@ -253,8 +252,8 @@ public class BeanRecordProxy<T> extends 
     {
         int index = getFieldIndex(column);
         if (index<0)
-            return error(Errors.ItemNotFound, column.getName());
-        clearError();
+            throw new EmpireException(Errors.ItemNotFound, column.getName());
+        // check modified
         return (modified!=null && modified[index]);
     }
 
@@ -268,12 +267,12 @@ public class BeanRecordProxy<T> extends 
 
     // --------------- Bean support ------------------
 
-    public boolean getBeanProperties(Object bean)
+    public int getBeanProperties(Object bean)
     {
         return getBeanProperties(bean, null);
     }
 
-    public boolean getBeanProperties(Object bean, Collection<ColumnExpr> ignoreList)
+    public int getBeanProperties(Object bean, Collection<ColumnExpr> ignoreList)
     {
         // Add all Columns
         int count = 0;
@@ -287,10 +286,10 @@ public class BeanRecordProxy<T> extends 
             // Get Property Name
             setBeanPropertyValue(bean, column, getValue(i));
         }
-        return (count > 0);
+        return count;
     }
 
-    public boolean setBeanValues(Object bean, Collection<Column> ignoreList)
+    public int setBeanValues(Object bean, Collection<Column> ignoreList)
     {
         // Add all Columns
         int count = 0;
@@ -306,13 +305,13 @@ public class BeanRecordProxy<T> extends 
             Object value = getBeanPropertyValue(bean, property);
             if (value==null && this.hasError())
                 continue;
-            if (setValue(column, value))
-                count++;
+            setValue(column, value);
+            count++;
         }
-        return (count > 0);
+        return count;
     }
 
-    public boolean setBeanValues(Object bean)
+    public int setBeanValues(Object bean)
     {
         return setBeanValues(bean, null);
     }
@@ -323,9 +322,8 @@ public class BeanRecordProxy<T> extends 
     {
         // Check Params
         if (column==null)
-        {   error(Errors.InvalidArg, "column");
-            return null;
-        }
+            throw new EmpireException(Errors.InvalidArg, "column");
+        // getBeanPropertyValue 
         return getBeanPropertyValue(bean, column.getBeanPropertyName()); 
     }
 
@@ -333,55 +331,47 @@ public class BeanRecordProxy<T> extends 
     {
         // Check Params
         if (bean==null || property==null)
-        {   error(Errors.InvalidArg, "property");
-            return null;
-        }
+            throw new EmpireException(Errors.InvalidArg, "property");
         try
         {   // Get Property Value
-            clearError();
             PropertyUtilsBean pub = BeanUtilsBean.getInstance().getPropertyUtils();
             return pub.getSimpleProperty(bean, property);
 
         } catch (IllegalAccessException e)
         {   log.error(bean.getClass().getName() + ": unable to get property '" + property + "'");
-            error(e);
-            return null;
+            throw new EmpireException(e);
         } catch (InvocationTargetException e)
         {   log.error(bean.getClass().getName() + ": unable to get property '" + property + "'");
-            error(e);
-            return null;
+            throw new EmpireException(e);
         } catch (NoSuchMethodException e)
         {   log.warn(bean.getClass().getName() + ": no getter available for property '" + property + "'");
-            error(e);
-            return null;
+            throw new EmpireException(e);
         }
     }
 
-    protected boolean setBeanPropertyValue(Object bean, Column column, Object value)
+    protected void setBeanPropertyValue(Object bean, Column column, Object value)
     {
         // Check Params
         if (bean==null || column==null)
-            return error(Errors.InvalidArg, "column");
+            throw new EmpireException(Errors.InvalidArg, "column");
         // Get Property Name
         String property = column.getBeanPropertyName(); 
         try
         {   // Get Property Value
-            clearError();
             if (ObjectUtils.isEmpty(value))
                 value = null;
             BeanUtils.setProperty(bean, property, value);
             // PropertyUtilsBean pub = BeanUtilsBean.getInstance().getPropertyUtils();
             // pub.setSimpleProperty(data, property, value);
-            return success();
         } catch (IllegalArgumentException e) {
             log.error(bean.getClass().getName() + ": invalid argument for property '" + property + "'");
-            return error(e);
+            throw new EmpireException(e);
         } catch (IllegalAccessException e)
         {   log.error(bean.getClass().getName() + ": unable to set property '" + property + "'");
-            return error(e);
+            throw new EmpireException(e);
         } catch (InvocationTargetException e)
         {   log.error(bean.getClass().getName() + ": unable to set property '" + property + "'");
-            return error(e);
+            throw new EmpireException(e);
         }    
     }
     

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBColumn.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBColumn.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBColumn.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBColumn.java Tue Jul 19 16:53:34 2011
@@ -114,7 +114,7 @@ public abstract class DBColumn extends D
      */
     public abstract boolean isReadOnly();
 
-    public abstract boolean checkValue(Object value);
+    public abstract void checkValue(Object value);
 
     @Override
     public abstract Element addXml(Element parent, long flags);

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java Tue Jul 19 16:53:34 2011
@@ -125,20 +125,18 @@ public class DBCombinedCmd extends DBCom
    * @return true if the creation was successful
    */
    @Override
-   public boolean getSelect(StringBuilder buf)
+   public void getSelect(StringBuilder buf)
    {
       // the left part
       left.clearOrderBy();
-      if (!left.getSelect(buf))
-           return error(left);
+      left.getSelect(buf);
       // concat keyword     
       buf.append( " " );
       buf.append( keyWord );
       buf.append( " (" );
       // the right part
       right.clearOrderBy();
-      if (!right.getSelect(buf))
-           return error(right);
+      right.getSelect(buf);
       // done
       buf.append( ")" );
       // Add optional Order by statement
@@ -147,7 +145,6 @@ public class DBCombinedCmd extends DBCom
            buf.append("\r\nORDER BY ");
            addListExpr(buf, orderBy, CTX_DEFAULT, ", ");
       }
-      return success();
    }
 
    @Override

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCommand.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCommand.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCommand.java Tue Jul 19 16:53:34 2011
@@ -672,9 +672,9 @@ public abstract class DBCommand extends 
      * 
      * @return true if the database supports a limit or false otherwise
      */
-    public boolean limitRows(int numRows)
+    public void limitRows(int numRows)
     {
-        return error(Errors.NotSupported, "limitRows");
+        throw new EmpireException(Errors.NotSupported, "limitRows");
     }
 
     /**
@@ -683,9 +683,9 @@ public abstract class DBCommand extends 
      * 
      * @return true if the database supports an offset or false otherwise
      */
-    public boolean skipRows(int numRows)
+    public void skipRows(int numRows)
     {
-        return error(Errors.NotSupported, "skipRows");
+        throw new EmpireException(Errors.NotSupported, "skipRows");
     }
     
     /**
@@ -702,11 +702,11 @@ public abstract class DBCommand extends 
     }
     
     @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 EmpireException(Errors.ObjectNotValid, getClass().getName()); // invalid!
         // Prepares statement
         addSelect(buf);
         // From clause
@@ -717,8 +717,6 @@ public abstract class DBCommand extends 
         addGrouping(buf);
         // Add Order
         addOrder(buf);
-        // done
-        return success();
     }
     
     /**

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java Tue Jul 19 16:53:34 2011
@@ -19,6 +19,7 @@
 package org.apache.empire.db;
 
 // java
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.Options;
 import org.apache.empire.data.DataType;
@@ -107,8 +108,7 @@ public abstract class DBCommandExpr exte
         @Override
         public DBColumn[] getKeyColumns()
         {
-            error(Errors.NotSupported, "getKeyColumns");
-            return null;
+            throw new EmpireException(Errors.NotSupported, "getKeyColumns");
         }
 
         /**
@@ -119,48 +119,47 @@ public abstract class DBCommandExpr exte
         @Override
         public Object[] getRecordKey(DBRecord rec)
         {
-            error(Errors.NotSupported, "getRecordKey");
-            return null;
+            throw new EmpireException(Errors.NotSupported, "getRecordKey");
         }
 
         /** Returns the error message: ERR_NOTSUPPORTED */
         @Override
-        public boolean initRecord(DBRecord rec, Object[] keyValues)
+        public void initRecord(DBRecord rec, Object[] keyValues)
         {
-            return error(Errors.NotSupported, "initRecord");
+            throw new EmpireException(Errors.NotSupported, "initRecord");
         }
 
         /** Returns the error message: ERR_NOTSUPPORTED */
         @Override
-        public boolean createRecord(DBRecord rec, Connection conn)
+        public void createRecord(DBRecord rec, Connection conn)
         {
-            return error(Errors.NotSupported, "addRecord");
+            throw new EmpireException(Errors.NotSupported, "addRecord");
         }
 
         /** Returns the error message: ERR_NOTSUPPORTED */
         @Override
-        public boolean readRecord(DBRecord rec, Object[] keys, Connection conn)
+        public void readRecord(DBRecord rec, Object[] keys, Connection conn)
         {
-            return error(Errors.NotSupported, "getRecord");
+            throw new EmpireException(Errors.NotSupported, "getRecord");
         }
 
         /** Returns the error message: ERR_NOTSUPPORTED */
         @Override
-        public boolean updateRecord(DBRecord rec, Connection conn)
+        public void updateRecord(DBRecord rec, Connection conn)
         {
-            return error(Errors.NotSupported, "updateRecord");
+            throw new EmpireException(Errors.NotSupported, "updateRecord");
         }
 
         /** Returns the error message: ERR_NOTSUPPORTED */
         @Override
-        public boolean deleteRecord(Object[] keys, Connection conn)
+        public void deleteRecord(Object[] keys, Connection conn)
         {
-            return error(Errors.NotSupported, "deleteRecord");
+            throw new EmpireException(Errors.NotSupported, "deleteRecord");
         }
     }
 
     /**
-     * This class wrapps a column of sql command in a special command column object. 
+     * This class wraps a column of sql command in a special command column object. 
      */
     protected static class DBCmdColumn extends DBColumn
     {
@@ -275,9 +274,9 @@ public abstract class DBCommandExpr exte
          * Not applicable - always returns true.
          */
         @Override
-        public boolean checkValue(Object value)
+        public void checkValue(Object value)
         {
-            return true;
+            // Nothing to check.
         }
 
         /**
@@ -304,7 +303,7 @@ public abstract class DBCommandExpr exte
     // get Select SQL
     public abstract boolean isValid();
 
-    public abstract boolean getSelect(StringBuilder buf);
+    public abstract void getSelect(StringBuilder buf);
 
     public abstract DBColumnExpr[] getSelectExprList();
     
@@ -340,15 +339,11 @@ public abstract class DBCommandExpr exte
      * returns an SQL select command for querying records.
      * @return the SQL-Command
      */
-    public String getSelect()
+    public final String getSelect()
     {
-        StringBuilder buf = new StringBuilder();
-        if (getSelect(buf) == false)
-        {
-            log.error(getErrorMessage());
-            return null;
-        }
-        return buf.toString();
+        StringBuilder sql = new StringBuilder();
+        getSelect(sql);
+        return sql.toString();
     }
 
     /**
@@ -467,10 +462,8 @@ public abstract class DBCommandExpr exte
     protected String getInsertInto(DBTable table, DBColumnExpr[] select, List<DBColumnExpr> columns)
     {
         if (select == null)
-        { // invalid Object
-            error(Errors.ObjectNotValid, getClass().getName());
-            return null;
-        }
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
+        // prepare buffer
         StringBuilder buf = new StringBuilder("INSERT INTO ");
         table.addSQL(buf, CTX_FULLNAME);
         // destination columns
@@ -478,8 +471,7 @@ public abstract class DBCommandExpr exte
         { // Check Count
             if (columns.size() != select.length)
             {
-                error(Errors.InvalidArg, columns, "columns");
-                return null;
+                throw new EmpireException(Errors.InvalidArg, columns, "columns");
             }
             // Append Names
             buf.append(" (");
@@ -519,10 +511,7 @@ public abstract class DBCommandExpr exte
     {
         DBColumnExpr[] select = getSelectExprList();
         if (select == null || select.length < 1)
-        {
-            error(Errors.ObjectNotValid, getClass().getName());
-            return null;
-        }
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // Match Columns
         List<DBColumnExpr> inscols = new ArrayList<DBColumnExpr>(select.length);
         for (int i = 0; i < select.length; i++)

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java Tue Jul 19 16:53:34 2011
@@ -26,6 +26,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.Options;
@@ -162,22 +163,20 @@ public abstract class DBDatabase extends
      * Sets the database driver for this database. This will
      * set up the connection for use.<br>
      * 
-     * @param driver the databae driver
+     * @param driver the database driver
      * @param conn the connection
      * 
-     * @return true on succes
+     * @return true on success
      */
-    public boolean open(DBDatabaseDriver driver, Connection conn)
+    public void open(DBDatabaseDriver driver, Connection conn)
     {
         // Close Database if already open
         if (isOpen())
             close(conn);
         // Attach to driver
-        if (driver.attachDatabase(this, conn)==false)
-            return error(driver);
+        driver.attachDatabase(this, conn);
         // set new driver
         this.driver = driver;
-        return success();
     }
 
     /**
@@ -207,24 +206,20 @@ public abstract class DBDatabase extends
      * 
      * @return the DLL script for creating the entire database schema
      */
-    public synchronized boolean getCreateDDLScript(DBDatabaseDriver driver, DBSQLScript script)
+    public synchronized void getCreateDDLScript(DBDatabaseDriver driver, DBSQLScript script)
     {
         DBDatabaseDriver prevDriver = this.driver;
         try {
             // Set driver
             if (this.driver!=null && this.driver!=driver && driver!=null)
             {   // The database belongs to a different driver
-                return error(Errors.Internal, "The database is attached to a different driver.");
+                throw new EmpireException(Errors.Internal, "The database is attached to a different driver.");
             }
             // Temporarily change driver
             if (this.driver== null)
                 this.driver = driver;
             // Get DDL Command
-            if (driver.getDDLScript(DBCmdType.CREATE, this, script)==false)
-            {   // DDL-creation failed 
-                return error(driver);
-            }
-            return success();
+            driver.getDDLScript(DBCmdType.CREATE, this, script);
             
         } finally {
             this.driver = prevDriver; 
@@ -255,15 +250,14 @@ public abstract class DBDatabase extends
      * 
      * @param schema the schema to set
      * 
-     * @return true on succes
+     * @return true on success
      */
-    public boolean setSchema(String schema)
+    public void setSchema(String schema)
     {   // Database must not be open so far
         if (driver != null)
-            return error(Errors.NoAccess);
+            throw new EmpireException(Errors.NoAccess);
         // Set Schema 
         this.schema = schema;
-        return success();
     }
 
     /**
@@ -296,15 +290,14 @@ public abstract class DBDatabase extends
      * 
      * @param linkName the database link name
      * 
-     * @return true on succes
+     * @return true on success
      */
-    public boolean setLinkName(String linkName)
+    public void setLinkName(String linkName)
     {   // Database must not be open so far
         if (driver != null)
-            return error(Errors.NoAccess);
+            throw new EmpireException(Errors.NoAccess);
         // Set Link 
         this.linkName = linkName;
-        return success();
     }
 
     /**
@@ -327,7 +320,7 @@ public abstract class DBDatabase extends
     /**
      * Adds a full qualified object name including schema prefix
      * and database link postfix (if any).
-     * to the string buffer suppield
+     * to the string buffer supplied
      * 
      * @param buf the string buffer to which to append the qualified object name
      * @param name the object's name
@@ -338,7 +331,7 @@ public abstract class DBDatabase extends
         // Check driver
         if (driver==null)
         {   // No driver attached!
-            error(Errors.ObjectNotValid, name);
+            log.warn("No driver attached for appending qualified name {0}.", name);
             buf.append(name);
             return;
         }
@@ -433,24 +426,23 @@ public abstract class DBDatabase extends
      * @param table the DBTable object
      * @return true if successful
      */
-    public boolean addTable(DBTable table)
+    public void addTable(DBTable table)
     { // find column by name
         if (table == null || table.getDatabase() != this)
-            return error(Errors.InvalidArg, table, "table");
+            throw new EmpireException(Errors.InvalidArg, table, "table");
         if (tables.contains(table)==true)
-            return error(Errors.ItemExists, table.getName());
+            throw new EmpireException(Errors.ItemExists, table.getName());
         // Check for second instances
         DBTable existing = getTable(table.getName()); 
         if (existing!=null)
         {   // Check classes
             if (existing.getClass().equals(table.getClass()))
-                return success(); // Ingore other instances 
+                return; // Ignore other instances 
             // Table exists with different class
-            return error(Errors.ItemExists, table.getName());
+            throw new EmpireException(Errors.ItemExists, table.getName());
         }
         // add now
         tables.add(table);
-        return true;
     }
 
     /**
@@ -486,14 +478,14 @@ public abstract class DBDatabase extends
      * @param reference a reference for a source and target column pair
      * @return true if the relations were successfully created.
      */
-    public final boolean addRelation(DBRelation.DBReference reference)
+    public final void addRelation(DBRelation.DBReference reference)
     {
         String table = reference.getSourceColumn().getRowSet().getName();
         String col1 = reference.getSourceColumn().getName();
         // Create Relation Name
         String name = table.substring(0, Math.min(table.length(), 14)) + "_" + col1.substring(0, Math.min(col1.length(), 12))
         			  + "_FK";
-        return addRelation(name, new DBRelation.DBReference[] { reference });
+        addRelation(name, new DBRelation.DBReference[] { reference });
     }
 
     /**
@@ -503,7 +495,7 @@ public abstract class DBDatabase extends
      * @param ref2 a reference for a source and target column pair
      * @return true if the relations were successfully created.
      */
-    public final boolean addRelation(DBRelation.DBReference ref1, DBRelation.DBReference ref2)
+    public final void addRelation(DBRelation.DBReference ref1, DBRelation.DBReference ref2)
     {
         String table = ref1.getSourceColumn().getRowSet().getName();
         String col1 = ref1.getSourceColumn().getName();
@@ -512,7 +504,7 @@ public abstract class DBDatabase extends
         String name = table.substring(0, Math.min(table.length(), 9))
                     + "_" + col1.substring(0, Math.min(col1.length(), 9))
                     + "_" + col2.substring(0, Math.min(col2.length(), 9)) + "_FK";
-        return addRelation(name, new DBRelation.DBReference[] { ref1, ref2 });
+        addRelation(name, new DBRelation.DBReference[] { ref1, ref2 });
     }
 
     /**
@@ -523,12 +515,12 @@ public abstract class DBDatabase extends
      * 
      * @return true if the relations were successfully created.
      */
-    public boolean addRelation(String name, DBRelation.DBReference[] references)
+    public void addRelation(String name, DBRelation.DBReference[] references)
     {
         // Add a Relation
         DBRelation relation = new DBRelation(this, name, references);
         if (relations.contains(relation))
-            return error(Errors.ItemExists, name); // Itemn already exists
+            throw new EmpireException(Errors.ItemExists, name); // Itemn already exists
         // Add Reference column to table
         for (DBRelation.DBReference ref : references)
         {   // add the reference column
@@ -537,7 +529,6 @@ public abstract class DBDatabase extends
         }
         // OK
         relations.add(relation);
-        return true;
     }
 
     /**
@@ -558,15 +549,14 @@ public abstract class DBDatabase extends
      * @param view the DBView object
      * @return true if successful
      */
-    public boolean addView(DBView view)
+    public void addView(DBView view)
     { // find column by name
         if (view == null || view.getDatabase() != this)
-            return error(Errors.InvalidArg, view, "view");
+            throw new EmpireException(Errors.InvalidArg, view, "view");
         if (views.contains(view) == true)
-            return error(Errors.ItemExists, view.getName());
+            throw new EmpireException(Errors.ItemExists, view.getName());
         // add now
         views.add(view);
-        return true;
     }
 
     /**
@@ -609,11 +599,10 @@ public abstract class DBDatabase extends
     /**
      * @return true if the database has been opened or false otherwise 
      */
-    protected boolean checkOpen()
+    protected void checkOpen()
     {
-        if (driver == null)
-            return error(DBErrors.DatabaseNotOpen);
-        return success();
+        if (isOpen()==false)
+            throw new EmpireException(DBErrors.DatabaseNotOpen);
     }
     
     /**
@@ -623,8 +612,7 @@ public abstract class DBDatabase extends
      */
     public DBCommand createCommand()
     {
-        if (!checkOpen()) 
-            return null;
+        checkOpen(); 
         return driver.createCommand(this);
     }
 
@@ -636,20 +624,16 @@ public abstract class DBDatabase extends
      */
     public java.sql.Timestamp getUpdateTimestamp(Connection conn)
     {
-        // Default implementation
-        if (checkOpen()==false)
-            return null;
         // Ask driver
+        checkOpen(); 
         return driver.getUpdateTimestamp(conn);
     }
 
     // Sequences
     public Object getNextSequenceValue(String seqName, Connection conn)
     {
-        // Default implementation
-        if (checkOpen()==false)
-            return null;
         // Ask driver
+        checkOpen(); 
         return driver.getNextSequenceValue(this, seqName, 1, conn);
     }
 
@@ -665,42 +649,34 @@ public abstract class DBDatabase extends
 
     public Object querySingleValue(String sqlCmd, Connection conn)
     {
+        checkOpen(); 
         ResultSet rs = null;
         try
-        {	// Check Open
-            if (checkOpen()==false)
-                return null;
-            // Debug
+        {   // Debug
             long start = System.currentTimeMillis();
             if (log.isDebugEnabled())
                 log.debug("executing: " + sqlCmd);
             // Get the next Value
             rs = driver.executeQuery(sqlCmd, null, false, conn);
             if (rs == null)
-            { // Error
-                error(driver);
-                return null;
-            }
+                throw new EmpireException(Errors.Internal, "Unexpected return value.");
             // Check Result
             if (rs.next() == false)
-            {
-                //log.warn("querySingleValue returned no result : Stack", new Exception("Just to show the stack"));
+            {   // no result
                 log.debug("querySingleValue returned no result");
-                error(DBErrors.QueryNoResult, sqlCmd);
-                return null;
+                throw new EmpireException(DBErrors.QueryNoResult, sqlCmd);
             }
             // No Value
-            clearError();
             Object result = rs.getObject(1);
             if (log.isDebugEnabled())
 	            log.debug("querySingleValue complete in " + (System.currentTimeMillis() - start) + " ms -> value="
 	                        + result);
             return result;
-        } catch (SQLException e) 
-        {
-            log.error("querySingleValue exception: " + e.toString());
-            error(DBErrors.QueryFailed, e);
-            return null;
+        } catch (SQLException sqle) 
+        {   // Error
+            EmpireException exptn = SQL2EmpireException(DBErrors.QueryFailed, sqle); 
+            log.error("Error executing query {0}. Message is {0}", sqlCmd, exptn.getMessage());
+            throw exptn;
         } finally
         { // Cleanup
             closeResultSet(rs);
@@ -825,10 +801,8 @@ public abstract class DBDatabase extends
      * @return the number of elements that have been added to the collection or -1 if an error occurred 
      */
     public <T> int querySimpleList(Class<T> c, String sqlCmd, Connection conn, Collection<T> result)
-    {   // Check status
-        if (checkOpen()==false)
-            return -1;
-        // Start query
+    {   // Start query
+        checkOpen();
         ResultSet rs = null;
         try
         {   // Log performance
@@ -838,10 +812,7 @@ public abstract class DBDatabase extends
             // Get the next Value
             rs = driver.executeQuery(sqlCmd, null, false, conn);
             if (rs == null)
-            { // Error
-                error(driver);
-                return -1;
-            }
+                throw new EmpireException(Errors.Internal, "Unexpected return value.");
             // Check Result
             int count=0;
             while (rs.next())
@@ -853,18 +824,15 @@ public abstract class DBDatabase extends
             // No Value
             if (log.isInfoEnabled())
                 log.info("querySimpleList retured " + count + " items. Query completed in " + (System.currentTimeMillis() - start) + " ms");
-            clearError();
             return count;
         } catch (ClassCastException e) 
-        {   
-            log.error("querySingleValue cast exception: ", e);
-            error(Errors.Exception, e);
-            return -1;
-        } catch (SQLException e) 
-        {
-            log.error("querySimpleList exception: ", e);
-            error(DBErrors.QueryFailed, e);
-            return -1;
+        {   log.error("querySingleValue cast exception: ", e);
+            throw new EmpireException(e);
+        } catch (SQLException sqle) 
+        {   // Error
+            EmpireException exptn = SQL2EmpireException(DBErrors.QueryFailed, sqle); 
+            log.error("Error executing query {0}. Message is {0}", sqlCmd, exptn.getMessage());
+            throw exptn;
         } finally
         { // Cleanup
             closeResultSet(rs);
@@ -913,30 +881,19 @@ public abstract class DBDatabase extends
      */
     public Options queryOptionList(String sqlCmd, Connection conn)
     {   // Execute the  Statement
-        if (checkOpen()==false)
-            return null;
-        // Debug
+        checkOpen();
         ResultSet rs = null;
         try
-        {   // Check Open
-            if (checkOpen()==false)
-                return null;
-            // Debug
+        {   // Debug
             long start = System.currentTimeMillis();
             if (log.isInfoEnabled())
                 log.info("executing: " + sqlCmd);
             // Get the next Value
             rs = driver.executeQuery(sqlCmd, null, false, conn);
             if (rs == null)
-            { // Error
-                error(driver);
-                return null;
-            }
+                throw new EmpireException(Errors.Internal, "Unexpected return value.");
             if (rs.getMetaData().getColumnCount()<2)
-            {   // Not enough columns
-                error(Errors.InvalidArg, sqlCmd, "sqlCmd");
-                return null;
-            }
+                throw new EmpireException(Errors.InvalidArg, sqlCmd, "sqlCmd");
             // Check Result
             Options result = new Options();
             while (rs.next())
@@ -948,12 +905,12 @@ public abstract class DBDatabase extends
             // No Value
             if (log.isInfoEnabled())
                 log.info("queryOptionList retured " + result.size() + " items. Query completed in " + (System.currentTimeMillis() - start) + " ms");
-            clearError();
             return result;
-        } catch (SQLException e) 
-        {
-            error(DBErrors.QueryFailed, e);
-            return null;
+        } catch (SQLException sqle) 
+        {   // Error
+            EmpireException exptn = SQL2EmpireException(DBErrors.QueryFailed, sqle); 
+            log.error("Error executing query {0}. Message is {0}", sqlCmd, exptn.getMessage());
+            throw exptn;
         } finally
         { // Cleanup
             closeResultSet(rs);
@@ -971,10 +928,8 @@ public abstract class DBDatabase extends
      * @return a list of object arrays 
      */
     public int queryObjectList(String sqlCmd, Connection conn, Collection<Object[]> result)
-    {   // Check status
-        if (checkOpen()==false)
-            return -1;
-        // Perform query
+    {   // Perform query
+        checkOpen();
         ResultSet rs = null;
         try
         {   // Log performance
@@ -984,10 +939,7 @@ public abstract class DBDatabase extends
             // Get the next Value
             rs = driver.executeQuery(sqlCmd, null, false, conn);
             if (rs == null)
-            { // Error
-                error(driver);
-                return -1;
-            }
+                throw new EmpireException(Errors.Internal, "Unexpected return value.");
             // Read List
             int colCount = rs.getMetaData().getColumnCount();
             int count = 0;
@@ -1004,12 +956,12 @@ public abstract class DBDatabase extends
             // No Value
             if (log.isInfoEnabled())
                 log.info("queryObjectList retured " + count + " items. Query completed in " + (System.currentTimeMillis() - start) + " ms");
-            clearError();
             return count;
-        } catch (SQLException e) 
-        {
-            error(DBErrors.QueryFailed, e);
-            return -1;
+        } catch (SQLException sqle) 
+        {   // Error
+            EmpireException exptn = SQL2EmpireException(DBErrors.QueryFailed, sqle); 
+            log.error("Error executing query {0}. Message is {0}", sqlCmd, exptn.getMessage());
+            throw exptn;
         } finally
         { // Cleanup
             closeResultSet(rs);
@@ -1044,33 +996,28 @@ public abstract class DBDatabase extends
      */
     public int executeSQL(String sqlCmd, Object[] sqlParams, Connection conn, DBDatabaseDriver.DBSetGenKeys setGenKeys)
     {
+        checkOpen();
         try 
-        {
-            // check driver
-            if (checkOpen()==false)
-                return -1;
-            // Debug
+        {   // Debug
             if (log.isInfoEnabled())
                 log.info("Executing: " + sqlCmd);
             // execute SQL
             long start = System.currentTimeMillis();
             int affected = driver.executeSQL(sqlCmd, sqlParams, conn, setGenKeys);
+            // number of affected records
+            if (affected < 0)
+                throw new EmpireException(Errors.Internal, "Unexpected return value <0 for driver.executeSQL().");
             // Log
             if (log.isInfoEnabled())
 	            log.info("executeSQL affected " + affected + " Records / " + (System.currentTimeMillis() - start) + "ms");
-            // number of affected records
-            if (affected < 0)
-            {
-                error(driver);
-                return -1;
-            }
             // Return number of affected records
             return affected;
             
 	    } catch (SQLException sqle) 
         { 	// Error
-	        error(sqle);
-	        return -1;
+	        EmpireException exptn = SQL2EmpireException(DBErrors.QueryFailed, sqle); 
+            log.error("Error executing statement {0}. Message is {0}", sqlCmd, exptn.getMessage());
+            throw exptn;
 	    }    
     }
 
@@ -1105,33 +1052,28 @@ public abstract class DBDatabase extends
      */
     public ResultSet executeQuery(String sqlCmd, Object[] sqlParams, boolean scrollable, Connection conn)
     {
+        checkOpen();
         try
-        {   // check driver
-            if (checkOpen()==false)
-                return null;
-            // Debug
+        {   // Debug
             if (log.isDebugEnabled())
     	        log.debug("Executing: " + sqlCmd);
             // Execute the Statement
             long start = System.currentTimeMillis();
             ResultSet rs = driver.executeQuery(sqlCmd, sqlParams, scrollable, conn);
             if (rs == null)
-            {   error(driver);
-                return null;
-            }
+                throw new EmpireException(Errors.Internal, "Unexpected return value.");
             // Debug
             if (log.isDebugEnabled())
                 log.debug("executeQuery successful in " + (System.currentTimeMillis() - start) + " ms");
             // Return number of affected records
-            success();
             return rs;
 
-        } catch (SQLException e) 
-        {   // SQL Query failed!
-            log.error("execute query exception! sql = " + sqlCmd);
-            error(DBErrors.QueryFailed, e);
-            return null; 
-        }
+        } catch (SQLException sqle) 
+        {   // Error
+            EmpireException exptn = SQL2EmpireException(DBErrors.QueryFailed, sqle); 
+            log.error("Error executing query {0}. Message is {0}", sqlCmd, exptn.getMessage());
+            throw exptn;
+        } 
     }
 
     /**
@@ -1143,20 +1085,20 @@ public abstract class DBDatabase extends
      * 
      * @return true if successful
      */
-    public boolean commit(Connection conn)
+    public void commit(Connection conn)
     {
         try
         {   // Check argument
             if (conn==null)
-                return error(Errors.InvalidArg, null, "conn");
+                throw new EmpireException(Errors.InvalidArg, null, "conn");
             // Commit
             if (conn.getAutoCommit()==false)
                 conn.commit();
-            return true;
-        } catch (SQLException sqle) 
-        { 
+            // Done
+            return;
+        } catch (SQLException sqle) { 
             // Commit failed!
-            return error(sqle);
+            throw new EmpireException(sqle);
         }
     }
 
@@ -1169,19 +1111,20 @@ public abstract class DBDatabase extends
      * 
      * @return true if successful
      */
-    public boolean rollback(Connection conn)
+    public void rollback(Connection conn)
     {
         try
-        {   // Check arguement
+        {   // Check argument
             if (conn==null)
-                return error(Errors.InvalidArg, null, "conn");
-            // Rollback
+                throw new EmpireException(Errors.InvalidArg, null, "conn");
+            // rollback
             log.info("Database rollback issued!");
             conn.rollback();
-            return success();
-        } catch (SQLException sqle) 
-        {
-            return error(sqle);
+            // Done
+            return;
+        } catch (SQLException sqle) { 
+            // Commit failed!
+            throw new EmpireException(sqle);
         }
     }
 
@@ -1198,10 +1141,10 @@ public abstract class DBDatabase extends
             if (stmt != null)
                 stmt.close();
             // done
-            success();
-        } catch (SQLException sqle)
-        {
-            error(sqle);
+            return;
+        } catch (SQLException sqle) { 
+            // Commit failed!
+            throw new EmpireException(sqle);
         }
     }
 
@@ -1217,7 +1160,7 @@ public abstract class DBDatabase extends
         { 	// check ResultSet
             if (rset == null)
                 return; // nothing to do
-            // close Resutlset
+            // close Resultset
             Statement stmt = rset.getStatement();
             rset.close();
             // check Statement
@@ -1225,11 +1168,11 @@ public abstract class DBDatabase extends
                 return;
             // close Statement
             stmt.close();
-            success();
-            
-        } catch (SQLException sqle) 
-        {
-            error(sqle);
+            // done
+            return;
+        } catch (SQLException sqle) { 
+            // Commit failed!
+            throw new EmpireException(sqle);
         }
     }
 

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java Tue Jul 19 16:53:34 2011
@@ -33,6 +33,7 @@ import java.util.HashSet;
 import java.util.Set;
 import java.util.UUID;
 
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.DateUtils;
 import org.apache.empire.commons.ErrorObject;
 import org.apache.empire.commons.Errors;
@@ -223,11 +224,9 @@ public abstract class DBDatabaseDriver e
                 if (log.isInfoEnabled())
                     log.info("Sequence {} incremented to {}.", SeqName, seqValue);
                 return new Long(seqValue);
-            } catch (Exception e) 
-            {
-                log.error("getNextValue exception: " + e.toString());
-                error(e);
-                return null;
+            } catch (SQLException e) {
+                // throw exception
+                throw SQL2EmpireException(e);
             } finally
             { // Cleanup
                 db.closeStatement(stmt);
@@ -380,8 +379,7 @@ public abstract class DBDatabaseDriver e
             return (type==DataType.DATE ? DateUtils.getDateOnly(ts) : ts);
         }
         // Other types
-        error(Errors.NotSupported, "getColumnAutoValue() for "+type);
-        return null;
+        throw new EmpireException(Errors.NotSupported, "getColumnAutoValue() for "+type);
     }
 
     /**
@@ -569,8 +567,7 @@ public abstract class DBDatabaseDriver e
 	            stmt = conn.createStatement(type, ResultSet.CONCUR_READ_ONLY);
 	            return stmt.executeQuery(sqlCmd);
 	        }
-        } catch(SQLException e) 
-        {
+        } catch(SQLException e) {
             // close statement (if not null)
             close(stmt);
             throw e;
@@ -679,9 +676,9 @@ public abstract class DBDatabaseDriver e
     /**
      * Called when a database is opened
      */
-    protected boolean attachDatabase(DBDatabase db, Connection conn)
+    protected void attachDatabase(DBDatabase db, Connection conn)
     {
-        return success();
+        // Override to implement attaching behaviour
     }
 
     /**
@@ -701,9 +698,9 @@ public abstract class DBDatabaseDriver e
      * 
      * @return true if it is consistent with the description
      */
-    public boolean checkDatabase(DBDatabase db, String owner, Connection conn)
+    public void checkDatabase(DBDatabase db, String owner, Connection conn)
     {
-    	return error(Errors.NotImplemented, "checkDatabase");
+        throw new EmpireException(Errors.NotImplemented, "checkDatabase");
     }
     
     /**
@@ -715,9 +712,9 @@ public abstract class DBDatabaseDriver e
      * 
      * @return true on succes 
      */
-    public boolean getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
+    public void getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
     {
-        return error(Errors.NotSupported, "getDDLScript");
+        throw new EmpireException(Errors.NotSupported, "getDDLScript");
     }
     
     /**

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBErrors.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBErrors.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBErrors.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBErrors.java Tue Jul 19 16:53:34 2011
@@ -24,49 +24,31 @@ import org.apache.empire.commons.ErrorTy
  * This class contains the definition of database specific errors.
  * <P>
  * For more informations see {@link org.apache.empire.commons.Errors}
- *
+ * 
  */
 public class DBErrors
 {
     // Database
-    public static final ErrorType DatabaseNotOpen        = new ErrorType("error.db.databasenotopen",
-                                                                         "the database has not been opened.");
-    public static final ErrorType ConnecitonInvalid      = new ErrorType("error.db.connectioninvalid",
-                                                                         "the database connection is not valid");
-    public static final ErrorType SQLException           = new ErrorType("error.db.sqlexception",
-                                                                         "The database operation failed. Native error is {0}.");
-    public static final ErrorType ObjectNotFound         = new ErrorType("error.db.objectnotfound",
-                                                                         "an object of type {0} named {1} does not exists or is inaccessible.");
-    public static final ErrorType ObjectCreationFailed   = new ErrorType("error.db.objectcreationfailed",
-                                                                         "error creating the {0} of name {1}.");
-    public static final ErrorType NoPrimaryKey           = new ErrorType("error.db.noprimarykey",
-                                                                         "No primary key is defined for {0}");
+    public static final ErrorType DatabaseNotOpen        = new ErrorType("error.db.databasenotopen",    "the database has not been opened.");
+    public static final ErrorType ConnecitonInvalid      = new ErrorType("error.db.connectioninvalid",  "the database connection is not valid");
+    public static final ErrorType SQLException           = new ErrorType("error.db.sqlexception",       "The database operation failed. Native error is {0}.");
+    public static final ErrorType ObjectNotFound         = new ErrorType("error.db.objectnotfound",     "an object of type {0} named {1} does not exists or is inaccessible.");
+    public static final ErrorType ObjectCreationFailed   = new ErrorType("error.db.objectcreationfailed",   "error creating the {0} of name {1}.");
+    public static final ErrorType NoPrimaryKey           = new ErrorType("error.db.noprimarykey",       "No primary key is defined for {0}");
     // Query errors
-    public static final ErrorType QueryFailed            = new ErrorType("error.db.queryfailed",
-                                                                         "The query failed. Native error is {0}.");
-    public static final ErrorType QueryNoResult          = new ErrorType("error.db.querynoresult",
-                                                                         "No records found for query {0}");
+    public static final ErrorType QueryFailed            = new ErrorType("error.db.queryfailed",        "The query failed. Native error is {0}.");
+    public static final ErrorType QueryNoResult          = new ErrorType("error.db.querynoresult",      "No records found for query {0}");
     // Record errors
-    public static final ErrorType RecordInvalidKey       = new ErrorType("error.db.recordinvalidkey", "Invalid record key {0}");
-    public static final ErrorType RecordNotFound         = new ErrorType("error.db.recordnotfound",
-                                                                         "The record {0} does not exist. It might have been deleted by another user.");
-    public static final ErrorType RecordUpdateFailed     = new ErrorType("error.db.recordupatefailed",
-                                                                         "Updating the record {0} failed. It might have been changed or deleted by another user.");
-    public static final ErrorType RecordUpdateInvalid    = new ErrorType("error.db.recordupateinvalid",
-                                                                         "Updating the record {0} failed. The given record key is ambiguous.");
-    public static final ErrorType RecordDeleteFailed     = new ErrorType("error.db.recorddeletefailed",
-                                                                         "Deleting the record {0} failed. The record might have been deleted already by another user.");
+    public static final ErrorType RecordInvalidKey       = new ErrorType("error.db.recordinvalidkey",   "Invalid record key {0}");
+    public static final ErrorType RecordNotFound         = new ErrorType("error.db.recordnotfound",     "The record {0} does not exist. It might have been deleted by another user.");
+    public static final ErrorType RecordUpdateFailed     = new ErrorType("error.db.recordupatefailed",  "Updating the record {0} failed. It might have been changed or deleted by another user.");
+    public static final ErrorType RecordUpdateInvalid    = new ErrorType("error.db.recordupateinvalid", "Updating the record {0} failed. The given record key is ambiguous.");
+    public static final ErrorType RecordDeleteFailed     = new ErrorType("error.db.recorddeletefailed", "Deleting the record {0} failed. The record might have been deleted already by another user.");
     // Field errors
-    public static final ErrorType FieldIsReadOnly        = new ErrorType("error.db.fieldisreadonly",
-                                                                         "The field {0} is read only.");
-    public static final ErrorType FieldValueTooLong      = new ErrorType("error.db.fieldvaluetoolong",
-                                                                         "The value supplied for field {0} is too long. The maximum number of characters is {1}.");
-    public static final ErrorType FieldNotNull           = new ErrorType("error.db.fieldnotnull",
-                                                                         "The value for field {0} must not be null.");
-    public static final ErrorType FieldNotNumeric        = new ErrorType("error.db.fieldnotnumeric",
-                                                                         "The field value supplied for field {0} is not numeric.");
-    public static final ErrorType FieldInvalidDateFormat = new ErrorType("error.db.fieldinvaliddateformat",
-                                                                         "The date supplied for field {0} is not valid.");
-    public static final ErrorType FieldInvalidValue      = new ErrorType("error.db.fieldinvalidvalue",
-                                                                         "The value for field {0} is invalid.");
+    public static final ErrorType FieldIsReadOnly        = new ErrorType("error.db.fieldisreadonly",    "The field {0} is read only.");
+    public static final ErrorType FieldValueTooLong      = new ErrorType("error.db.fieldvaluetoolong",  "The value supplied for field {0} is too long. The maximum number of characters is {1}.");
+    public static final ErrorType FieldNotNull           = new ErrorType("error.db.fieldnotnull",       "The value for field {0} must not be null.");
+    public static final ErrorType FieldNotNumeric        = new ErrorType("error.db.fieldnotnumeric",    "The field value supplied for field {0} is not numeric.");
+    public static final ErrorType FieldInvalidDateFormat = new ErrorType("error.db.fieldinvaliddateformat", "The date supplied for field {0} is not valid.");
+    public static final ErrorType FieldInvalidValue      = new ErrorType("error.db.fieldinvalidvalue",  "The value for field {0} is invalid.");
 }

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBObject.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBObject.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBObject.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBObject.java Tue Jul 19 16:53:34 2011
@@ -19,14 +19,15 @@
 package org.apache.empire.db;
 
 // java.sql
+import java.io.Serializable;
+import java.sql.SQLException;
+
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.ErrorObject;
 import org.apache.empire.commons.ErrorType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.Serializable;
-import java.sql.SQLException;
-
 
 /**
  * Base class for all database related objects.
@@ -47,7 +48,7 @@ public abstract class DBObject extends E
      * @return the database object
      */
     public abstract DBDatabase getDatabase();
-
+    
     /**
      * Sets the current error from an SQL Exception.
      * 
@@ -56,15 +57,15 @@ public abstract class DBObject extends E
      *            
      * @return the return value is always false
      */
-    protected boolean error(ErrorType type, SQLException sqle)
+    protected EmpireException SQL2EmpireException(ErrorType type, SQLException sqle)
     {
         log.error("Database operation failed.", sqle);
         // converts a database error message to a human readable error message.
         DBDatabase db = getDatabase();
         if (db!=null && db.getDriver()!=null)
-            return error(type, db.getDriver().extractErrorMessage(sqle));
+            return new EmpireException(type, new Object[] { db.getDriver().extractErrorMessage(sqle) }, sqle);
         // Set the error Message
-        return error(type, sqle.getMessage());
+        return new EmpireException(type, sqle.getMessage());
     }
 
     /**
@@ -74,9 +75,9 @@ public abstract class DBObject extends E
      *            
      * @return the return value is always false
      */
-    protected boolean error(SQLException sqle)
-    { // converts a database error message to a human readable error message.
-        return error(DBErrors.SQLException, sqle);
+    protected EmpireException SQL2EmpireException(SQLException sqle)
+    {   // converts a database error message to a human readable error message.
+        return SQL2EmpireException(DBErrors.SQLException, sqle);
     }
 
 }
\ No newline at end of file