db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: db-torque/src/generator/src/java/org/apache/torque/task TorqueDataDumpTask.java
Date Tue, 28 Oct 2003 15:16:51 GMT
mpoeschl    2003/10/28 07:16:51

  Modified:    src/generator/src/java/org/apache/torque/task
                        TorqueDataDumpTask.java
  Log:
  use standard jdbc instead of village.
  the generator no longer depends on village
  
  Revision  Changes    Path
  1.5       +24 -27    db-torque/src/generator/src/java/org/apache/torque/task/TorqueDataDumpTask.java
  
  Index: TorqueDataDumpTask.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/task/TorqueDataDumpTask.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TorqueDataDumpTask.java	28 Oct 2003 09:23:08 -0000	1.4
  +++ TorqueDataDumpTask.java	28 Oct 2003 15:16:51 -0000	1.5
  @@ -54,24 +54,26 @@
    * <http://www.apache.org/>.
    */
   
  -import java.util.Iterator;
  -import java.util.NoSuchElementException;
   import java.sql.Connection;
   import java.sql.DriverManager;
  +import java.sql.ResultSet;
   import java.sql.SQLException;
   import java.sql.Statement;
  +import java.util.Iterator;
  +import java.util.NoSuchElementException;
  +
   import org.apache.tools.ant.Project;
  +
   import org.apache.velocity.context.Context;
   
  -import com.workingdogs.village.QueryDataSet;
  -import com.workingdogs.village.Record;
   
   /**
    * An extended Texen task used for dumping data from db into XML
    *
    * @author <a href="mailto:fedor.karpelevitch@home.com">Fedor Karpelevitch</a>
  - * @author <a href="jvanzyl@zenplex.com">Jason van Zyl</a>
  - * @author <a href="dlr@finemaltcoding.com">Daniel Rall</a>
  + * @author <a href="mailto:jvanzyl@zenplex.com">Jason van Zyl</a>
  + * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
  + * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class TorqueDataDumpTask extends TorqueDataModelTask
  @@ -267,22 +269,14 @@
        *  <li>the abovenamed iterator which iterates over the table</li>
        *  <li>getter for the table fields</li>
        *  </ul>
  -     *
  -     * @author  fedor
        */
       public class TableTool implements Iterator
       {
           /** querydataset */
  -        private QueryDataSet qds;
  -        /** is empty */
  -        private boolean isEmpty;
  -        /** current index */
  -        private int curIndex = -1;
  -        /** current record */
  -        private Record curRec = null;
  +        private ResultSet rs;
   
           /**
  -         *  Constructor for the TableTool object
  +         * Constructor for the TableTool object
            */
           public TableTool()
           {
  @@ -294,11 +288,9 @@
            * @param qds Description of Parameter
            * @throws Exception Problem using database record set cursor.
            */
  -        protected TableTool(QueryDataSet qds) throws Exception
  +        protected TableTool(ResultSet rs) throws Exception
           {
  -            this.qds = qds;
  -            this.qds.fetchRecords();
  -            this.isEmpty = !(qds.size() > 0);
  +            this.rs = rs;
           }
   
           /**
  @@ -313,8 +305,8 @@
               log("Fetching data for table " + tableName, Project.MSG_INFO);
               // Set Statement object in associated TorqueDataDump
               // instance
  -            return new TableTool
  -                (new QueryDataSet(conn, "SELECT * FROM " + tableName));
  +            return new TableTool(conn.createStatement()
  +                    .executeQuery("SELECT * FROM " + tableName));
           }
   
           /**
  @@ -326,7 +318,12 @@
           {
               try
               {
  -                return ((this.curIndex < this.qds.size() - 1) && (!isEmpty));
  +                // TODO optimize this
  +                // i tried to use rs.isLast() but this returns wrong results
  +                // for empty tables :-(
  +                boolean validRow = rs.next();
  +                rs.previous();
  +                return validRow;
               }
               catch (Exception se)
               {
  @@ -346,8 +343,8 @@
           {
               try
               {
  -                System.err.print(".");
  -                this.curRec = this.qds.getRecord(++curIndex);
  +                System.out.print(".");
  +                rs.next();
               }
               catch (Exception se)
               {
  @@ -368,7 +365,7 @@
           {
               try
               {
  -                return (this.curRec.getValue(columnName).asString());
  +                return (rs.getString(columnName));
               }
               catch (Exception se)
               {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message