You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by ha...@apache.org on 2002/12/19 12:09:42 UTC
cvs commit: xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp PostgresOldEsqlQuery.java AbstractEsqlConnection.java PostgresEsqlQuery.java
haul 2002/12/19 03:09:42
Modified: src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp
AbstractEsqlConnection.java PostgresEsqlQuery.java
Added: src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp
PostgresOldEsqlQuery.java
Log:
<action dev="CH" type="fix" due-to-email="michael.enke@wincor-nixdorf.com"
due-to="Michael Enke" fixes-bug="15064">
Postgresql 7.3: LIMIT x,y no longer supported. Added new class for
postgresql-old limit method that still uses LIMIT x,y while postgresql
uses the LIMIT x OFFSET y syntax which has been used by postgresql for
some time now.
</action>
Revision Changes Path
1.5 +3 -0 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/AbstractEsqlConnection.java
Index: AbstractEsqlConnection.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/AbstractEsqlConnection.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractEsqlConnection.java 10 Dec 2002 00:51:45 -0000 1.4
+++ AbstractEsqlConnection.java 19 Dec 2002 11:09:42 -0000 1.5
@@ -162,6 +162,9 @@
else if ("postgresql".equalsIgnoreCase(type)) {
query = new PostgresEsqlQuery(this,queryString);
}
+ else if ("postgresql-old".equalsIgnoreCase(type)) {
+ query = new PostgresOldEsqlQuery(this,queryString);
+ }
else if ("mysql".equalsIgnoreCase(type)) {
query = new MysqlEsqlQuery(this,queryString);
}
1.5 +5 -23 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PostgresEsqlQuery.java
Index: PostgresEsqlQuery.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PostgresEsqlQuery.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PostgresEsqlQuery.java 10 Dec 2002 00:51:45 -0000 1.4
+++ PostgresEsqlQuery.java 19 Dec 2002 11:09:42 -0000 1.5
@@ -55,6 +55,7 @@
import java.sql.ResultSet;
/**
+ * @author <a href="mailto:haul@apache.org">Christian Haul</a>
* @author <a href="mailto:tcurdt@apache.org">Torsten Curdt</a>
*/
@@ -82,29 +83,10 @@
}
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());
- }
- }
+ StringBuffer sb = new StringBuffer(super.getQueryString());
+ if (getMaxRows() > -1) sb.append(" LIMIT ").append(getMaxRows());
+ if (getSkipRows() > 0) sb.append(" OFFSET ").append(getSkipRows());
+ return sb.toString();
}
public void getResultRows() throws SQLException {
1.1 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PostgresOldEsqlQuery.java
Index: PostgresOldEsqlQuery.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
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 <st...@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 java.sql.SQLException;
import java.sql.ResultSet;
/**
* @author <a href="mailto:tcurdt@apache.org">Torsten Curdt</a>
*/
final public class PostgresOldEsqlQuery extends AbstractEsqlQuery {
public PostgresOldEsqlQuery(AbstractEsqlConnection connection, String query) {
super(connection, query);
}
/**
* Only newInstance may use this contructor
* @param resultSet
*/
private PostgresOldEsqlQuery(ResultSet resultSet) {
super(resultSet);
}
/**
* Create a EsqlQuery of the same type
* @param resultSet
* @return
*/
public AbstractEsqlQuery newInstance(final ResultSet resultSet) {
return(new PostgresOldEsqlQuery(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());
}
}
----------------------------------------------------------------------
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