KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > servlet > jsp > jstl > sql > ResultSupport


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 javax.servlet.jsp.jstl.sql;
18
19 import java.sql.ResultSet JavaDoc;
20 import java.sql.SQLException JavaDoc;
21
22 /**
23  * <p>Supports the creation of a javax.servlet.jsp.jstl.sql.Result object
24  * from a source java.sql.ResultSet object. A Result object makes it much
25  * easier for page authors to access and manipulate the data resulting
26  * from a SQL query.</p>
27  *
28  * @author Justyna Horwat
29  *
30  */

31 public class ResultSupport {
32
33
34     /**
35      * Converts a <code>ResultSet</code> object to a <code>Result</code> object.
36      *
37      * @param rs the <code>ResultSet</code> object
38      *
39      * @return The <code>Result</code> object created from the <code>ResultSet</code>
40      */

41     public static Result toResult(ResultSet JavaDoc rs) {
42         try {
43             return new ResultImpl(rs, -1, -1);
44         } catch (SQLException JavaDoc ex) {
45             return null;
46         }
47     }
48
49     /**
50      * Converts <code>maxRows</code> of a <code>ResultSet</code> object to a
51      * <code>Result</code> object.
52      *
53      * @param rs the <code>ResultSet</code> object
54      * @param maxRows the maximum number of rows to be cached into the <code>Result</code> object.
55      *
56      * @return The <code>Result</code> object created from the <code>ResultSet</code>,
57      * limited by <code>maxRows</code>
58      */

59     public static Result toResult(ResultSet JavaDoc rs, int maxRows) {
60         try {
61             return new ResultImpl(rs, -1, maxRows);
62         } catch (SQLException JavaDoc ex) {
63             return null;
64         }
65     }
66
67 }
68
Popular Tags