KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > language > markup > xsp > PostgresEsqlQuery


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.cocoon.components.language.markup.xsp;
18
19 import java.sql.SQLException JavaDoc;
20 import java.sql.ResultSet JavaDoc;
21 import java.sql.Connection JavaDoc;
22
23 /**
24  * @author <a HREF="mailto:haul@apache.org">Christian Haul</a>
25  * @author <a HREF="mailto:tcurdt@apache.org">Torsten Curdt</a>
26  * @version CVS $Id: PostgresEsqlQuery.java 30932 2004-07-29 17:35:38Z vgritsenko $
27  */

28 final public class PostgresEsqlQuery extends AbstractEsqlQuery {
29
30     public PostgresEsqlQuery(Connection JavaDoc connection, String JavaDoc query) {
31         super(connection, query);
32     }
33
34     /**
35      * Only newInstance may use this contructor
36      * @param resultSet
37      */

38     private PostgresEsqlQuery(ResultSet JavaDoc resultSet) {
39         super(resultSet);
40     }
41
42     /**
43      * Create a EsqlQuery of the same type
44      * @param resultSet
45      */

46     public AbstractEsqlQuery newInstance(final ResultSet JavaDoc resultSet) {
47         return(new PostgresEsqlQuery(resultSet));
48     }
49
50     public String JavaDoc getQueryString() throws SQLException JavaDoc {
51         StringBuffer JavaDoc sb = new StringBuffer JavaDoc(super.getQueryString());
52         if (getMaxRows() > -1) sb.append(" LIMIT ").append(getMaxRows()+1);
53         if (getSkipRows() > 0) sb.append(" OFFSET ").append(getSkipRows());
54         return(sb.toString());
55     }
56
57     public void getResultRows() throws SQLException JavaDoc {
58         setPosition(getSkipRows());
59     }
60 }
61
Popular Tags