2362N/A * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * The standard interface that all standard implementations of 0N/A * <code>JdbcRowSet</code> must implement. 0N/A * <h3>1.0 Overview</h3> 0N/A * A wrapper around a <code>ResultSet</code> object that makes it possible 0N/A * to use the result set as a JavaBeans<sup><font size=-2>TM</font></sup> 0N/A * component. Thus, a <code>JdbcRowSet</code> object can be one of the Beans that 0N/A * a tool makes available for composing an application. Because 0N/A * a <code>JdbcRowSet</code> is a connected rowset, that is, it continually 0N/A * maintains its connection to a database using a JDBC technology-enabled 0N/A * driver, it also effectively makes the driver a JavaBeans component. 0N/A * Because it is always connected to its database, an instance of 0N/A * <code>JdbcRowSet</code> 0N/A * can simply take calls invoked on it and in turn call them on its 0N/A * <code>ResultSet</code> object. As a consequence, a result set can, for 0N/A * example, be a component in a Swing application. 0N/A * Another advantage of a <code>JdbcRowSet</code> object is that it can be 0N/A * used to make a <code>ResultSet</code> object scrollable and updatable. All 0N/A * <code>RowSet</code> objects are by default scrollable and updatable. If 0N/A * the driver and database being used do not support scrolling and/or updating 0N/A * of result sets, an application can populate a <code>JdbcRowSet</code> object 0N/A * with the data of a <code>ResultSet</code> object and then operate on the 0N/A * <code>JdbcRowSet</code> object as if it were the <code>ResultSet</code> 0N/A * <h3>2.0 Creating a <code>JdbcRowSet</code> Object</h3> 0N/A * The reference implementation of the <code>JdbcRowSet</code> interface, 0N/A * <code>JdbcRowSetImpl</code>, provides an implementation of 0N/A * the default constructor. A new instance is initialized with 0N/A * default values, which can be set with new values as needed. A 0N/A * new instance is not really functional until its <code>execute</code> 0N/A * method is called. In general, this method does the following: 0N/A * <LI> establishes a connection with a database 0N/A * <LI> creates a <code>PreparedStatement</code> object and sets any of its 0N/A * placeholder parameters 0N/A * <LI> executes the statement to create a <code>ResultSet</code> object 0N/A * If the <code>execute</code> method is successful, it will set the 0N/A * appropriate private <code>JdbcRowSet</code> fields with the following: 0N/A * <LI> a <code>Connection</code> object -- the connection between the rowset 0N/A * <LI> a <code>PreparedStatement</code> object -- the query that produces 0N/A * <LI> a <code>ResultSet</code> object -- the result set that the rowset's 0N/A * command produced and that is being made, in effect, a JavaBeans 0N/A * If these fields have not been set, meaning that the <code>execute</code> 0N/A * method has not executed successfully, no methods other than 0N/A * <code>execute</code> and <code>close</code> may be called on the 0N/A * rowset. All other public methods will throw an exception. 0N/A * Before calling the <code>execute</code> method, however, the command 0N/A * and properties needed for establishing a connection must be set. 0N/A * The following code fragment creates a <code>JdbcRowSetImpl</code> object, 0N/A * sets the command and connection properties, sets the placeholder parameter, 0N/A * and then invokes the method <code>execute</code>. 0N/A * JdbcRowSetImpl jrs = new JdbcRowSetImpl(); 0N/A * jrs.setCommand("SELECT * FROM TITLES WHERE TYPE = ?"); 0N/A * jrs.setURL("jdbc:myDriver:myAttribute"); 0N/A * jrs.setUsername("cervantes"); 0N/A * jrs.setPassword("sancho"); 0N/A * jrs.setString(1, "BIOGRAPHY"); 0N/A * The variable <code>jrs</code> now represents an instance of 0N/A * <code>JdbcRowSetImpl</code> that is a thin wrapper around the 0N/A * <code>ResultSet</code> object containing all the rows in the 0N/A * table <code>TITLES</code> where the type of book is biography. 0N/A * At this point, operations called on <code>jrs</code> will 0N/A * affect the rows in the result set, which is effectively a JavaBeans 0N/A * The implementation of the <code>RowSet</code> method <code>execute</code> in the 0N/A * <code>JdbcRowSet</code> reference implementation differs from that in the 0N/A * <code>CachedRowSet</code><sup><font size=-2>TM</font></sup> 0N/A * reference implementation to account for the different 0N/A * requirements of connected and disconnected <code>RowSet</code> objects. 0N/A * @author Jonathan Bruce 0N/A * Retrieves a <code>boolean</code> indicating whether rows marked 0N/A * for deletion appear in the set of current rows. If <code>true</code> is 0N/A * returned, deleted rows are visible with the current rows. If 0N/A * <code>false</code> is returned, rows are not visible with the set of 0N/A * current rows. The default value is <code>false</code>. 0N/A * Standard rowset implementations may choose to restrict this behavior 0N/A * for security considerations or for certain deployment 0N/A * scenarios. The visibility of deleted rows is implementation-defined 0N/A * and does not represent standard behavior. 0N/A * Note: Allowing deleted rows to remain visible complicates the behavior 0N/A * of some standard JDBC <code>RowSet</code> implementations methods. 0N/A * However, most rowset users can simply ignore this extra detail because 0N/A * only very specialized applications will likely want to take advantage of 0N/A * @return <code>true</code> if deleted rows are visible; 0N/A * <code>false</code> otherwise 0N/A * @exception SQLException if a rowset implementation is unable to 0N/A * to determine whether rows marked for deletion remain visible 0N/A * @see #setShowDeleted 0N/A * Sets the property <code>showDeleted</code> to the given 0N/A * <code>boolean</code> value. This property determines whether 0N/A * rows marked for deletion continue to appear in the set of current rows. 0N/A * If the value is set to <code>true</code>, deleted rows are immediately 0N/A * visible with the set of current rows. If the value is set to 0N/A * <code>false</code>, the deleted rows are set as invisible with the 0N/A * current set of rows. 0N/A * Standard rowset implementations may choose to restrict this behavior 0N/A * for security considerations or for certain deployment 0N/A * scenarios. This is left as implementation-defined and does not 0N/A * represent standard behavior. 0N/A * @param b <code>true</code> if deleted rows should be shown; 0N/A * <code>false</code> otherwise 0N/A * @exception SQLException if a rowset implementation is unable to 0N/A * to reset whether deleted rows should be visible 0N/A * @see #getShowDeleted 0N/A * Retrieves the first warning reported by calls on this <code>JdbcRowSet</code> 0N/A * If a second warning was reported on this <code>JdbcRowSet</code> object, 0N/A * it will be chained to the first warning and can be retrieved by 0N/A * calling the method <code>RowSetWarning.getNextWarning</code> on the 0N/A * first warning. Subsequent warnings on this <code>JdbcRowSet</code> 0N/A * object will be chained to the <code>RowSetWarning</code> objects 0N/A * returned by the method <code>RowSetWarning.getNextWarning</code>. 0N/A * The warning chain is automatically cleared each time a new row is read. 0N/A * This method may not be called on a <code>RowSet</code> object 0N/A * that has been closed; 0N/A * doing so will cause an <code>SQLException</code> to be thrown. 0N/A * Because it is always connected to its data source, a <code>JdbcRowSet</code> 0N/A * object can rely on the presence of active 0N/A * <code>Statement</code>, <code>Connection</code>, and <code>ResultSet</code> 0N/A * instances. This means that applications can obtain additional 0N/A * <code>SQLWarning</code> 0N/A * notifications by calling the <code>getNextWarning</code> methods that 0N/A * Disconnected <code>Rowset</code> objects, such as a 0N/A * <code>CachedRowSet</code> object, do not have access to 0N/A * these <code>getNextWarning</code> methods. 0N/A * @return the first <code>RowSetWarning</code> 0N/A * object reported on this <code>JdbcRowSet</code> object 0N/A * or <code>null</code> if there are none 0N/A * @throws SQLException if this method is called on a closed 0N/A * <code>JdbcRowSet</code> object 0N/A * @see RowSetWarning 0N/A * Each <code>JdbcRowSet</code> contains a <code>Connection</code> object from 0N/A * the <code>ResultSet</code> or JDBC properties passed to it's constructors. 0N/A * This method wraps the <code>Connection</code> commit method to allow flexible 0N/A * auto commit or non auto commit transactional control support. 0N/A * and releases any database locks currently held by this Connection 0N/A * object. This method should be used only when auto-commit mode has 0N/A * @throws SQLException if a database access error occurs or this 0N/A * Connection object within this <code>JdbcRowSet</code> is in auto-commit mode 0N/A * @see java.sql.Connection#setAutoCommit 0N/A * Each <code>JdbcRowSet</code> contains a <code>Connection</code> object from 0N/A * the original <code>ResultSet</code> or JDBC properties passed to it. This 0N/A * method wraps the <code>Connection</code>'s <code>getAutoCommit</code> method 0N/A * to allow an application to determine the <code>JdbcRowSet</code> transaction 0N/A * Sets this connection's auto-commit mode to the given state. If a 0N/A * connection is in auto-commit mode, then all its SQL statements will 0N/A * be executed and committed as individual transactions. Otherwise, its 0N/A * SQL statements are grouped into transactions that are terminated by a 0N/A * call to either the method commit or the method rollback. By default, 0N/A * new connections are in auto-commit mode. 0N/A * @throws SQLException if a database access error occurs 0N/A * @see java.sql.Connection#getAutoCommit() 0N/A * Each <code>JdbcRowSet</code> contains a <code>Connection</code> object from 0N/A * the original <code>ResultSet</code> or JDBC properties passed to it. This 0N/A * method wraps the <code>Connection</code>'s <code>getAutoCommit</code> method 0N/A * to allow an application to set the <code>JdbcRowSet</code> transaction behavior. 0N/A * Sets the current auto-commit mode for this <code>Connection</code> object. 0N/A * @throws SQLException if a database access error occurs 0N/A * @see java.sql.Connection#setAutoCommit(boolean) 0N/A * Each <code>JdbcRowSet</code> contains a <code>Connection</code> object from 0N/A * the original <code>ResultSet</code> or JDBC properties passed to it. 0N/A * Undoes all changes made in the current transaction and releases any 0N/A * database locks currently held by this <code>Connection</code> object. This method 0N/A * should be used only when auto-commit mode has been disabled. 0N/A * @throws SQLException if a database access error occurs or this <code>Connection</code> 0N/A * object within this <code>JdbcRowSet</code> is in auto-commit mode. 0N/A * @see #rollback(Savepoint) 0N/A * Each <code>JdbcRowSet</code> contains a <code>Connection</code> object from 0N/A * the original <code>ResultSet</code> or JDBC properties passed to it. 0N/A * Undoes all changes made in the current transaction to the last set savepoint 0N/A * and releases any database locks currently held by this <code>Connection</code> 0N/A * object. This method should be used only when auto-commit mode has been disabled. 0N/A * @throws SQLException if a database access error occurs or this <code>Connection</code> 0N/A * object within this <code>JdbcRowSet</code> is in auto-commit mode.