cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp AbstractEsqlConnection.java AbstractEsqlQuery.java JdbcEsqlQuery.java MysqlEsqlQuery.java OracleEsqlQuery.java PervasiveEsqlQuery.java PostgresEsqlQuery.java PostgresOldEsqlQuery.java SybaseEsqlQuery.java
Date Thu, 20 Mar 2003 21:51:44 GMT
tcurdt      2003/03/20 13:51:44

  Modified:    src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp
                        AbstractEsqlQuery.java JdbcEsqlQuery.java
                        MysqlEsqlQuery.java OracleEsqlQuery.java
                        PervasiveEsqlQuery.java PostgresEsqlQuery.java
                        PostgresOldEsqlQuery.java SybaseEsqlQuery.java
  Added:       src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp
                        AbstractEsqlConnection.java
  Log:
  EsqlConnection no longer implements java.sql.Connection.
  No jvm dependency any more!!
  
  Revision  Changes    Path
  1.3       +2 -2      cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/AbstractEsqlQuery.java
  
  Index: AbstractEsqlQuery.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/AbstractEsqlQuery.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractEsqlQuery.java	11 Mar 2003 17:44:19 -0000	1.2
  +++ AbstractEsqlQuery.java	20 Mar 2003 21:51:43 -0000	1.3
  @@ -94,7 +94,7 @@
        * @param connection
        * @param query - The SQL query string
        */
  -    protected AbstractEsqlQuery(AbstractEsqlConnection connection, String query) {
  +    protected AbstractEsqlQuery(Connection connection, String query) {
           this.connection = connection;
           this.query = query;
       }
  
  
  
  1.3       +3 -2      cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/JdbcEsqlQuery.java
  
  Index: JdbcEsqlQuery.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/JdbcEsqlQuery.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JdbcEsqlQuery.java	11 Mar 2003 17:44:19 -0000	1.2
  +++ JdbcEsqlQuery.java	20 Mar 2003 21:51:43 -0000	1.3
  @@ -55,6 +55,7 @@
   import java.sql.SQLException;
   import java.sql.ResultSet;
   import java.sql.CallableStatement;
  +import java.sql.Connection;
   
   /**
    * This EsqlQuery only uses the standard JDBC API approaches.
  @@ -68,7 +69,7 @@
    */
   final public class JdbcEsqlQuery extends AbstractEsqlQuery {
   
  -    public JdbcEsqlQuery(AbstractEsqlConnection connection, String query) {
  +    public JdbcEsqlQuery(Connection connection, String query) {
           super(connection, query);
       }
   
  
  
  
  1.3       +3 -2      cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/MysqlEsqlQuery.java
  
  Index: MysqlEsqlQuery.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/MysqlEsqlQuery.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MysqlEsqlQuery.java	11 Mar 2003 17:44:19 -0000	1.2
  +++ MysqlEsqlQuery.java	20 Mar 2003 21:51:43 -0000	1.3
  @@ -55,6 +55,7 @@
   
   import java.sql.SQLException;
   import java.sql.ResultSet;
  +import java.sql.Connection;
   
   /**
    * @author <a href="mailto:tcurdt@apache.org">Torsten Curdt</a>
  @@ -62,7 +63,7 @@
    */
   final public class MysqlEsqlQuery extends AbstractEsqlQuery {
   
  -    public MysqlEsqlQuery(AbstractEsqlConnection connection, String query) {
  +    public MysqlEsqlQuery(Connection connection, String query) {
           super(connection, query);
       }
   
  
  
  
  1.3       +3 -2      cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/OracleEsqlQuery.java
  
  Index: OracleEsqlQuery.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/OracleEsqlQuery.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- OracleEsqlQuery.java	11 Mar 2003 17:44:19 -0000	1.2
  +++ OracleEsqlQuery.java	20 Mar 2003 21:51:43 -0000	1.3
  @@ -53,6 +53,7 @@
   
   import java.sql.ResultSet;
   import java.sql.SQLException;
  +import java.sql.Connection;
   
   /**
    * @author <a href="mailto:tcurdt@apache.org">Torsten Curdt</a>
  @@ -60,7 +61,7 @@
    */
   final public class OracleEsqlQuery extends AbstractEsqlQuery {
   
  -    public OracleEsqlQuery(AbstractEsqlConnection connection, String query) {
  +    public OracleEsqlQuery(Connection connection, String query) {
           super(connection, query);
       }
   
  
  
  
  1.3       +3 -2      cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PervasiveEsqlQuery.java
  
  Index: PervasiveEsqlQuery.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PervasiveEsqlQuery.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PervasiveEsqlQuery.java	11 Mar 2003 17:44:19 -0000	1.2
  +++ PervasiveEsqlQuery.java	20 Mar 2003 21:51:43 -0000	1.3
  @@ -55,6 +55,7 @@
   import java.sql.SQLException;
   import java.sql.ResultSet;
   import java.sql.CallableStatement;
  +import java.sql.Connection;
   
   /**
    * Database specific EsqlQuery
  @@ -63,7 +64,7 @@
    */
   final public class PervasiveEsqlQuery extends AbstractEsqlQuery {
   
  -    public PervasiveEsqlQuery(AbstractEsqlConnection connection, String query) {
  +    public PervasiveEsqlQuery(Connection connection, String query) {
           super(connection, query);
       }
   
  
  
  
  1.3       +3 -2      cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PostgresEsqlQuery.java
  
  Index: PostgresEsqlQuery.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PostgresEsqlQuery.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PostgresEsqlQuery.java	11 Mar 2003 17:44:19 -0000	1.2
  +++ PostgresEsqlQuery.java	20 Mar 2003 21:51:43 -0000	1.3
  @@ -53,6 +53,7 @@
   
   import java.sql.SQLException;
   import java.sql.ResultSet;
  +import java.sql.Connection;
   
   /**
    * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  @@ -61,7 +62,7 @@
    */
   final public class PostgresEsqlQuery extends AbstractEsqlQuery {
   
  -    public PostgresEsqlQuery(AbstractEsqlConnection connection, String query) {
  +    public PostgresEsqlQuery(Connection connection, String query) {
           super(connection, query);
       }
   
  
  
  
  1.3       +3 -2      cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PostgresOldEsqlQuery.java
  
  Index: PostgresOldEsqlQuery.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PostgresOldEsqlQuery.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PostgresOldEsqlQuery.java	11 Mar 2003 17:44:19 -0000	1.2
  +++ PostgresOldEsqlQuery.java	20 Mar 2003 21:51:43 -0000	1.3
  @@ -53,6 +53,7 @@
   
   import java.sql.SQLException;
   import java.sql.ResultSet;
  +import java.sql.Connection;
   
   /**
    * @author <a href="mailto:tcurdt@apache.org">Torsten Curdt</a>
  @@ -60,7 +61,7 @@
    */
   final public class PostgresOldEsqlQuery extends AbstractEsqlQuery {
   
  -    public PostgresOldEsqlQuery(AbstractEsqlConnection connection, String query) {
  +    public PostgresOldEsqlQuery(Connection connection, String query) {
           super(connection, query);
       }
   
  
  
  
  1.3       +3 -2      cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/SybaseEsqlQuery.java
  
  Index: SybaseEsqlQuery.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/SybaseEsqlQuery.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SybaseEsqlQuery.java	11 Mar 2003 17:44:19 -0000	1.2
  +++ SybaseEsqlQuery.java	20 Mar 2003 21:51:43 -0000	1.3
  @@ -55,6 +55,7 @@
   import java.sql.PreparedStatement;
   import java.sql.ResultSet;
   import java.sql.CallableStatement;
  +import java.sql.Connection;
   
   /**
    * Database specific EsqlQuery
  @@ -63,7 +64,7 @@
    */
   final public class SybaseEsqlQuery extends AbstractEsqlQuery {
   
  -    public SybaseEsqlQuery(AbstractEsqlConnection connection, String query) {
  +    public SybaseEsqlQuery(Connection connection, String query) {
           super(connection, query);
       }
   
  
  
  
  1.1                  cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/AbstractEsqlConnection.java
  
  Index: AbstractEsqlConnection.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.language.markup.xsp;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  
  import java.sql.Connection;
  import java.util.Properties;
  import java.sql.SQLException;
  import java.sql.DatabaseMetaData;
  
  /**
   * @author <a href="mailto:tcurdt@apache.org">Torsten Curdt</a>
   * @version CVS $Id: AbstractEsqlConnection.java,v 1.1 2003/03/20 21:51:43 tcurdt Exp $
   */
  public abstract class AbstractEsqlConnection extends AbstractLogEnabled {
  
      private String url = null;
      private Properties properties = null;
      private boolean multipleResults = false;
  
      protected AbstractEsqlConnection() {
      }
  
      protected abstract Connection getConnection() throws SQLException;
  
  
      /**
       * It appears that some commercial DBMSs like Oracle and Informix
       * are broken in that they don't follow the JDBC standard and
       * calls to getUpdateCount after getMoreResults result either in
       * an exception (Informix) or return the same value (i.e. not -1) (Oracle).
       * In addition, this feature is only useful with stored procedures.
       * Hence we disable it per default.
       **/
      public void setMultipleResults(String value) {
          this.multipleResults = ("true".equalsIgnoreCase(value) || "yes".equalsIgnoreCase(value));
      }
  
      public boolean getMultipleResults() {
          return (this.multipleResults);
      }
  
  
  
      public Properties getProperties() {
          return (properties);
      }
  
      public void setProperty(final String name, final Object value) {
          if (properties == null) properties = new Properties();
          properties.put(name, value);
      }
  
      public void setUser(String user) {
          setProperty("user", user);
      }
  
      public void setPassword(String password) {
          setProperty("password", password);
      }
  
      public void setAutoCommit(final boolean autocommit) throws SQLException {
          getConnection().setAutoCommit(autocommit);
      }
  
      public boolean getAutoCommit() throws SQLException {
          return (getConnection().getAutoCommit());
      }
  
      public String getURL() throws SQLException {
          if (this.url == null) {
              this.url = getConnection().getMetaData().getURL();
          }
          return (this.url);
      }
  
      public void setURL(final String url) {
          this.url = url;
      }
  
  
      public DatabaseMetaData getMetaData() throws SQLException {
          return (getConnection().getMetaData());
      }
  
      public void commit() throws SQLException {
          getConnection().commit();
      }
  
      public void rollback() throws SQLException {
          getConnection().rollback();
      }
  
      public void close() throws SQLException {
          getConnection().close();
      }
  
  
  
      /**
       * Factory method for creating an EsqlQuery object. If type is set to
       * "" or "auto" it will try to find type from the JDBC connection URL.
       * If this does not succeed the generic JDBC type will be assumed.
       * (This type does not work for some databases like mssql though)
       *
       * @param type {sybase|postgresql|mysql|oracle|jdbc}
       * @param queryString
       * @return implementation of the AbstractEsqlQuery
       * @throws SQLException
       */
      public AbstractEsqlQuery createQuery(final String type, final String queryString) throws
SQLException {
          AbstractEsqlQuery query;
          if ("".equals(type) || "auto".equalsIgnoreCase(type)) {
              String url = getURL();
  
              if (url.startsWith("jdbc:postgresql:")) {
                  query = new PostgresEsqlQuery(getConnection(),queryString);
              }
              else if (url.startsWith("jdbc:mysql:")) {
                  query = new MysqlEsqlQuery(getConnection(),queryString);
              }
              else if (url.startsWith("jdbc:sybase:")) {
                  query = new SybaseEsqlQuery(getConnection(),queryString);
              }
              else if (url.startsWith("jdbc:oracle:")) {
                  query = new OracleEsqlQuery(getConnection(),queryString);
              }
              else if (url.startsWith("jdbc:pervasive:")) {
                  query = new PervasiveEsqlQuery(getConnection(),queryString);
              }
              else {
                  getLogger().warn("Cannot guess database type from jdbc url: " + String.valueOf(url)
+" - Defaulting to JDBC");
                  query = new JdbcEsqlQuery(getConnection(),queryString);
              }
          }
          else if ("sybase".equalsIgnoreCase(type)) {
              query = new SybaseEsqlQuery(getConnection(),queryString);
          }
          else if ("postgresql".equalsIgnoreCase(type)) {
              query = new PostgresEsqlQuery(getConnection(),queryString);
          }
          else if ("postgresql-old".equalsIgnoreCase(type)) {
              query = new PostgresOldEsqlQuery(getConnection(),queryString);
          }
          else if ("mysql".equalsIgnoreCase(type)) {
              query = new MysqlEsqlQuery(getConnection(),queryString);
          }
          else if ("oracle".equalsIgnoreCase(type)) {
              query = new OracleEsqlQuery(getConnection(),queryString);
          }
          else if ("pervasive".equalsIgnoreCase(type)) {
              query = new PervasiveEsqlQuery(getConnection(),queryString);
          }
          else if ("jdbc".equalsIgnoreCase(type)) {
              query = new JdbcEsqlQuery(getConnection(),queryString);
          }
          else {
              getLogger().error("Unknown database type: " + String.valueOf(type));
              throw new SQLException("Unknown database type: " + String.valueOf(type));
          }
          setupLogger(query);
          return(query);
      }
  }
  
  
  
  

Mime
View raw message