cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/transformation SQLTransformer.java
Date Fri, 03 Aug 2001 11:16:23 GMT
dims        01/08/03 04:16:23

  Modified:    src/org/apache/cocoon/transformation Tag: cocoon_20_branch
                        SQLTransformer.java
  Log:
  Patch from "Ignacio J. Ortega" <nacho@siapi.es>
  for "Making SQLTransformer with Interbase 1.6 JDBC Drivers"
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.5.2.6   +48 -18    xml-cocoon2/src/org/apache/cocoon/transformation/SQLTransformer.java
  
  Index: SQLTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/SQLTransformer.java,v
  retrieving revision 1.5.2.5
  retrieving revision 1.5.2.6
  diff -u -r1.5.2.5 -r1.5.2.6
  --- SQLTransformer.java	2001/07/10 14:05:00	1.5.2.5
  +++ SQLTransformer.java	2001/08/03 11:16:22	1.5.2.6
  @@ -30,6 +30,9 @@
   import org.apache.avalon.framework.component.ComponentSelector;
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.parameters.Parameters;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.excalibur.datasource.DataSourceComponent;
   import org.apache.avalon.excalibur.pool.Recyclable;
   import org.apache.cocoon.environment.SourceResolver;
  @@ -54,10 +57,10 @@
    * @author <a href="mailto:giacomo.pati@pwr.ch">Giacomo Pati</a>
    *         (PWR Organisation & Entwicklung)
    * @author <a href="mailto:sven.beauprez@the-ecorp.com">Sven Beauprez</a>
  - * @version CVS $Revision: 1.5.2.5 $ $Date: 2001/07/10 14:05:00 $ $Author: dims $
  + * @version CVS $Revision: 1.5.2.6 $ $Date: 2001/08/03 11:16:22 $ $Author: dims $
    */
   
  -public class SQLTransformer extends AbstractTransformer implements Composable, Recyclable,
Disposable {
  +public class SQLTransformer extends AbstractTransformer implements Composable, Recyclable,
Disposable, Configurable {
   
       /** The SQL namespace **/
       public static final String my_uri = "http://apache.org/cocoon/SQL/2.0";
  @@ -122,6 +125,9 @@
       /** Check if nr of rows need to be written out. **/
       protected String showNrOfRows;
   
  +    /** Is the old-driver turned on? (default is off) */
  +    private boolean oldDriver = false;
  +
       protected ComponentSelector dbSelector = null;
       protected ComponentManager manager;
   
  @@ -155,7 +161,18 @@
       public void dispose() {
           if(this.dbSelector != null) this.manager.release((Component) this.dbSelector);
       }
  -    
  +
  +    /**
  +     * configure
  +     */
  +    public void configure(Configuration conf)throws ConfigurationException {
  +        if (conf != null) {
  +            Configuration child = conf.getChild("old-driver");
  +            this.oldDriver = child.getValueAsBoolean(false);
  +            getLogger().debug("old-driver is " + this.oldDriver + " for " + this);
  +        }
  +    }
  +
       /** BEGIN SitemapComponent methods **/
   
       public void setup(SourceResolver resolver, Map objectModel,
  @@ -168,7 +185,7 @@
           this.current_query_index = -1;
           this.default_properties = new Properties();
           this.current_state = SQLTransformer.STATE_OUTSIDE;
  -    
  +
           this.parameters = parameters;
           this.objectModel = objectModel;
   
  @@ -247,7 +264,7 @@
                     if (index + 1 < queries.size()) {
                         executeQuery(index + 1);
                     }
  -                  this.end(query.row_name);                             
  +                  this.end(query.row_name);
                 }
               } else  {
                 query.serializeStoredProcedure();
  @@ -699,7 +716,7 @@
           protected void setStoredProcedure(boolean flag)  {
               isstoredprocedure = flag;
           }
  -        
  +
           protected boolean isStoredProcedure()  {
             return isstoredprocedure;
           }
  @@ -707,7 +724,7 @@
           protected void setName(String name)  {
             this.name = name;
           }
  -        
  +
           protected String getName()  {
             return name;
           }
  @@ -817,13 +834,21 @@
                       }
                   }
                   if (!isstoredprocedure)  {
  -                    pst = conn.prepareStatement(query,
  -                                                ResultSet.TYPE_SCROLL_INSENSITIVE, 
  -                                                ResultSet.CONCUR_READ_ONLY );
  +                    if (oldDriver) {
  +                        pst = conn.prepareStatement(query);
  +                    } else {
  +                        pst = conn.prepareStatement(query,
  +                                                    ResultSet.TYPE_SCROLL_INSENSITIVE,
  +                                                    ResultSet.CONCUR_READ_ONLY );
  +                    }
                   } else  {
  -                    cst = conn.prepareCall(query,
  -                                           ResultSet.TYPE_SCROLL_INSENSITIVE, 
  -                                           ResultSet.CONCUR_READ_ONLY );
  +                    if (oldDriver) {
  +                        cst = conn.prepareCall(query);
  +                    } else {
  +                        cst = conn.prepareCall(query,
  +                                               ResultSet.TYPE_SCROLL_INSENSITIVE,
  +                                               ResultSet.CONCUR_READ_ONLY );
  +                    }
                       registerOutParameters(cst);
                       pst = cst;
                   }
  @@ -848,9 +873,13 @@
           protected int getNrOfRows() throws SQLException  {
             int nr = 0;
             if (rs!=null) {
  -              rs.last();
  -              nr = rs.getRow();
  -              rs.beforeFirst();
  +              if (oldDriver){
  +                nr=-1;
  +              } else {
  +                rs.last();
  +                nr = rs.getRow();
  +                rs.beforeFirst();
  +              }
             } else  {
               if (outParameters!=null)  {
                 nr=outParameters.size();
  @@ -947,7 +976,7 @@
                           rs.close();
                       }
                       transformer.end((String)outParametersNames.get(counter));
  -                }    
  +                }
                 }catch (SQLException e)  {
                   transformer.getTheLogger().error("Caught a SQLException", e);
                   throw e;
  @@ -955,7 +984,7 @@
                   close();
                 }
             }
  -        
  +
           }
       }
   
  @@ -968,4 +997,5 @@
               this.name = name;
           }
       }
  +
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message