avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport WriteReply.java UpdateReply.java
Date Fri, 23 Nov 2001 12:40:21 GMT
hammant     01/11/23 04:40:21

  Modified:    apps/db/src/java/org/apache/avalon/db/basic/actions
                        BasicSelect.java
               apps/db/src/java/org/apache/avalon/db/basic/data
                        BasicTable.java
               apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql
                        BasicLXSQLCreateIndexHandler.java
                        BasicLXSQLCreateTableHandler.java
                        BasicLXSQLCreateViewHandler.java
                        BasicLXSQLDeleteRowsHandler.java
                        BasicLXSQLDropIndexHandler.java
                        BasicLXSQLDropTableHandler.java
                        BasicLXSQLDropViewHandler.java
                        BasicLXSQLInsertRowsHandler.java
                        BasicLXSQLUpdateRowsHandler.java
               apps/db/src/java/org/apache/avalon/db/data/impl
                        AbstractQueryable.java
               apps/db/src/java/org/apache/avalon/db/driver
                        AvalonDBStatement.java
               apps/db/src/java/org/apache/avalon/db/test Tester.java
  Added:       apps/db/src/java/org/apache/avalon/db/transport
                        WriteReply.java
  Removed:     apps/db/src/java/org/apache/avalon/db/transport
                        UpdateReply.java
  Log:
  UpdateReply renamed to WriteReply, more test output
  
  Revision  Changes    Path
  1.32      +9 -10     jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicSelect.java
  
  Index: BasicSelect.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicSelect.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- BasicSelect.java	2001/11/23 08:21:53	1.31
  +++ BasicSelect.java	2001/11/23 12:40:20	1.32
  @@ -15,17 +15,16 @@
   import org.apache.avalon.db.results.Columns;
   import org.apache.avalon.db.basic.data.BasicTable;
   import org.apache.avalon.db.basic.data.BasicRow;
  -import org.apache.avalon.db.basic.results.BasicColumns;
   import org.apache.avalon.db.basic.results.BasicRowSet;
  +import org.apache.avalon.db.basic.results.BasicColumns;
   import org.apache.avalon.db.data.Column;
  -
  +import org.apache.avalon.db.data.impl.AbstractQueryable;
   import org.apache.avalon.framework.logger.LogEnabled;
  -
   import org.w3c.dom.Element;
   import org.w3c.dom.NodeList;
   
  -import java.util.Iterator;
   import java.util.Vector;
  +import java.util.Iterator;
   
   /**
    * This class represents the BasicSelect
  @@ -42,7 +41,7 @@
       private boolean mPrepared;
       private boolean mWithParams;
       private int mParamCount;
  -    private BasicTable mTable = null;
  +    private AbstractQueryable mQueryable;
       private Column[] mCols;
       private String[] mTablenames;
       private SimpleWhereClause mSimpleWhereClause;
  @@ -76,8 +75,8 @@
   
           for(int i=0; i < mTablenames.length; i++) {
               /** get the table, should be only one */
  -            mTable = (BasicTable)mDatabasePersistor.getQueryable(mTablenames[i]);
  -            Iterator it = mTable.getRows().iterator();
  +            mQueryable = (AbstractQueryable) mDatabasePersistor.getQueryable(mTablenames[i]);
  +            Iterator it = mQueryable.getRows().iterator();
               while(it.hasNext()) {
                   /** iterate rows and select only the needed cols */
                   BasicRow row = (BasicRow)it.next();
  @@ -178,15 +177,15 @@
       }
   
       protected Column[] convertColumns(String[] columnNames) {
  -        BasicTable table = (BasicTable)mDatabasePersistor.getQueryable(mTablenames[0]);
  +        AbstractQueryable queryable = (AbstractQueryable) mDatabasePersistor.getQueryable(mTablenames[0]);
           //TODO * could be with other contrived columns
           if (columnNames[0].equals("*")) {
  -            return table.getColumns();
  +            return queryable.getColumns();
           }
   
           Column[] columns = new Column[columnNames.length];
           for ( int i = 0; i < columnNames.length; i++ ) {
  -            columns[i] = table.getColumn(columnNames[i], false);
  +            columns[i] = queryable.getColumn(columnNames[i], false);
           }
           return columns;
       }
  
  
  
  1.10      +0 -32     jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/data/BasicTable.java
  
  Index: BasicTable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/data/BasicTable.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BasicTable.java	2001/11/19 10:59:09	1.9
  +++ BasicTable.java	2001/11/23 12:40:20	1.10
  @@ -16,36 +16,4 @@
       public BasicTable(String name, Column[] columns) {
           super(name, columns);
       }
  -
  -    public int getColumnIndex(String columnName) {
  -        for (int x = 0; x < mColumns.length; x++) {
  -            if (mColumns[x].getColumnName().equals(columnName)) {
  -                return x;
  -            }
  -        }
  -        throw new RuntimeException("Column " + columnName + " not found");
  -    }
  -
  -
  -    public Column getColumn(String columnName) {
  -        return this.getColumn(columnName, true);
  -    }
  -    public Column getColumn(String columnName, boolean throwExcpt) {
  -        Column col = null;
  -
  -        for (int x = 0; x < mColumns.length; x++) {
  -            if (mColumns[x].getColumnName().equals(columnName)) {
  -                col = mColumns[x];
  -            }
  -        }
  -        if(col != null) {
  -            return col;
  -        } else {
  -            if (throwExcpt) {
  -                throw new RuntimeException("Column " + columnName + " not found");
  -            } else {
  -                return null;
  -            }
  -        }
  -    }
   }
  
  
  
  1.8       +3 -3      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLCreateIndexHandler.java
  
  Index: BasicLXSQLCreateIndexHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLCreateIndexHandler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BasicLXSQLCreateIndexHandler.java	2001/11/19 17:36:06	1.7
  +++ BasicLXSQLCreateIndexHandler.java	2001/11/23 12:40:20	1.8
  @@ -14,7 +14,7 @@
   import org.apache.avalon.db.transport.Reply;
   import org.apache.avalon.db.transport.Request;
   import org.apache.avalon.db.transport.CreateIndexRequest;
  -import org.apache.avalon.db.transport.UpdateReply;
  +import org.apache.avalon.db.transport.WriteReply;
   import org.apache.avalon.db.actions.ActionException;
   import org.apache.avalon.db.actions.CreateIndex;
   import org.apache.avalon.db.server.DBRequestContext;
  @@ -28,7 +28,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    */
   public class BasicLXSQLCreateIndexHandler extends BasicLXSQLHandler {
   
  @@ -72,7 +72,7 @@
               mParser.initializeAction(action);
               action.execute();
   
  -            return new UpdateReply(action.getRecordCount());
  +            return new WriteReply(action.getRecordCount());
           }
       }
   }
  
  
  
  1.6       +3 -3      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLCreateTableHandler.java
  
  Index: BasicLXSQLCreateTableHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLCreateTableHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BasicLXSQLCreateTableHandler.java	2001/11/19 17:36:06	1.5
  +++ BasicLXSQLCreateTableHandler.java	2001/11/23 12:40:20	1.6
  @@ -16,7 +16,7 @@
   import org.apache.avalon.db.transport.Reply;
   import org.apache.avalon.db.transport.Request;
   import org.apache.avalon.db.transport.CreateTableRequest;
  -import org.apache.avalon.db.transport.UpdateReply;
  +import org.apache.avalon.db.transport.WriteReply;
   import org.apache.avalon.db.actions.ActionException;
   import org.apache.avalon.db.actions.CreateTable;
   import org.apache.avalon.db.data.Column;
  @@ -32,7 +32,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public class BasicLXSQLCreateTableHandler extends BasicLXSQLQueryableHandler {
   
  @@ -85,7 +85,7 @@
               mParser.initializeAction(action);
               action.execute();
   
  -            return new UpdateReply(action.getRecordCount());
  +            return new WriteReply(action.getRecordCount());
           }
       }
   }
  
  
  
  1.7       +3 -3      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLCreateViewHandler.java
  
  Index: BasicLXSQLCreateViewHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLCreateViewHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BasicLXSQLCreateViewHandler.java	2001/11/20 16:44:11	1.6
  +++ BasicLXSQLCreateViewHandler.java	2001/11/23 12:40:20	1.7
  @@ -18,7 +18,7 @@
   import org.apache.avalon.db.transport.Reply;
   import org.apache.avalon.db.transport.Request;
   import org.apache.avalon.db.transport.CreateViewRequest;
  -import org.apache.avalon.db.transport.UpdateReply;
  +import org.apache.avalon.db.transport.WriteReply;
   import org.apache.avalon.db.actions.ActionException;
   import org.apache.avalon.db.actions.CreateView;
   import org.apache.avalon.db.data.Column;
  @@ -34,7 +34,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   public class BasicLXSQLCreateViewHandler extends BasicLXSQLQueryableHandler {
   
  @@ -92,7 +92,7 @@
               mParser.initializeAction(action);
               action.execute();
   
  -            return new UpdateReply(action.getRecordCount());
  +            return new WriteReply(action.getRecordCount());
           }
       }
   }
  
  
  
  1.6       +3 -3      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLDeleteRowsHandler.java
  
  Index: BasicLXSQLDeleteRowsHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLDeleteRowsHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BasicLXSQLDeleteRowsHandler.java	2001/11/20 16:44:11	1.5
  +++ BasicLXSQLDeleteRowsHandler.java	2001/11/23 12:40:20	1.6
  @@ -17,7 +17,7 @@
   import org.apache.avalon.db.transport.Reply;
   import org.apache.avalon.db.transport.Request;
   import org.apache.avalon.db.transport.DeleteRowsRequest;
  -import org.apache.avalon.db.transport.UpdateReply;
  +import org.apache.avalon.db.transport.WriteReply;
   import org.apache.avalon.db.actions.ActionException;
   import org.apache.avalon.db.actions.DeleteRows;
   import org.apache.avalon.db.data.Queryable;
  @@ -33,7 +33,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public class BasicLXSQLDeleteRowsHandler extends BasicLXSQLHandler {
   
  @@ -78,6 +78,6 @@
           mParser.initializeAction(action);
           action.execute();
   
  -        return new UpdateReply(action.getRecordCount());
  +        return new WriteReply(action.getRecordCount());
       }
   }
  
  
  
  1.3       +3 -3      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLDropIndexHandler.java
  
  Index: BasicLXSQLDropIndexHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLDropIndexHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BasicLXSQLDropIndexHandler.java	2001/11/19 09:03:02	1.2
  +++ BasicLXSQLDropIndexHandler.java	2001/11/23 12:40:20	1.3
  @@ -15,7 +15,7 @@
   import org.apache.avalon.db.actions.DropIndex;
   import org.apache.avalon.db.transport.Request;
   import org.apache.avalon.db.transport.Reply;
  -import org.apache.avalon.db.transport.UpdateReply;
  +import org.apache.avalon.db.transport.WriteReply;
   import org.apache.avalon.db.transport.DropIndexRequest;
   import org.apache.avalon.db.server.DBRequestContext;
   import org.w3c.dom.Document;
  @@ -26,7 +26,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class BasicLXSQLDropIndexHandler extends BasicLXSQLQueryableHandler {
   
  @@ -65,7 +65,7 @@
   
           mParser.initializeAction(action);
           action.execute();
  -        return new UpdateReply(action.getRecordCount());
  +        return new WriteReply(action.getRecordCount());
   
       }
   }
  
  
  
  1.3       +3 -3      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLDropTableHandler.java
  
  Index: BasicLXSQLDropTableHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLDropTableHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BasicLXSQLDropTableHandler.java	2001/11/19 09:03:02	1.2
  +++ BasicLXSQLDropTableHandler.java	2001/11/23 12:40:20	1.3
  @@ -16,7 +16,7 @@
   import org.apache.avalon.db.transport.Request;
   import org.apache.avalon.db.transport.Reply;
   import org.apache.avalon.db.transport.DropTableRequest;
  -import org.apache.avalon.db.transport.UpdateReply;
  +import org.apache.avalon.db.transport.WriteReply;
   import org.apache.avalon.db.server.DBRequestContext;
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
  @@ -26,7 +26,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class BasicLXSQLDropTableHandler extends BasicLXSQLQueryableHandler {
   
  @@ -65,6 +65,6 @@
   
           mParser.initializeAction(action);
           action.execute();
  -        return new UpdateReply(action.getRecordCount());
  +        return new WriteReply(action.getRecordCount());
       }
   }
  
  
  
  1.3       +3 -3      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLDropViewHandler.java
  
  Index: BasicLXSQLDropViewHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLDropViewHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BasicLXSQLDropViewHandler.java	2001/11/19 09:03:02	1.2
  +++ BasicLXSQLDropViewHandler.java	2001/11/23 12:40:20	1.3
  @@ -15,7 +15,7 @@
   import org.apache.avalon.db.actions.DropView;
   import org.apache.avalon.db.transport.Request;
   import org.apache.avalon.db.transport.Reply;
  -import org.apache.avalon.db.transport.UpdateReply;
  +import org.apache.avalon.db.transport.WriteReply;
   import org.apache.avalon.db.transport.DropViewRequest;
   import org.apache.avalon.db.server.DBRequestContext;
   import org.w3c.dom.Document;
  @@ -26,7 +26,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class BasicLXSQLDropViewHandler extends BasicLXSQLQueryableHandler {
   
  @@ -65,7 +65,7 @@
   
           mParser.initializeAction(action);
           action.execute();
  -        return new UpdateReply(action.getRecordCount());
  +        return new WriteReply(action.getRecordCount());
   
       }
   }
  
  
  
  1.5       +3 -3      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLInsertRowsHandler.java
  
  Index: BasicLXSQLInsertRowsHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLInsertRowsHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BasicLXSQLInsertRowsHandler.java	2001/11/19 09:03:02	1.4
  +++ BasicLXSQLInsertRowsHandler.java	2001/11/23 12:40:20	1.5
  @@ -18,7 +18,7 @@
   import org.apache.avalon.db.transport.Reply;
   import org.apache.avalon.db.transport.Request;
   import org.apache.avalon.db.transport.InsertRowsRequest;
  -import org.apache.avalon.db.transport.UpdateReply;
  +import org.apache.avalon.db.transport.WriteReply;
   import org.apache.avalon.db.actions.ActionException;
   import org.apache.avalon.db.actions.InsertRows;
   import org.apache.avalon.db.data.Queryable;
  @@ -40,7 +40,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public class BasicLXSQLInsertRowsHandler extends BasicLXSQLHandler {
   
  @@ -98,7 +98,7 @@
           mParser.initializeAction(action);
           action.execute();
   
  -        return new UpdateReply(action.getRecordCount());
  +        return new WriteReply(action.getRecordCount());
       }
   
       private Vector processSubRowsNodes(BasicTable table, NodeList subRowsNodes) throws
