⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jdbcresultset.java

📁 httptunnel.jar httptunnel java 源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* Copyrights and Licenses * * This product includes Hypersonic SQL. * Originally developed by Thomas Mueller and the Hypersonic SQL Group.  * * Copyright (c) 1995-2000 by the Hypersonic SQL Group. All rights reserved.  * Redistribution and use in source and binary forms, with or without modification, are permitted * provided that the following conditions are met:  *     -  Redistributions of source code must retain the above copyright notice, this list of conditions *         and the following disclaimer.  *     -  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.  *     -  All advertising materials mentioning features or use of this software must display the *        following acknowledgment: "This product includes Hypersonic SQL."  *     -  Products derived from this software may not be called "Hypersonic SQL" nor may *        "Hypersonic SQL" appear in their names without prior written permission of the *         Hypersonic SQL Group.  *     -  Redistributions of any form whatsoever must retain the following acknowledgment: "This *          product includes Hypersonic SQL."  * 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 Hypersonic SQL Group or its contributors be liable for any * direct, indirect, incidental, special, exemplary, or consequential damages (including, but * not limited to, procurement of substitute goods or services; loss of use, data, or profits; * or business interruption). However caused any 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 * Hypersonic SQL Group. * * * For work added by the HSQL Development Group: * * Copyright (c) 2001-2002, The HSQL Development Group * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer, including earlier * license statements (above) and comply with all above license conditions. * * 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, including earlier * license statements (above) and comply with all above license conditions. * * Neither the name of the HSQL Development Group nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS 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 HSQL DEVELOPMENT GROUP, HSQLDB.ORG,  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 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. */package net.jumperz.ext.org.hsqldb;import java.io.ByteArrayInputStream;import java.io.InputStream;import java.io.Reader;import java.io.StringReader;import java.math.BigDecimal;import java.net.URL;import java.sql.*;     // for Array, Blob, Clob, Refimport java.sql.ResultSet;import java.sql.ResultSetMetaData;import java.sql.SQLException;import java.sql.Statement;import java.sql.Time;import java.sql.Timestamp;import java.sql.Types;import java.sql.SQLWarning;import java.util.*;    // for Mapimport java.util.Calendar;import net.jumperz.ext.org.hsqldb.lib.AsciiStringInputStream;import net.jumperz.ext.org.hsqldb.lib.StringInputStream;// fredt@users 20020320 - patch 1.7.0 - JDBC 2 support and error trapping// JDBC 2 methods can now be called from jdk 1.1.x - see javadoc comments// SCROLL_INSENSITIVE and FORWARD_ONLY types for ResultSet are now supported// fredt@users 20020315 - patch 497714 by lakuhns@users - scrollable ResultSet// all absolute and relative positioning methods defined// boucherb@users 20020409 - added "throws SQLException" to all methods where// it was missing here but specified in the java.sql.ResultSet and// java.sql.ResultSetMetaData interfaces, updated generic documentation to// JDK 1.4, and added JDBC3 methods and docs// boucherb@users and fredt@users 20020409/20020505 extensive review and update// of docs and behaviour to comply with previous and latest java.sql specification// tony_lai@users 20020820 - patch 595073 by tlai@users - duplicated exception msg/** * Implements both the <CODE>java.sql.ResultSet</CODE> and * <CODE>java.sql.ResultSetMetaData</CODE> interfaces. <p> * * <span class="ReleaseSpecificDocumentation"> * In short: <p> * * <UL> * <LI>A <code>ResultSet</code> object is essentially--but not limited to *    being--a table of data representing a database result set, which *    is usually generated by executing a statement that queries the *    database.</LI> * <LI>A <CODE>ResultSetMetaData</CODE> object is one that can be used to *    get information about the types and properties of the columns in a *    <code>ResultSet</code> object.</LI> * </UL> * <p> * * The following is composed of three sections: * <OL> * <LI>The generic overview for <CODE>ResultSet</CODE>.</LI> * <LI>The generic overview for <CODE>ResultSetMetaData</CODE>.</LI> * <LI>A discussion of some HSQLDB-specific concerns.</LI> * </OL> * </span> <p> * <!-- end Release-specific documentation --> * * <!-- start java.sql.ResultSet generaic documentation --> * <B>From <CODE>ResultSet</CODE>:</B><p> * * A table of data representing a database result set, which * is usually generated by executing a statement that queries the database. * * <P>A <code>ResultSet</code> object  maintains a cursor pointing * to its current row of data.  Initially the cursor is positioned * before the first row. The <code>next</code> method moves the * cursor to the next row, and because it returns <code>false</code> * when there are no more rows in the <code>ResultSet</code> object, * it can be used in a <code>while</code> loop to iterate through * the result set. * <P> * A default <code>ResultSet</code> object is not updatable and * has a cursor that moves forward only.  Thus, you can * iterate through it only once and only from the first row to the * last row. It is possible to * produce <code>ResultSet</code> objects that are scrollable and/or * updatable.  The following code fragment, in which <code>con</code> * is a valid <code>Connection</code> object, illustrates how to make * a result set that is scrollable and insensitive to updates by others, * and that is updatable. See <code>ResultSet</code> fields for other * options. * <PRE> * * Statement stmt = con.createStatement( *                            ResultSet.TYPE_SCROLL_INSENSITIVE, *                            ResultSet.CONCUR_UPDATABLE); * ResultSet rs = stmt.executeQuery("SELECT a, b FROM TABLE2"); * // rs will be scrollable, will not show changes made by others, * // and will be updatable * * </PRE> * The <code>ResultSet</code> interface provides * <i>getter</i> methods (<code>getBoolean</code>, <code>getLong</code>, * and so on) for retrieving column values from the current row. * Values can be retrieved using either the index number of the * column or the name of the column.  In general, using the * column index will be more efficient.  Columns are numbered from 1. * For maximum portability, result set columns within each row should be * read in left-to-right order, and each column should be read only once. * * <P>For the getter methods, a JDBC driver attempts * to convert the underlying data to the Java type specified in the * getter method and returns a suitable Java value.  The JDBC specification * has a table showing the allowable mappings from SQL types to Java types * that can be used by the <code>ResultSet</code> getter methods. * <P> * <P>Column names used as input to getter methods are case * insensitive.  When a getter method is called  with * a column name and several columns have the same name, * the value of the first matching column will be returned. * The column name option is * designed to be used when column names are used in the SQL * query that generated the result set. * For columns that are NOT explicitly named in the query, it * is best to use column numbers. If column names are used, there is * no way for the programmer to guarantee that they actually refer to * the intended columns. * <P> * A set of updater methods were added to this interface * in the JDBC 2.0 API (Java<sup><font size=-2>TM</font></sup> 2 SDK, * Standard Edition, version 1.2). The comments regarding parameters * to the getter methods also apply to parameters to the * updater methods. * <P> * The updater methods may be used in two ways: * <ol> * <LI>to update a column value in the current row.  In a scrollable * <code>ResultSet</code> object, the cursor can be moved backwards * and forwards, to an absolute position, or to a position * relative to the current row. * The following code fragment updates the <code>NAME</code> column * in the fifth row of the <code>ResultSet</code> object * <code>rs</code> and then uses the method <code>updateRow</code> * to update the data source table from which <code>rs</code> was * derived. * <PRE> * * rs.absolute(5); // moves the cursor to the fifth row of rs * rs.updateString("NAME", "AINSWORTH"); // updates the * // <code>NAME</code> column of row 5 to be <code>AINSWORTH</code> * rs.updateRow(); // updates the row in the data source * * </PRE> * <LI>to insert column values into the insert row.  An updatable * <code>ResultSet</code> object has a special row associated with * it that serves as a staging area for building a row to be inserted. * The following code fragment moves the cursor to the insert row, builds * a three-column row, and inserts it into <code>rs</code> and into * the data source table using the method <code>insertRow</code>. * <PRE> * * rs.moveToInsertRow(); // moves cursor to the insert row * rs.updateString(1, "AINSWORTH"); // updates the * // first column of the insert row to be <code>AINSWORTH</code> * rs.updateInt(2,35); // updates the second column to be <code>35</code> * rs.updateBoolean(3, true); // updates the third row to <code>true</code> * rs.insertRow(); * rs.moveToCurrentRow(); * * </PRE> * </ol> * <P>A <code>ResultSet</code> object is automatically closed when the * <code>Statement</code> object that * generated it is closed, re-executed, or used * to retrieve the next result from a sequence of multiple results. * * <P>The number, types and properties of a <code>ResultSet</code> * object's columns are provided by the <code>ResulSetMetaData</code> * object returned by the <code>ResultSet.getMetaData</code> method. <p> * <!-- end java.sql.ResultSet generic documentation --> * * <!-- start java.sql.ResultSetMetaData generic documentation--> * <B>From <CODE>ResultSetMetaData</CODE>:</B><p> * * An object that can be used to get information about the types * and properties of the columns in a <code>ResultSet</code> object. * The following code fragment creates the <code>ResultSet</code> * object rs, creates the <code>ResultSetMetaData</code> object rsmd, * and uses rsmd * to find out how many columns rs has and whether the first column in rs * can be used in a <code>WHERE</code> clause. * <PRE> * * ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2"); * ResultSetMetaData rsmd = rs.getMetaData(); * int numberOfColumns = rsmd.getColumnCount(); * boolean b = rsmd.isSearchable(1); * * </PRE> * <!-- end generic documentation --> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * <B>HSQLDB-Specific Information:</B> <p> * * As stated above, <CODE>jdbcResultSet</CODE> implements both the * <CODE>ResultSet</CODE> and <CODE>ResultSetMetaData</CODE> interfaces. * However, to gain access to the interface methods of * <CODE>ResultSetMetaData</CODE> in a driver independent way, the * traditional call to the {@link #getMetaData getMetaData} method should * be used, rather than casting objects known to be of type * <CODE>jdbcResultSet</CODE> to type <CODE>ResultSetMetaData</CODE>. <p> * * A <code>ResultSet</code> object generated by HSQLDB is, as is standard * JDBC behavior, by default of <code>ResultSet.TYPE_FORWARD_ONLY</code> * and does not allow the use of absolute and relative positioning * methods.  However, starting with 1.7.0, if a statement is created * with:<p> * * <code class="JavaCodeExample"> * Statement stmt createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, *                                ResultSet.CONCUR_READ_ONLY); * </code> <p> * * then the <CODE>ResultSet</CODE> objects it produces support * using all of  the absolute and relative positioning methods of JDBC2 * to set the position of the current row, for example:<p> * * <code class="JavaCodeExample"> * rs.absolute(5);<br> * String fifthRowValue = rs.getString(1);<br> * rs.relative(4);<br> * String ninthRowValue = rs.getString(1);<br> * </code> * <p> * * Note: An HSQLDB <code>ResultSet</code> object persists, even after its * connection is closed.  This is regardless of the operational mode of * the {@link Database Database} from which it came.  That is, they * persist whether originating from a <CODE>Server</CODE>, * <CODE>WebServer</CODE> or in-process mode <CODE>Database.</CODE> * <p> * * Up to and including HSQLDB 1.7.0, there is no support for any of * the methods introduced in JDBC 2 relating to updateable result sets. * These methods include all updateXXX methods, as well as the * {@link #insertRow}, {@link #updateRow}, {@link #deleteRow}, * {@link #moveToInsertRow} (and so on) methods.  A call to any such * unsupported method will simply result in throwing a * <CODE>SQLException</CODE> which states that the function is not * supported.  It is not anticipated that HSQLDB-native support for * updateable <CODE>ResultSet</CODE> objects will be introduced in the * HSQLDB 1.7.x series.  Such features <I>may</I> be part of the

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -