empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1041673 - in /incubator/empire-db/trunk: empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/ empire-db/src/main/java/org/apache/empire/db/
Date Fri, 03 Dec 2010 02:02:39 GMT
Author: doebele
Date: Fri Dec  3 02:02:38 2010
New Revision: 1041673

URL: http://svn.apache.org/viewvc?rev=1041673&view=rev
Log:
EMPIREDB-91
Futher improvements and fixed reorder issue

Modified:
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java?rev=1041673&r1=1041672&r2=1041673&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
Fri Dec  3 02:02:38 2010
@@ -46,7 +46,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.apache.empire.samples.db.advanced.SampleAdvDB.EmployeeInfoView;
 
 
 public class SampleAdvApp 
@@ -427,8 +426,8 @@ public class SampleAdvApp 
         // create a command
         DBCommand cmd = db.createCommand();
         // Create cmd parameters
-        DBCommandParam genderParam = cmd.addCmdParam(); // Gender ('M' or 'F')
         DBCommandParam curDepParam = cmd.addCmdParam(); // Current Department
+        DBCommandParam genderParam = cmd.addCmdParam(); // Gender ('M' or 'F')
         // Define the query
         cmd.select(T_EMP.C_FULLNAME);
         cmd.join  (T_EMP.C_EMPLOYEE_ID, db.V_EMPLOYEE_INFO.C_EMPLOYEE_ID);

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java?rev=1041673&r1=1041672&r2=1041673&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java
Fri Dec  3 02:02:38 2010
@@ -97,10 +97,10 @@ public class DBCombinedCmd extends DBCom
     * @return the list of parameter values for a prepared statement 
     */
    @Override