ValidationException {
  
  
  
  1.6       +3 -3      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLUpdateRowsHandler.java
  
  Index: BasicLXSQLUpdateRowsHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/BasicLXSQLUpdateRowsHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BasicLXSQLUpdateRowsHandler.java	2001/11/23 08:21:54	1.5
  +++ BasicLXSQLUpdateRowsHandler.java	2001/11/23 12:40:20	1.6
  @@ -16,7 +16,7 @@
   import org.apache.avalon.db.services.DatabasePersistor;
   import org.apache.avalon.db.transport.Reply;
   import org.apache.avalon.db.transport.Request;
  -import org.apache.avalon.db.transport.UpdateReply;
  +import org.apache.avalon.db.transport.WriteReply;
   import org.apache.avalon.db.transport.UpdateRowsRequest;
   import org.apache.avalon.db.actions.ActionException;
   import org.apache.avalon.db.actions.UpdateRows;
  @@ -34,7 +34,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public class BasicLXSQLUpdateRowsHandler extends BasicLXSQLHandler {
   
  @@ -87,7 +87,7 @@
           mParser.initializeAction(action);
           action.execute();
   
  -        return new UpdateReply(action.getRecordCount());
  +        return new WriteReply(action.getRecordCount());
       }
   
      private String getMatchingInstructions(Element updatesElement) throws ActionException
{
  
  
  
  1.9       +36 -1     jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/AbstractQueryable.java
  
  Index: AbstractQueryable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/AbstractQueryable.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractQueryable.java	2001/11/19 10:20:25	1.8
  +++ AbstractQueryable.java	2001/11/23 12:40:20	1.9
  @@ -27,7 +27,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.8 $
  + * @version $Revision: 1.9 $
    */
   public abstract class AbstractQueryable extends AbstractNameable implements Queryable {
   
  @@ -194,4 +194,39 @@
               }
           }
       }
  +
  +    public int getColumnIndex(String columnName) {
  +        for (int x = 0; x < mColumns.length; x++) {
  +            if (mColumns[x].getColumnName().equals(columnName)) {
  +                return x;
  +            }
  +        }
  +        throw new RuntimeException("Column " + columnName + " not found");
  +    }
  +
  +
  +    public Column getColumn(String columnName) {
  +        return this.getColumn(columnName, true);
  +    }
  +
  +    public Column getColumn(String columnName, boolean throwExcpt) {
  +        Column col = null;
  +
  +        for (int x = 0; x < mColumns.length; x++) {
  +            if (mColumns[x].getColumnName().equals(columnName)) {
  +                col = mColumns[x];
  +            }
  +        }
  +        if(col != null) {
  +            return col;
  +        } else {
  +            if (throwExcpt) {
  +                throw new RuntimeException("Column " + columnName + " not found");
  +            } else {
  +                return null;
  +            }
  +        }
  +    }
  +
  +
   }
  
  
  
  1.9       +5 -5      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/AvalonDBStatement.java
  
  Index: AvalonDBStatement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/AvalonDBStatement.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AvalonDBStatement.java	2001/11/16 06:14:59	1.8
  +++ AvalonDBStatement.java	2001/11/23 12:40:20	1.9
  @@ -14,7 +14,7 @@
   import org.apache.avalon.db.transport.ResultSetReply;
   import org.apache.avalon.db.transport.Request;
   import org.apache.avalon.db.transport.WriteRequest;
  -import org.apache.avalon.db.transport.UpdateReply;
  +import org.apache.avalon.db.transport.WriteReply;
   import org.apache.avalon.db.transport.CloseRequest;
   import org.apache.avalon.db.transport.InsertRowsRequest;
   import org.apache.avalon.db.transport.UpdateRowsRequest;
  @@ -33,7 +33,7 @@
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
    * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">g-froehlich@gmx.de</a>
  - * @version $Revision: 1.8 $
  + * @version $Revision: 1.9 $
    */
   public class AvalonDBStatement extends AbstractDriver implements Statement {
   
  @@ -96,7 +96,7 @@
           }
           Reply reply = mAvalonDBConnection.sendRequest(request);
           handleSQLException(reply);
  -        UpdateReply updateReply = (UpdateReply) reply;
  +        WriteReply updateReply = (WriteReply) reply;
           mUpdateCount = updateReply.getRowCount();
           return mUpdateCount;
       }
  @@ -348,8 +348,8 @@
               mRowSet = rsReply.getRowSet();
               mResultSet = new AvalonDBResultSet(mAvalonDBConnection,mRowSet);
               return true;
  -        } else if (reply instanceof UpdateReply) {
  -            mUpdateCount = ((UpdateReply) reply).getRowCount();
  +        } else if (reply instanceof WriteReply) {
  +            mUpdateCount = ((WriteReply) reply).getRowCount();
               return false;
           }
           throw new SQLException("Unknown internal reply type");
  
  
  
  1.26      +38 -14    jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/test/Tester.java
  
  Index: Tester.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/test/Tester.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Tester.java	2001/11/19 18:00:02	1.25
  +++ Tester.java	2001/11/23 12:40:21	1.26
  @@ -36,6 +36,7 @@
                                "</create-table>";
   
           st.executeUpdate(createTable);
  +        System.out.println("  Update Count : " + st.getUpdateCount());
           st.close();
   
           System.err.println("INSERT");
  @@ -65,6 +66,7 @@
                                  "</rows>" +
                                "</insert-into>";
           st.executeUpdate(insertInto);
  +        System.out.println("  Update Count : " + st.getUpdateCount());
           st.close();
   
           System.err.println("SELECT 1");
  @@ -84,9 +86,9 @@
           ResultSet rs = st.executeQuery(select);
           st.close();
           while (rs.next()) {
  -            System.out.println("Result col0 = " + rs.getString(0));
  -            System.out.println("Result col1 = " + rs.getString(1));
  +            System.out.println("  Row:" + rs.getString(0) + ", " + rs.getString(1));
           }
  +        rs.close();
   
           System.err.println("VIEW 1");
           st = mCon.createStatement();
  @@ -105,8 +107,25 @@
                         "</create-view>";
   
           st.execute(view);
  +        System.out.println("  Update Count : " + st.getUpdateCount());
           st.close();
   
  +        System.err.println("SELECT 2 (on view)");
  +        st = mCon.createStatement();
  +        select = "<simple-select>" +
  +                          "<columns><column name=\"forename\"/>" +
  +                          "<column name=\"surname\"/></columns>" +
  +                           //"<columns>*</columns>" +
  +                           "<from><table name=\"FlintstonesView\"/></from>"
