tcurdt 2002/12/04 13:51:38 Modified: src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/java esql.xsl Added: src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp AbstractEsqlConnection.java AbstractEsqlQuery.java Cocoon2EsqlConnection.java JdbcEsqlQuery.java MysqlEsqlQuery.java PostgresEsqlQuery.java SybaseEsqlQuery.java Removed: src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp EsqlConnection.java EsqlConnectionCocoon2.java EsqlQuery.java Log: cleaned up the esql logicsheet and helper classes, put db specific handling into separate classes, renamed some methods to more reasonable names Revision Changes Path 1.1 xml-cocoon2/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-2002 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 [EMAIL PROTECTED] 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 <[EMAIL PROTECTED]>. 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; /** * based on the orginal esql.xsl * @author <a href="mailto:[EMAIL PROTECTED]">Torsten Curdt</a> */ public abstract class AbstractEsqlConnection extends AbstractLogEnabled implements Connection { 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 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 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(this,queryString); } else if (url.startsWith("jdbc:mysql:")) { query = new MysqlEsqlQuery(this,queryString); } else if (url.startsWith("jdbc:sybase:")) { query = new SybaseEsqlQuery(this,queryString); } else { getLogger().warn("Cannot guess database type from jdbc url: " + String.valueOf(url) +" - Defaulting to JDBC"); query = new JdbcEsqlQuery(this,queryString); } } else if ("sybase".equalsIgnoreCase(type)) { query = new SybaseEsqlQuery(this,queryString); } else if ("postgresql".equalsIgnoreCase(type)) { query = new PostgresEsqlQuery(this,queryString); } else if ("mysql".equalsIgnoreCase(type)) { query = new MysqlEsqlQuery(this,queryString); } else if ("jdbc".equalsIgnoreCase(type)) { query = new JdbcEsqlQuery(this,queryString); } else { getLogger().error("Unknown database type: " + String.valueOf(type)); throw new SQLException("Unknown database type: " + String.valueOf(type)); } setupLogger(query); return(query); } /* */ public java.sql.Statement createStatement() throws SQLException { return (getConnection().createStatement()); } public java.sql.Statement createStatement(int i1, int i2) throws SQLException { return (getConnection().createStatement(i1, i2)); } public java.sql.PreparedStatement prepareStatement(String s) throws SQLException { return (getConnection().prepareStatement(s)); } public java.sql.PreparedStatement prepareStatement(String s, int i1, int i2) throws SQLException { return (getConnection().prepareStatement(s, i1, i2)); } public void close() throws SQLException { getConnection().close(); } public void commit() throws SQLException { getConnection().commit(); } public void rollback() throws SQLException { getConnection().rollback(); } public boolean getAutoCommit() throws SQLException { return (getConnection().getAutoCommit()); } public void setAutoCommit(boolean autocommit) throws SQLException { getConnection().setAutoCommit(autocommit); } public void setTransactionIsolation(int i) throws SQLException { getConnection().setTransactionIsolation(i); } public int getTransactionIsolation() throws SQLException { return (getConnection().getTransactionIsolation()); } public String getCatalog() throws SQLException { return (getConnection().getCatalog()); } public java.sql.SQLWarning getWarnings() throws SQLException { return (getConnection().getWarnings()); } public java.util.Map getTypeMap() throws SQLException { return (getConnection().getTypeMap()); } public boolean isClosed() throws SQLException { return (getConnection().isClosed()); } public java.sql.DatabaseMetaData getMetaData() throws SQLException { return (getConnection().getMetaData()); } public void setCatalog(String s) throws SQLException { getConnection().setCatalog(s); } public void setTypeMap(java.util.Map m) throws SQLException { getConnection().setTypeMap(m); } public void setReadOnly(boolean b) throws SQLException { getConnection().setReadOnly(b); } public void clearWarnings() throws SQLException { getConnection().clearWarnings(); } public boolean isReadOnly() throws SQLException { return (getConnection().isReadOnly()); } public String nativeSQL(String s) throws SQLException { return (getConnection().nativeSQL(s)); } public java.sql.CallableStatement prepareCall(String s) throws SQLException { return (getConnection().prepareCall(s)); } public java.sql.CallableStatement prepareCall(String s, int i1, int i2) throws SQLException { return (getConnection().prepareCall(s, i1, i2)); } /* @JDBC3_START@ public void setHoldability(int holdability) throws SQLException { getConnection().setHoldability(holdability); } public int getHoldability() throws SQLException { return getConnection().getHoldability(); } public java.sql.Savepoint setSavepoint() throws SQLException { return getConnection().setSavepoint(); } public java.sql.Savepoint setSavepoint(String savepoint) throws SQLException { return getConnection().setSavepoint(savepoint); } public void rollback(java.sql.Savepoint savepoint) throws SQLException { getConnection().rollback(savepoint); } public void releaseSavepoint(java.sql.Savepoint savepoint) throws SQLException { getConnection().releaseSavepoint(savepoint); } public java.sql.Statement createStatement(int resulSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return getConnection().createStatement(resulSetType, resultSetConcurrency, resultSetHoldability); } public java.sql.PreparedStatement prepareStatement(String sql, int resulSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return getConnection().prepareStatement(sql, resulSetType, resultSetConcurrency, resultSetHoldability); } public java.sql.CallableStatement prepareCall(String sql, int resulSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return getConnection().prepareCall(sql, resulSetType, resultSetConcurrency, resultSetHoldability); } public java.sql.PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { return getConnection().prepareStatement(sql, autoGeneratedKeys); } public java.sql.PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { return getConnection().prepareStatement(sql, columnIndexes); } public java.sql.PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { return getConnection().prepareStatement(sql, columnNames); } @JDBC3_END@ */ } 1.1 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/AbstractEsqlQuery.java Index: AbstractEsqlQuery.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 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 [EMAIL PROTECTED] 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 <[EMAIL PROTECTED]>. 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.sql.PreparedStatement; import java.sql.CallableStatement; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.ArrayList; /** * This one of the esql helper classes * * based on the orginal esql.xsl * @author <a href="mailto:[EMAIL PROTECTED]">Torsten Curdt</a> */ public abstract class AbstractEsqlQuery extends AbstractLogEnabled { private int maxRows = -1; private int skipRows = 0; private int rowCount = -1; private int position = -1; private String query = null; private Connection connection = null; private ResultSetMetaData resultSetMetaData = null; private PreparedStatement preparedStatement = null; private ResultSet resultSet = null; private boolean hasResultSet = false; private boolean keepgoing = true; private int queryResultsCount = 0; private int updateResultsCount = 0; private int updateCount = -2; private ArrayList groups = null; private int groupLevel = -1; private int changeLevel = -1; protected AbstractEsqlQuery(AbstractEsqlConnection connection, String query) { this.connection = connection; this.query = query; } protected AbstractEsqlQuery(final ResultSet resultSet) { this.connection = null; this.query = null; this.resultSet = resultSet; this.hasResultSet = (resultSet != null); } public abstract AbstractEsqlQuery newInstance(final ResultSet resultSet); public Connection getConnection() { return (connection); } public final int getSkipRows() { return (skipRows); } public final void setSkipRows(int i) { skipRows = i; } public final int getMaxRows() { return (maxRows); } public final void setMaxRows(int i) { maxRows = i; } protected final void setPosition(int p) { position = p; } protected final PreparedStatement setPreparedStatement(final PreparedStatement ps) { preparedStatement = ps; return (preparedStatement); } public final ResultSetMetaData getResultSetMetaData() { return (resultSetMetaData); } public final PreparedStatement getPreparedStatement() { return (preparedStatement); } public final CallableStatement getCallableStatement() { return ((CallableStatement) preparedStatement); } public final ResultSet getResultSet() { return (resultSet); } public String getQueryString() throws SQLException { return (query); } public PreparedStatement prepareStatement() throws SQLException { preparedStatement = connection.prepareStatement(getQueryString()); return (preparedStatement); } public CallableStatement prepareCall() throws SQLException { preparedStatement = connection.prepareCall(getQueryString()); return ((CallableStatement) preparedStatement); } public final boolean nextRow() throws SQLException { position++; return (resultSet.next()); } public final int getCurrentRow() { return (position); } public int getRowCount() throws SQLException { if (rowCount < 0) { String lowerQuery = query.toLowerCase(); int from = lowerQuery.indexOf(" from "); int groupby = lowerQuery.indexOf(" group by "); int orderby = lowerQuery.indexOf(" order by "); int min = Math.min(groupby, orderby); String countQuery; if (min > -1) { countQuery = "select count(*)" + String.valueOf(query).substring(from, min); } else { countQuery = "select count(*)" + String.valueOf(query).substring(from); } if (getLogger().isDebugEnabled()) getLogger().debug("executing [" + String.valueOf(query) + "]"); ResultSet rs = preparedStatement.executeQuery(countQuery); try { if (rs.first()) { rowCount = rs.getInt(1); if (getLogger().isDebugEnabled()) getLogger().debug("count = " + rowCount); } } finally { rs.close(); } } return (rowCount); } public void getResultRows() throws SQLException { if (skipRows > 0) { while (resultSet.next()) { position++; if (position >= skipRows) { break; } } } } public final boolean execute(int resultSetFromObject) throws SQLException { if (preparedStatement != null) { hasResultSet = preparedStatement.execute(); if (hasResultSet) { resultSet = (ResultSet) ((CallableStatement) preparedStatement).getObject(resultSetFromObject); queryResultsCount++; return (true); } else { updateResultsCount++; updateCount = preparedStatement.getUpdateCount(); return (updateCount > -1); } } else { return (false); } } public final boolean execute() throws SQLException { if (preparedStatement != null) { hasResultSet = preparedStatement.execute(); if (hasResultSet) { resultSet = preparedStatement.getResultSet(); resultSetMetaData = resultSet.getMetaData(); queryResultsCount++; return (true); } else { updateResultsCount++; updateCount = preparedStatement.getUpdateCount(); return (updateCount > -1); } } else { return (false); } } public final boolean executeQuery() throws SQLException { if (preparedStatement != null) { resultSet = preparedStatement.executeQuery(); if (resultSet != null) { resultSetMetaData = resultSet.getMetaData(); queryResultsCount++; return (true); } else { return (false); } } else { return (false); } } public final boolean getMoreResults() throws SQLException { if (preparedStatement != null) { hasResultSet = preparedStatement.getMoreResults(); if (hasResultSet) { resultSetMetaData = resultSet.getMetaData(); queryResultsCount++; return (true); } else { updateResultsCount++; updateCount = preparedStatement.getUpdateCount(); return (updateCount > -1); } } else { return (false); } } public final boolean hasResultSet() { return (hasResultSet); } public final int getUpdateCount() throws SQLException { return (updateCount); } public final int getQueryResultsCount() { return (queryResultsCount); } public final int getUpdateResultsCount() { return (updateResultsCount); } public final boolean keepGoing() { return (keepgoing); } public final void setKeepGoing(boolean still) { keepgoing = still; } /************************* GROUPING START ***********************************/ public final void incGroupLevel() { groupLevel++; } public final void decGroupLevel() { groupLevel--; } public final boolean groupLevelExists() { return (groups != null && groups.size() >= groupLevel + 1 && groups.get(groupLevel) != null); } public final void setGroupingVar(String key) throws SQLException { if (groups == null) groups = new ArrayList(groupLevel); groups.ensureCapacity(groupLevel); groups.add(groupLevel, new EsqlGroup(key, getResultSet().getObject(key)) ); } public final boolean hasGroupingVarChanged() throws SQLException { if (changeLevel != -1) { if (changeLevel < groupLevel) { return (true); } else { changeLevel = -1; return (true); } } else { boolean result = false; // need to check the complete hierarchy of nested groups for changes for (int i = 0; i <= groupLevel; i++) { Object tmp = getResultSet().getObject(((EsqlGroup) groups.get(i)).var); if (!tmp.equals(((EsqlGroup) groups.get(i)).value)) { ((EsqlGroup) groups.get(i)).value = tmp; result = true; if (changeLevel == -1 && groupLevel != i) changeLevel = i; } } return (result); } } class EsqlGroup { public String var = null; public Object value = null; EsqlGroup(String var, Object value) { this.var = var; this.value = value; } } /******** GROUPING END ********************/ } 1.1 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/Cocoon2EsqlConnection.java Index: Cocoon2EsqlConnection.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 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 [EMAIL PROTECTED] 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 <[EMAIL PROTECTED]>. 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.excalibur.datasource.DataSourceComponent; import java.sql.Connection; import java.sql.SQLException; import java.sql.DriverManager; /** * This is the Cocoon2 specific part of an AbstractEsqlConnection. * This should only be in the C2 codebase * * based on the orginal esql.xsl * @author <a href="mailto:[EMAIL PROTECTED]">Torsten Curdt</a> * @version CVS $Id: Cocoon2EsqlConnection.java,v 1.1 2002/12/04 21:51:38 tcurdt Exp $ */ final public class Cocoon2EsqlConnection extends AbstractEsqlConnection { final private DataSourceComponent datasource; private Connection connection = null; public Cocoon2EsqlConnection() { this.datasource = null; this.connection = null; } public Cocoon2EsqlConnection( Connection connection ) { this.datasource = null; this.connection = connection; } public Cocoon2EsqlConnection( DataSourceComponent datasource ) { this.datasource = datasource; } protected Connection getConnection() throws SQLException { if (connection != null) { return(connection); } else { if (datasource != null) { connection = datasource.getConnection(); return(connection); } else { connection = DriverManager.getConnection(getURL(), getProperties()); return(connection); } } } } 1.1 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/JdbcEsqlQuery.java Index: JdbcEsqlQuery.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 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 [EMAIL PROTECTED] 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 <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.language.markup.xsp; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.ResultSet; import java.sql.CallableStatement; final public class JdbcEsqlQuery extends AbstractEsqlQuery { public JdbcEsqlQuery(AbstractEsqlConnection connection, String query) { super(connection, query); } private JdbcEsqlQuery(final ResultSet resultSet) { super(resultSet); } public AbstractEsqlQuery newInstance(final ResultSet resultSet) { return(new JdbcEsqlQuery(resultSet)); } public PreparedStatement prepareStatement() throws SQLException { return ( setPreparedStatement( getConnection().prepareStatement( getQueryString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY) )); } public CallableStatement prepareCall() throws SQLException { return ( (CallableStatement) setPreparedStatement( getConnection().prepareCall( getQueryString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY ) ) ); } /** * AFAIK this is the proposed JDBC API way to get the number * of results. Unfortunately -at least some- driver implementation * are transfering the complete resultset when moving to the end. * Which is totally stupid for limit/paging purposes. So we probably * better stick with an additional count query. */ /* public int getRowCount() throws SQLException { ResultSet rs = getResultSet(); synchronized (rs) { int currentRow = rs.getRow(); rs.last(); int count = rs.getRow(); if (currentRow > 0) { rs.absolute(currentRow); } else { rs.first(); rs.relative(-1); } return (count); } } */ public void getResultRows() throws SQLException { getResultSet().absolute(getSkipRows()); setPosition(getSkipRows()); } } 1.1 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/MysqlEsqlQuery.java Index: MysqlEsqlQuery.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 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 [EMAIL PROTECTED] 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 <[EMAIL PROTECTED]>. 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.cocoon.components.language.markup.xsp.AbstractEsqlQuery; import java.sql.SQLException; import java.sql.ResultSet; final public class MysqlEsqlQuery extends AbstractEsqlQuery { public MysqlEsqlQuery(AbstractEsqlConnection connection, String query) { super(connection, query); } private MysqlEsqlQuery(final ResultSet resultSet) { super(resultSet); } public AbstractEsqlQuery newInstance(ResultSet resultSet) { return( new MysqlEsqlQuery(resultSet) ); } public String getQueryString() throws SQLException { if (getSkipRows() > 0) { if (getMaxRows() > -1) { return (new StringBuffer(super.getQueryString()) .append(" LIMIT ").append(getSkipRows()) .append(",").append(getMaxRows()) .toString()); } else { throw new SQLException("MySQL does not support a skip of rows only. Please also provide the max amount of rows"); } } else { if (getMaxRows() > -1) { return (new StringBuffer(super.getQueryString()) .append(" LIMIT ").append(getMaxRows()) .toString()); } else { return (super.getQueryString()); } } } public void getResultRows() throws SQLException { setPosition(getSkipRows()); } } 1.1 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PostgresEsqlQuery.java Index: PostgresEsqlQuery.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 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 [EMAIL PROTECTED] 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 <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.language.markup.xsp; import java.sql.SQLException; import java.sql.ResultSet; final public class PostgresEsqlQuery extends AbstractEsqlQuery { public PostgresEsqlQuery(AbstractEsqlConnection connection, String query) { super(connection, query); } private PostgresEsqlQuery(ResultSet resultSet) { super(resultSet); } public AbstractEsqlQuery newInstance(final ResultSet resultSet) { return(new PostgresEsqlQuery(resultSet)); } public String getQueryString() throws SQLException { if (getSkipRows() > 0) { if (getMaxRows() > -1) { return (new StringBuffer(super.getQueryString()) .append(" LIMIT ").append(getMaxRows()) .append(",").append(getSkipRows()) .toString()); } else { return (new StringBuffer(super.getQueryString()) .append(" OFFSET ").append(getSkipRows()) .toString()); } } else { if (getMaxRows() > -1) { return (new StringBuffer(super.getQueryString()) .append(" LIMIT ").append(getMaxRows()) .toString()); } else { return (super.getQueryString()); } } } public void getResultRows() throws SQLException { setPosition(getSkipRows()); } } 1.1 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/SybaseEsqlQuery.java Index: SybaseEsqlQuery.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 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 [EMAIL PROTECTED] 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 <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.language.markup.xsp; import java.sql.SQLException; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.CallableStatement; final public class SybaseEsqlQuery extends AbstractEsqlQuery { public SybaseEsqlQuery(AbstractEsqlConnection connection, String query) { super(connection, query); } private SybaseEsqlQuery(final ResultSet resultSet) { super(resultSet); } public AbstractEsqlQuery newInstance(ResultSet resultSet) { return(new SybaseEsqlQuery(resultSet)); } public String getQueryString() throws SQLException { if (getMaxRows() > -1) { String original = super.getQueryString().trim(); int command = original.indexOf(' '); return (new StringBuffer() .append(original.substring(0,command)) .append(" TOP ").append(getMaxRows()+getSkipRows()) .append(original.substring(command)) .toString()); } else { return (super.getQueryString()); } } public PreparedStatement prepareStatement() throws SQLException { return ( setPreparedStatement( getConnection().prepareStatement( getQueryString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY) )); } public CallableStatement prepareCall() throws SQLException { return ( (CallableStatement) setPreparedStatement( getConnection().prepareCall( getQueryString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY ) ) ); } public void getResultRows() throws SQLException { getResultSet().absolute(getSkipRows()); setPosition(getSkipRows()); } } 1.4 +46 -35 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl Index: esql.xsl =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- esql.xsl 17 Nov 2002 18:00:04 -0000 1.3 +++ esql.xsl 4 Dec 2002 21:51:38 -0000 1.4 @@ -55,7 +55,9 @@ <!-- * ESQL Logicsheet * - * @author ? + * @author <a href="mailto:[EMAIL PROTECTED]">Donald Ball</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Torsten Curdt</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a> * @version CVS $Revision$ $Date$ --> @@ -189,9 +191,9 @@ <xsp:include>java.sql.Struct</xsp:include> <xsp:include>java.sql.Types</xsp:include> <xsp:include>org.apache.cocoon.components.language.markup.xsp.EsqlHelper</xsp:include> - <xsp:include>org.apache.cocoon.components.language.markup.xsp.EsqlQuery</xsp:include> - <xsp:include>org.apache.cocoon.components.language.markup.xsp.EsqlConnection</xsp:include> - <xsp:include>org.apache.cocoon.components.language.markup.xsp.EsqlConnectionCocoon2</xsp:include> + <xsp:include>org.apache.cocoon.components.language.markup.xsp.AbstractEsqlQuery</xsp:include> + <xsp:include>org.apache.cocoon.components.language.markup.xsp.AbstractEsqlConnection</xsp:include> + <xsp:include>org.apache.cocoon.components.language.markup.xsp.Cocoon2EsqlConnection</xsp:include> <xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</xsp:include> <xsl:if test=".//esql:connection/esql:pool"> <xsp:include>org.apache.avalon.excalibur.datasource.DataSourceComponent</xsp:include> @@ -253,9 +255,9 @@ <xsl:param name="modifier" select="''"/> <xsp:logic> <xsl:value-of select="$modifier"/> Stack _esql_connections = new Stack(); - <xsl:value-of select="$modifier"/> EsqlConnectionCocoon2 _esql_connection = null; + <xsl:value-of select="$modifier"/> Cocoon2EsqlConnection _esql_connection = null; <xsl:value-of select="$modifier"/> Stack _esql_queries = new Stack(); - <xsl:value-of select="$modifier"/> EsqlQuery _esql_query = null; + <xsl:value-of select="$modifier"/> AbstractEsqlQuery _esql_query = null; <xsl:value-of select="$modifier"/> SQLException _esql_exception = null; <xsl:value-of select="$modifier"/> StringWriter _esql_exception_writer = null; </xsp:logic> @@ -275,19 +277,18 @@ <xsl:variable name="password"><xsl:call-template name="get-nested-string"><xsl:with-param name="content" select="esql:password"/></xsl:call-template></xsl:variable> <xsl:variable name="pool"><xsl:call-template name="get-nested-string"><xsl:with-param name="content" select="esql:pool"/></xsl:call-template></xsl:variable> <xsl:variable name="autocommit"><xsl:call-template name="get-nested-string"><xsl:with-param name="content" select="esql:autocommit"/></xsl:call-template></xsl:variable> - <xsl:variable name="use-limit-clause"><xsl:call-template name="get-nested-string"><xsl:with-param name="content" select="esql:use-limit-clause"/></xsl:call-template></xsl:variable> <xsl:variable name="allow-multiple-results"><xsl:call-template name="get-nested-string"><xsl:with-param name="content" select="esql:allow-multiple-results"/></xsl:call-template></xsl:variable> <xsp:logic> if (_esql_connection != null) { _esql_connections.push(_esql_connection); } - _esql_connection = new EsqlConnectionCocoon2(); try { <xsl:choose> <xsl:when test="esql:pool"> try { - _esql_connection.datasource = (DataSourceComponent) _esql_get_selector().select(String.valueOf(<xsl:copy-of select="$pool"/>)); - _esql_connection.connection = _esql_connection.datasource.getConnection(); + _esql_connection = new Cocoon2EsqlConnection( (DataSourceComponent) _esql_get_selector().select(String.valueOf(<xsl:copy-of select="$pool"/>)) ); + setupLogger(_esql_connection); + <xsl:if test="esql:allow-multiple-results"> _esql_connection.setMultipleResults(String.valueOf(<xsl:copy-of select="$allow-multiple-results"/>)); </xsl:if> @@ -305,6 +306,9 @@ } </xsl:if> try { + _esql_connection = new Cocoon2EsqlConnection(); + setupLogger(_esql_connection); + _esql_connection.setUrl(String.valueOf(<xsl:copy-of select="$dburl"/>)); <xsl:if test="esql:username"> _esql_connection.setUser(String.valueOf(<xsl:copy-of select="$username"/>)); @@ -318,14 +322,13 @@ <xsl:if test="esql:allow-multiple-results"> _esql_connection.setMultipleResults(String.valueOf(<xsl:copy-of select="$allow-multiple-results"/>)); </xsl:if> - _esql_connection.connection = DriverManager.getConnection(_esql_connection.getUrl(), _esql_connection.getInfo()); } catch (Exception _esql_exception_<xsl:value-of select="generate-id(.)"/>) { throw new RuntimeException("Error opening connection to dburl: "+String.valueOf(<xsl:copy-of select="$dburl"/>)+": "+_esql_exception_<xsl:value-of select="generate-id(.)"/>.getMessage()); } </xsl:otherwise> </xsl:choose> try { - if ("false".equals(String.valueOf(<xsl:copy-of select="$autocommit"/>))) { + if ("false".equalsIgnoreCase(String.valueOf(<xsl:copy-of select="$autocommit"/>))) { if (_esql_connection.getAutoCommit()) { _esql_connection.setAutoCommit(false); } @@ -337,11 +340,12 @@ } catch (Exception _esql_exception_<xsl:value-of select="generate-id(.)"/>) { // do NOT: throw new RuntimeException("Error setting connection autocommit"); } - <xsl:if test="esql:use-limit-clause"> - _esql_connection.setLimitMethod(String.valueOf(<xsl:copy-of select="$use-limit-clause"/>)); - </xsl:if> <xsl:apply-templates/> - } finally { + } + catch (SQLException e) { + getLogger().error("",e); + } + finally { try { if(!_esql_connection.getAutoCommit()) { _esql_connection.commit(); @@ -350,7 +354,7 @@ if (_esql_connections.empty()) { _esql_connection = null; } else { - _esql_connection = (EsqlConnectionCocoon2)_esql_connections.pop(); + _esql_connection = (Cocoon2EsqlConnection)_esql_connections.pop(); } } catch (Exception _esql_exception_<xsl:value-of select="generate-id(.)"/>) {} } @@ -416,7 +420,7 @@ if (_esql_query.hasResultSet()) { _esql_query.getResultRows(); if (_esql_query.nextRow()) { - switch (_esql_query.getResultCount()) { + switch (_esql_query.getQueryResultsCount()) { <xsl:for-each select="esql:results"> case <xsl:value-of select="position()"/>: <xsl:if test="position()=last()"><xsl:text> default: </xsl:text></xsl:if><xsl:apply-templates select="."/> @@ -424,7 +428,7 @@ </xsl:for-each> } } else { - switch (_esql_query.getUpdateCountCount()) { + switch (_esql_query.getUpdateResultsCount()) { <xsl:for-each select="esql:no-results"> case <xsl:value-of select="position()"/>: <xsl:if test="position()=last()"><xsl:text> default: </xsl:text></xsl:if><xsl:apply-templates select="."/> @@ -435,7 +439,7 @@ _esql_query.getResultSet().close(); } else { if (_esql_query.getUpdateCount() > 0) { - switch (_esql_query.getUpdateCountCount()) { + switch (_esql_query.getUpdateResultsCount()) { <xsl:for-each select="esql:update-results"> case <xsl:value-of select="position()"/>: <xsl:if test="position()=last()"><xsl:text> default: </xsl:text></xsl:if><xsl:apply-templates select="."/> @@ -443,7 +447,7 @@ </xsl:for-each> } } else { - switch (_esql_query.getUpdateCountCount()) { + switch (_esql_query.getUpdateResultsCount()) { <xsl:for-each select="esql:no-results"> case <xsl:value-of select="position()"/>: <xsl:if test="position()=last()"><xsl:text> default: </xsl:text></xsl:if><xsl:apply-templates select="."/> @@ -452,7 +456,7 @@ } } } - } while(_esql_connection.multipleResults() && _esql_query.getMoreResults()); + } while(_esql_connection.getMultipleResults() && _esql_query.getMoreResults()); </xsl:template> @@ -462,11 +466,17 @@ <xsl:variable name="maxrows"><xsl:call-template name="get-nested-string"><xsl:with-param name="content" select="esql:max-rows"/></xsl:call-template></xsl:variable> <xsl:variable name="skiprows"><xsl:call-template name="get-nested-string"><xsl:with-param name="content" select="esql:skip-rows"/></xsl:call-template></xsl:variable> + <xsl:variable name="use-limit-clause"><xsl:call-template name="get-nested-string"><xsl:with-param name="content" select="esql:use-limit-clause"/></xsl:call-template></xsl:variable> + <xsp:logic> if (_esql_query != null) { _esql_queries.push(_esql_query); } - _esql_query = new EsqlQuery( _esql_connection, String.valueOf(<xsl:copy-of select="$query"/>) ); + + _esql_query = _esql_connection.createQuery( + String.valueOf(<xsl:copy-of select="$use-limit-clause"/>), + String.valueOf(<xsl:copy-of select="$query"/>) + ); <xsl:if test="esql:max-rows"> try { @@ -501,7 +511,7 @@ _esql_query.execute(); </xsl:when> <xsl:otherwise> - _esql_query.createStatement(); + _esql_query.prepareStatement(); _esql_query.execute(); </xsl:otherwise> </xsl:choose> @@ -516,7 +526,7 @@ </xsp:content> </xsl:if> - _esql_query.getStatement().close(); + _esql_query.getPreparedStatement().close(); } catch (SQLException _esql_exception_<xsl:value-of select="generate-id(.)"/>) { <xsl:choose> @@ -544,7 +554,7 @@ if (_esql_queries.empty()) { _esql_query = null; } else { - _esql_query = (EsqlQuery)_esql_queries.pop(); + _esql_query = (AbstractEsqlQuery)_esql_queries.pop(); } </xsp:logic> </xsl:template> @@ -553,7 +563,7 @@ <xsl:template match="esql:call//esql:parameter">"?"</xsl:template> <xsl:template match="esql:execute-query//esql:results//esql:row-count"> - <xsp:expr>_esql_query.rowCount()</xsp:expr> + <xsp:expr>_esql_query.getRowCount()</xsp:expr> </xsl:template> <xsl:template match="esql:execute-query//esql:results"> @@ -664,14 +674,14 @@ </xsl:variable> <xsp:logic> - _esql_query.groupLevelPlusPlus(); + _esql_query.incGroupLevel(); if (!_esql_query.groupLevelExists()) { _esql_query.setGroupingVar(<xsl:copy-of select="$group"/>); } <xsp:content> <xsl:apply-templates/> </xsp:content> - _esql_query.groupLevelMinusMinus(); + _esql_query.decGroupLevel(); </xsp:logic> </xsl:template> @@ -722,7 +732,7 @@ // postgres is broken as it doesn't allow getObject() // to retrieve any type (i.e. bit and bit varying) // so don't handle complex types different for postgres - if (!_esql_connection.getUrl().startsWith("jdbc:postgresql:")) { + if (!_esql_connection.getURL().startsWith("jdbc:postgresql:")) { this._esql_printObject(_esql_query.getResultSet().getObject(_esql_i), xspAttr); break; } @@ -997,7 +1007,8 @@ if (_esql_query != null) { _esql_queries.push(_esql_query); } - _esql_query = new EsqlQuery((ResultSet) <xsl:apply-templates select="esql:result/*"/>); + + _esql_query = _esql_query.newInstance((ResultSet) <xsl:apply-templates select="esql:result/*"/>)); <xsl:if test="esql:max-rows"> try { @@ -1017,7 +1028,7 @@ if (_esql_queries.empty()) { _esql_query = null; } else { - _esql_query = (EsqlQuery)_esql_queries.pop(); + _esql_query = (AbstractEsqlQuery)_esql_queries.pop(); } </xsp:logic> </xsl:template> @@ -1044,7 +1055,7 @@ <xsl:template name="get-query"> <xsl:choose> <xsl:when test="@ancestor"> - <xsl:text>((EsqlQuery)_esql_queries.elementAt(_esql_queries.size()-</xsl:text> + <xsl:text>((AbstractEsqlQuery)_esql_queries.elementAt(_esql_queries.size()-</xsl:text> <xsl:value-of select="@ancestor"/> <xsl:text>))</xsl:text> </xsl:when>
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]