-   public Object[] getCmdParams()
+   public Object[] getCmdParamValues()
    {
-       Object[] leftParams  = left.getCmdParams();
-       Object[] rightParams = right.getCmdParams();
+       Object[] leftParams  = left.getCmdParamValues();
+       Object[] rightParams = right.getCmdParamValues();
        // Check
        if (leftParams==null)
            return rightParams;

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java?rev=1041673&r1=1041672&r2=1041673&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
Fri Dec  3 02:02:38 2010
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Set;
 import java.util.Vector;
 
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.Errors;
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.expr.compare.DBCompareColExpr;
@@ -46,18 +47,47 @@ public abstract class DBCommand extends 
     public static final class DBCommandParam extends DBExpr
     {
         protected DBCommand cmd;
-        protected int index; 
+        protected DataType  type;
+        protected Object    value;
         
-        protected DBCommandParam(DBCommand cmd, int index)
+        protected DBCommandParam(DBCommand cmd, DataType type, Object value)
         {
-            this.cmd   = cmd;
-            this.index = index;
+            this.cmd = cmd;
+            this.type = type;
+            this.value = getCmdParamValue(value);
+        }
+        
+        protected Object getCmdParamValue(Object value)
+        {        
+            switch (type)
+            {
+                case BLOB:
+                    if (value == null)
+                        return null;
+                    if (value instanceof DBBlobData)
+                        return value;
+                    if (value instanceof byte[])
+                        return new DBBlobData((byte[])value);
+                    // create a blob data
+                    return new DBBlobData(value.toString());
+                case CLOB:
+                    if (value == null)
+                        return null;
+                    if (value instanceof DBClobData)
+                        return value;
+                    // create a clob data
+                    return new DBClobData(value.toString());
+                default:
+                    return value;
+            }
         }
         
         @Override
         public void addSQL(StringBuilder buf, long context)
         {
             buf.append("?"); //$NON-NLS-1$
+            // Move to current usage position
+            cmd.notifyParamUsage(this);
         }
         
         /**
@@ -77,12 +107,12 @@ public abstract class DBCommand extends 
         
         public Object getValue()
         {
-            return cmd.cmdParams.get(index);
+            return value;
         }
         
         public void setValue(Object value)
         {
-            cmd.cmdParams.set(index, value);
+            this.value = getCmdParamValue(value);
         }
     }
     
@@ -96,7 +126,8 @@ public abstract class DBCommand extends 
     protected List<DBCompareExpr>    having         = null;
     protected List<DBColumnExpr>     groupBy        = null;
     // Parameters for prepared Statements
-    protected Vector<Object>         cmdParams      = null;
+    protected Vector<DBCommandParam> cmdParams      = null;
+    protected int                    paramUsageCount= 0;
     // Database
     private DBDatabase               db;
 
@@ -110,6 +141,28 @@ public abstract class DBCommand extends 
         this.db = db;
     }
 
+    private void resetParamUsage()
+    {
+        paramUsageCount = 0;
+    }
+    
+    private synchronized void notifyParamUsage(DBCommandParam param)
+    {
+        int index = cmdParams.indexOf(param);
+        if (index < paramUsageCount)
+        {   // Error: parameter probably used twice in statement!
+            String msg = "A parameter may only be used once in a command.";
+            error(Errors.Internal, msg);
+            throw new EmpireException(this);
+        }
+        if (index > paramUsageCount)
+        {   // Correct parameter order
+            cmdParams.remove(index);
+            cmdParams.insertElementAt(param, paramUsageCount);
+        }
+        paramUsageCount++;
+    }
+    
     /**
      * Creates a clone of this class.
      */
@@ -229,31 +282,6 @@ public abstract class DBCommand extends 
         DataType dt = col.getDataType();
         return ( dt==DataType.BLOB || dt==DataType.CLOB );
     }
-    
-    protected Object getCmdParamValue(DBColumn col, Object value)
-    {        
-        switch (col.getDataType())
-        {
-            case BLOB:
-                if (value == null)
-                    return null;
-                if (value instanceof DBBlobData)
-                    return value;
-                if (value instanceof byte[])
-                	return new DBBlobData((byte[])value);
-                // create a blob data
-                return new DBBlobData(value.toString());
-            case CLOB:
-                if (value == null)
-                    return null;
-                if (value instanceof DBClobData)
-                    return value;
-                // create a clob data
-                return new DBClobData(value.toString());
-            default:
-                return value;
-        }
-    }
 
     /**
      * Inserts DBSetExpr objects to the Vector 'set'.
@@ -271,9 +299,10 @@ public abstract class DBCommand extends 
             { // Overwrite existing value
                 if (useCmdParam(expr.column) && (expr.value instanceof DBExpr) ==
false
                     && chk.value instanceof DBCommandParam)
-                { // replace parameter
-                    int index = ((DBCommandParam) chk.value).index;
-                    this.setCmdParam(index, getCmdParamValue(expr.column, expr.value));
+                {   // replace parameter value
+                    // int index = ((DBCommandParam) chk.value).index;
+                    // this.setCmdParam(index, getCmdParamValue(expr.column, expr.value));
+                    ((DBCommandParam)chk.value).setValue(expr.value);
                 } 
                 else
                 { // replace value
@@ -284,7 +313,7 @@ public abstract class DBCommand extends 
         }
         // Replace with parameter 
         if (useCmdParam(expr.column) && (expr.value instanceof DBExpr)==false)
-            expr.value = addCmdParam(getCmdParamValue(expr.column, expr.value));
+            expr.value = addCmdParam(expr.column.getDataType(), expr.value);
         // new Value!
         set.add(expr);
     }
@@ -309,45 +338,64 @@ public abstract class DBCommand extends 
     }
 
     /**
-     * Sets a object to in the list of Parameters.
+     * Adds an command parameter which will be used in a prepared statement.
+     * The command parameter returned may be used to alter the value.
      * 
-     * @param index the parameter index
-     * @param item the parameter value
+     * @param type the data type of the parameter
+     * @param value the initial parameter value 
      * 
-     * @return true on succes
+     * @return the command parameter object 
      */
-    public boolean setCmdParam(int index, Object item)
+    public DBCommandParam addCmdParam(DataType type, Object value)
     {
-        if (index<0 || index>999)
-            return error(Errors.InvalidArg, index, "index");
         if (cmdParams==null)
-            cmdParams= new Vector<Object>();
-        if (index>=cmdParams.size())
-        {	// extend the parameter list
-            cmdParams.setSize(index+1);
-        }
-        cmdParams.set(index, item);
-        return success();
+            cmdParams= new Vector<DBCommandParam>();
+        // Adds the parameter 
+        DBCommandParam param = new DBCommandParam(this, type, value);
+        if (cmdParams.add(param)==false)
+            return null; // unknown error
+        // Creates a Parameter expression
+        return param;
     }
 
     /**
      * Adds an command parameter which will be used in a prepared statement.
-     * The command parameter returned may be used to alter the value.
-     * 
+     * The initial value of the command parameter is null but can be modified using the setValue
method.
+     *  
+     * @param colExpr the column expression for which to create the parameter
      * @param value the initial parameter value 
      * 
      * @return the command parameter object 
      */
-    public DBCommandParam addCmdParam(Object value)
+    public final DBCommandParam addCmdParam(DBColumnExpr colExpr, Object value)
     {
-        if (cmdParams==null)
-            cmdParams= new Vector<Object>();
-        // Adds the parameter 
-        int index = cmdParams.size(); 
-        if (cmdParams.add(value)==false)
-            return null; // unknown error
-        // Creates a Parameter expression
-        return new DBCommandParam(this, index);
+        return addCmdParam(colExpr.getDataType(), value);
+    }
+
+    /**
+     * Adds an command parameter which will be used in a prepared statement.
+     * The initial value of the command parameter is null but can be modified using the setValue
method.
+     *  
+     * @param colExpr the column expression for which to create the parameter
+     * 
+     * @return the command parameter object 
+     */
+    public final DBCommandParam addCmdParam(DBColumnExpr colExpr)
+    {
+        return addCmdParam(colExpr.getDataType(), null);
+    }
+    
+    /**
+     * Adds an command parameter which will be used in a prepared statement.
+     * The initial value of the command parameter is null but can be modified using the setValue
method.
+     *  
+     * @param type the data type of the parameter
+     * 
+     * @return the command parameter object 
+     */
+    public final DBCommandParam addCmdParam(DataType type)
+    {
+        return addCmdParam(type, null);
     }
 
     /**
@@ -358,7 +406,7 @@ public abstract class DBCommand extends 
      */
     public final DBCommandParam addCmdParam()
     {
-        return addCmdParam(null);
+        return addCmdParam(DataType.UNKNOWN, null);
     }
 
     /**
@@ -622,8 +670,9 @@ public abstract class DBCommand extends 
     }
     
     @Override
-    public boolean getSelect(StringBuilder buf)
+    public synchronized boolean getSelect(StringBuilder buf)
     {
+        resetParamUsage();
         if (select == null)
             return error(Errors.ObjectNotValid, getClass().getName()); // invalid!
         // Prepares statement
@@ -834,12 +883,16 @@ public abstract class DBCommand extends 
      * @return the list of parameter values for a prepared statement 
      */
     @Override
-    public Object[] getCmdParams()
+    public Object[] getCmdParamValues()
     {
-        if (cmdParams==null)
+        if (cmdParams==null || cmdParams.size()==0)
             return null;
         // return Params
-        return cmdParams.toArray();
+        Object[] values = new Object[cmdParams.size()];
+        for (int i=0; i<values.length; i++)
+            values[i]=cmdParams.get(i).getValue();
+        // values
+        return values;
     }
 
     /**
@@ -847,8 +900,9 @@ public abstract class DBCommand extends 
      * 
      * @return the update SQL-Command
      */
-    public String getUpdate()
+    public synchronized String getUpdate()
     {
+        resetParamUsage();
         if (set == null)
             return null;
         StringBuilder buf = new StringBuilder("UPDATE ");
@@ -874,8 +928,9 @@ public abstract class DBCommand extends 
      * @return the insert SQL-Command
      */
     // get Insert
-    public String getInsert()
+    public synchronized String getInsert()
     {
+        resetParamUsage();
         if (set==null || set.get(0)==null)
             return null;
         StringBuilder buf = new StringBuilder("INSERT INTO ");
@@ -932,8 +987,9 @@ public abstract class DBCommand extends 
      * 
      * @return the delete SQL-Command
      */
-    public String getDelete(DBTable table)
+    public synchronized String getDelete(DBTable table)
     {
+        resetParamUsage();
         StringBuilder buf = new StringBuilder("DELETE FROM ");
         table.addSQL(buf, CTX_FULLNAME);
         // Set Expressions

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java?rev=1041673&r1=1041672&r2=1041673&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
Fri Dec  3 02:02:38 2010
@@ -294,7 +294,7 @@ public abstract class DBCommandExpr exte
     /** Constructs an empty DBCommandExpr object */
     public DBCommandExpr()
     {
-        // Default Construtor
+        // Default Constructor
     }
 
     // get Select SQL
@@ -304,7 +304,7 @@ public abstract class DBCommandExpr exte
 
     public abstract DBColumnExpr[] getSelectExprList();
     
-    public abstract Object[] getCmdParams();
+    public abstract Object[] getCmdParamValues();
 
     public DBColumnExpr getCmdColumn(DBColumnExpr col)
     {

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java?rev=1041673&r1=1041672&r2=1041673&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
Fri Dec  3 02:02:38 2010
@@ -383,19 +383,20 @@ public abstract class DBDatabaseDriver e
 	{
         for (int i=0; i<sqlParams.length; i++)
         {
-            if(sqlParams[i] instanceof DBBlobData)
+            Object value = sqlParams[i];
+            if (value instanceof DBBlobData)
             {
                 // handling for blobs
-                DBBlobData blobData = (DBBlobData)sqlParams[i];
+                DBBlobData blobData = (DBBlobData)value;
                 pstmt.setBinaryStream(i + 1, blobData.getInputStream(), blobData.getLength());
                 // log
                 if (log.isDebugEnabled())
                     log.debug("Setting statement param " + String.valueOf(i) + " to BLOB
data");
             }
-            else if(sqlParams[i] instanceof DBClobData)
+            else if(value instanceof DBClobData)
             {
                 // handling for clobs
-                DBClobData clobData = (DBClobData)sqlParams[i];
+                DBClobData clobData = (DBClobData)value;
                 pstmt.setCharacterStream(i + 1, clobData.getReader(), clobData.getLength());
                 // log
                 if (log.isDebugEnabled())
@@ -403,10 +404,10 @@ public abstract class DBDatabaseDriver e
             }
             else
             {   // simple parameter value 
-                pstmt.setObject(i + 1, sqlParams[i]);
+                pstmt.setObject(i + 1, value);
                 // log
                 if (log.isDebugEnabled())
-                    log.debug("Setting statement param " + String.valueOf(i) + " to '" +
String.valueOf(sqlParams[i])+ "'");
+                    log.debug("Setting statement param " + String.valueOf(i) + " to '" +
String.valueOf(value)+ "'");
             }
         }
 	}

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java?rev=1041673&r1=1041672&r2=1041673&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java Fri
Dec  3 02:02:38 2010
@@ -355,7 +355,12 @@ public class DBQuery extends DBRowSet
             return error(DBErrors.RecordInvalidKey, key);
         // Select
         for (int i = 0; i < keyColumns.length; i++)
-            cmd.where(keyColumns[i].is(key[i]));
+        {   // Set key column constraint
+            Object value = key[i];
+            if (db.isPreparedStatementsEnabled())
+                value = cmd.addCmdParam(keyColumns[i], value);
+            cmd.where(keyColumns[i].is(value));
+        }    
         // Read Record
         if (!readRecord(rec, cmd, conn))
         { // Record not found
@@ -464,8 +469,15 @@ public class DBQuery extends DBRowSet
             }
             // Add Restrictions
             for (i = 0; i < keyColumns.length; i++)
+            {
                 if (keyColumns[i].getRowSet() == table)
-                    upd.where(keyColumns[i].is(keys[i]));
+                {   // Set key column constraint
+                    Object value = keys[i];
+                    if (db.isPreparedStatementsEnabled())
+                        value = upd.addCmdParam(keyColumns[i], value);
+                    upd.where(keyColumns[i].is(value));
+                }
+            }    
 
             // Set Update Timestamp
             int timestampIndex = -1;
@@ -479,7 +491,11 @@ public class DBQuery extends DBRowSet
                     timestampValue = db.getUpdateTimestamp(conn); 
                     Object lastTS = fields[timestampIndex];
                     if (ObjectUtils.isEmpty(lastTS)==false)
+                    {   // set timestamp constraint
+                        if (db.isPreparedStatementsEnabled())
+                            lastTS = upd.addCmdParam(tsColumn, lastTS);
                         upd.where(tsColumn.is(lastTS));
+                    }    
                     // Set new Timestamp
                     upd.set(tsColumn.to(timestampValue));
                 }
@@ -490,7 +506,7 @@ public class DBQuery extends DBRowSet
             }
             
             // Execute SQL
-            int affected = db.executeSQL(upd.getUpdate(), upd.getCmdParams(), conn);
+            int affected = db.executeSQL(upd.getUpdate(), upd.getCmdParamValues(), conn);
             if (affected <= 0)
             {   // Error
                 if (affected == 0)
@@ -524,7 +540,7 @@ public class DBQuery extends DBRowSet
      * Adds join restrictions to the supplied command object.
      */
     protected boolean addJoinRestriction(DBCommand upd, DBColumn updCol, DBColumn keyCol,
DBColumn[] keyColumns, DBRecord rec)
-    {   // Find key for forein field
+    {   // Find key for foreign field
         Object rowsetData = rec.getRowSetData();
         for (int i = 0; i < keyColumns.length; i++)
             if (keyColumns[i]==keyCol && rowsetData!=null)
@@ -532,7 +548,7 @@ public class DBQuery extends DBRowSet
                 upd.where(updCol.is(((Object[]) rowsetData)[i]));
                 return true;
             }
-        // Not found, what about the reocrd
+        // Not found, what about the record
         int index = this.getColumnIndex(updCol);
         if (index<0)
             index = this.getColumnIndex(keyCol);

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java?rev=1041673&r1=1041672&r2=1041673&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java Fri
Dec  3 02:02:38 2010
@@ -410,7 +410,7 @@ public class DBReader extends DBRecordDa
         String sqlCmd = cmd.getSelect();
         // Create Statement
         db = cmd.getDatabase();
-        rset = db.executeQuery(sqlCmd, cmd.getCmdParams(), scrollable, conn);
+        rset = db.executeQuery(sqlCmd, cmd.getCmdParamValues(), scrollable, conn);
         if (rset==null)
             return error(db);
         // successfully opened

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java?rev=1041673&r1=1041672&r2=1041673&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java Fri
Dec  3 02:02:38 2010
@@ -516,7 +516,12 @@ public abstract class DBRowSet extends D
         DBCommand cmd = db.createCommand();
         cmd.select(columns);
         for (int i = 0; i < key.length; i++)
-            cmd.where(keyColumns[i].is(key[i]));
+        {   // Set key column constraint
+            Object value = key[i];
+            if (db.isPreparedStatementsEnabled())
+                value = cmd.addCmdParam(keyColumns[i], value);
+            cmd.where(keyColumns[i].is(value));
+        }    
         // Read Record
         if (!readRecord(rec, cmd, conn))
         {   // Record not found
@@ -618,14 +623,22 @@ public abstract class DBRowSet extends D
                         { // Requires a primary key
                             log.warn("updateRecord: " + name + " primary has been modified!");
                         }
+                        // set pk constraint
+                        if (db.isPreparedStatementsEnabled())
+                            value = cmd.addCmdParam(col, value);
                         cmd.where(col.is(value));
                     } 
                     else if (timestampColumn == col)
-                    { // Check the update Time Stamp
-                    	if (empty==false)
+                    {   // Check the update-timestamp
+                    	if (empty==false) 
+                    	{   // set timestamp constraint
+                            if (db.isPreparedStatementsEnabled())
+                                value = cmd.addCmdParam(col, value);
 	                        cmd.where(col.is(value));
-                    	else if (log.isDebugEnabled())
+                    	}    
+                    	else if (log.isDebugEnabled()) {
                     		log.debug("updateRecord has no value for timestamp column. Concurrent
changes will not be detected.");
+                    	}	
                         cmd.set(col.to(timestamp));
                     } 
                     else if (modified && value!=ObjectUtils.NO_VALUE)
@@ -698,7 +711,7 @@ public abstract class DBRowSet extends D
             return success();
         }
         // Perform action
-        int affected = db.executeSQL(sql, cmd.getCmdParams(), conn, setGenKey);
+        int affected = db.executeSQL(sql, cmd.getCmdParamValues(), conn, setGenKey);
         if (affected < 0)
         { // Update Failed
             return error(db);



Mime
View raw message