+
  +                        "</simple-select>";
  +        rs = st.executeQuery(select);
  +        st.close();
  +        while (rs.next()) {
  +            System.out.println("  Row:" + rs.getString(0) + ", " + rs.getString(1));
  +        }
  +        rs.close();
  +
  +
           System.err.println("INDEX 1");
           st = mCon.createStatement();
           String index = "<create-index name=\"FlintstonesIdx\" table=\"Flintstones\">"
+
  @@ -115,8 +134,8 @@
                               "<column name=\"surname\"/>" +
                            "</columns>" +
                         "</create-index>";
  -
           st.execute(index);
  +        System.out.println("  Update Count : " + st.getUpdateCount());
           st.close();
   
   
  @@ -129,6 +148,8 @@
                             "</where>" +
                         "</delete-rows>";
           st.execute(delt);
  +        System.out.println("  Update Count : " + st.getUpdateCount());
  +        st.close();
   
           System.err.println("UPDATE 1");
           st = mCon.createStatement();
  @@ -141,21 +162,24 @@
                             "</where>" +
                         "</update-rows>";
           st.execute(updt);
  -
  -
  +        System.out.println("  Update Count : " + st.getUpdateCount());
  +        st.close();
   
  -        /*
  -        System.err.println("SELECT 2"); //TODO
  +        System.err.println("SELECT 3");
           st = mCon.createStatement();
  -        String select2 = "<simple-select>" +
  -                            "<columns>*</columns>" +
  -                            "<from><table name=\"Flintstones\"/></from>"
+
  -                            "<where><and-block/></where>" +
  +        select = "<simple-select>" +
  +                          "<columns><column name=\"forename\"/>" +
  +                          "<column name=\"surname\"/></columns>" +
  +                           //"<columns>*</columns>" +
  +                           "<from><table name=\"Flintstones\"/></from>"
+
                           "</simple-select>";
  -
  -        st.executeQuery(select2);
  +        rs = st.executeQuery(select);
           st.close();
  -        */
  +        while (rs.next()) {
  +            System.out.println("  Row:" + rs.getString(0) + ", " + rs.getString(1));
  +        }
  +        rs.close();
  +
   
       }
   
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/WriteReply.java
  
  Index: WriteReply.java
  ===================================================================
  
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.avalon.db.transport;
  
  
  
  import org.apache.avalon.db.actions.ActionException;
  
  
  /**
   * Class WriteReply
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class WriteReply extends Reply {
  
      private int mRowCount;
  
      /**
       * Constructor WriteReply
       *
       *
       * @param rc
       *
       */
      public WriteReply(int rc) {
          super(UPDATEREPLY);
          mRowCount = rc;
      }
  
      public int getRowCount() {
          return mRowCount;
      }
  
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message