KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > tools > ij > ijResultSetResult


1 /*
2
3    Derby - Class org.apache.derby.impl.tools.ij.ijResultSetResult
4
5    Licensed to the Apache Software Foundation (ASF) under one
6    or more contributor license agreements. See the NOTICE file
7    distributed with this work for additional information
8    regarding copyright ownership. The ASF licenses this file
9    to you under the Apache License, Version 2.0 (the
10    "License"); you may not use this file except in compliance
11    with the License. You may obtain a copy of the License at
12
13       http://www.apache.org/licenses/LICENSE-2.0
14
15    Unless required by applicable law or agreed to in writing, software
16    distributed under the License is distributed on an "AS IS" BASIS,
17    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18    See the License for the specific language governing permissions and
19    limitations under the License.
20
21  */

22
23 package org.apache.derby.impl.tools.ij;
24
25 import java.sql.Connection JavaDoc;
26 import java.sql.ResultSet JavaDoc;
27 import java.sql.Statement JavaDoc;
28 import java.sql.SQLException JavaDoc;
29 import java.sql.SQLWarning JavaDoc;
30
31 /**
32  * This impl is intended to be used with a resultset,
33  * where the execution of the statement is already complete.
34  */

35 public class ijResultSetResult extends ijResultImpl {
36
37     ResultSet JavaDoc resultSet;
38     Statement JavaDoc statement;
39
40     int[] displayColumns = null;
41     int[] columnWidths = null;
42
43     /**
44      * Create a ijResultImpl that represents a result set.
45      */

46     public ijResultSetResult(ResultSet JavaDoc r) throws SQLException JavaDoc {
47         resultSet = r;
48         statement = resultSet.getStatement();
49     }
50
51     /**
52      * Create a ijResultImpl that represents a result set, only
53      * displaying a subset of the columns, using specified column widths.
54      *
55      * @param r The result set to display
56      * @param display Which column numbers to display, or null to display
57      * all columns.
58      * @param widths The widths of the columns specified in 'display', or
59      * null to display using default column sizes.
60      */

61     public ijResultSetResult(ResultSet JavaDoc r, int[] display,
62                              int[] widths) throws SQLException JavaDoc {
63         resultSet = r;
64         statement = resultSet.getStatement();
65
66         displayColumns = display;
67         columnWidths = widths;
68     }
69
70     public boolean isResultSet() throws SQLException JavaDoc { return statement==null || statement.getUpdateCount() == -1; }
71
72     public ResultSet JavaDoc getResultSet() throws SQLException JavaDoc { return resultSet; }
73
74     public void closeStatement() throws SQLException JavaDoc { if(statement!=null) statement.close(); else resultSet.close(); }
75
76     public int[] getColumnDisplayList() { return displayColumns; }
77     public int[] getColumnWidthList() { return columnWidths; }
78
79     public SQLWarning JavaDoc getSQLWarnings() throws SQLException JavaDoc { return resultSet.getWarnings(); }
80     public void clearSQLWarnings() throws SQLException JavaDoc { resultSet.clearWarnings(); }
81 }
82
Popular Tags