src/java.sql.rowset/share/classes/javax/sql/rowset/CachedRowSet.java
author lancea
Wed, 13 Mar 2019 14:10:18 -0400
changeset 54106 9a90236ab64c
parent 47216 71c04702a3d5
permissions -rw-r--r--
8220253: Fix Headings in java.sql.rowset Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
54106
9a90236ab64c 8220253: Fix Headings in java.sql.rowset
lancea
parents: 47216
diff changeset
     2
 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.sql.rowset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.sql.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.sql.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.naming.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.math.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.sql.rowset.spi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * The interface that all standard implementations of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <code>CachedRowSet</code> must implement.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * The reference implementation of the <code>CachedRowSet</code> interface provided
6671
c5fbc05d7347 6984044: RowSet source needs to rebrand vendor references
lancea
parents: 6529
diff changeset
    42
 * by Oracle Corporation is a standard implementation. Developers may use this implementation
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * just as it is, they may extend it, or they may choose to write their own implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * of this interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * A <code>CachedRowSet</code> object is a container for rows of data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * that caches its rows in memory, which makes it possible to operate without always being
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * connected to its data source. Further, it is a
18564
f9db68ff2cbb 8017471: Fix JDBC -Xdoclint public errors
lancea
parents: 18156
diff changeset
    49
 * JavaBeans&trade; component and is scrollable,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * updatable, and serializable. A <code>CachedRowSet</code> object typically
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * contains rows from a result set, but it can also contain rows from any file
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * with a tabular format, such as a spread sheet.  The reference implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * supports getting data only from a <code>ResultSet</code> object, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * developers can extend the <code>SyncProvider</code> implementations to provide
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * access to other tabular data sources.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * An application can modify the data in a <code>CachedRowSet</code> object, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * those modifications can then be propagated back to the source of the data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * A <code>CachedRowSet</code> object is a <i>disconnected</i> rowset, which means
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * that it makes use of a connection to its data source only briefly. It connects to its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * data source while it is reading data to populate itself with rows and again
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * while it is propagating changes back to its underlying data source. The rest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * of the time, a <code>CachedRowSet</code> object is disconnected, including
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * while its data is being modified. Being disconnected makes a <code>RowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * object much leaner and therefore much easier to pass to another component.  For
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * example, a disconnected <code>RowSet</code> object can be serialized and passed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * over the wire to a thin client such as a personal digital assistant (PDA).
20880
1b610151b316 8026812: doclint clean up for java.sql and javax.sql
lancea
parents: 18564
diff changeset
    69
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
54106
9a90236ab64c 8220253: Fix Headings in java.sql.rowset
lancea
parents: 47216
diff changeset
    71
 * <h2>1.0 Creating a <code>CachedRowSet</code> Object</h2>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * The following line of code uses the default constructor for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * supplied in the reference implementation (RI) to create a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * <code>CachedRowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *     CachedRowSetImpl crs = new CachedRowSetImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * This new <code>CachedRowSet</code> object will have its properties set to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * default properties of a <code>BaseRowSet</code> object, and, in addition, it will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * have an <code>RIOptimisticProvider</code> object as its synchronization provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <code>RIOptimisticProvider</code>, one of two <code>SyncProvider</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * implementations included in the RI, is the default provider that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * <code>SyncFactory</code> singleton will supply when no synchronization
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * provider is specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * A <code>SyncProvider</code> object provides a <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * with a reader (a <code>RowSetReader</code> object) for reading data from a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * data source to populate itself with data. A reader can be implemented to read
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * data from a <code>ResultSet</code> object or from a file with a tabular format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * A <code>SyncProvider</code> object also provides
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * a writer (a <code>RowSetWriter</code> object) for synchronizing any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * modifications to the <code>CachedRowSet</code> object's data made while it was
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * disconnected with the data in the underlying data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * A writer can be implemented to exercise various degrees of care in checking
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * for conflicts and in avoiding them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * (A conflict occurs when a value in the data source has been changed after
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * the rowset populated itself with that value.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * The <code>RIOptimisticProvider</code> implementation assumes there will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * few or no conflicts and therefore sets no locks. It updates the data source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * with values from the <code>CachedRowSet</code> object only if there are no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * conflicts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * Other writers can be implemented so that they always write modified data to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * the data source, which can be accomplished either by not checking for conflicts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * or, on the other end of the spectrum, by setting locks sufficient to prevent data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * in the data source from being changed. Still other writer implementations can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * somewhere in between.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * A <code>CachedRowSet</code> object may use any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * <code>SyncProvider</code> implementation that has been registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * with the <code>SyncFactory</code> singleton. An application
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * can find out which <code>SyncProvider</code> implementations have been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * registered by calling the following line of code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 *      java.util.Enumeration providers = SyncFactory.getRegisteredProviders();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * There are two ways for a <code>CachedRowSet</code> object to specify which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * <code>SyncProvider</code> object it will use.
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 6671
diff changeset
   121
 * <UL>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 *     <LI>Supplying the name of the implementation to the constructor<BR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 *     The following line of code creates the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 *     object <i>crs2</i> that is initialized with default values except that its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 *     <code>SyncProvider</code> object is the one specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 *     <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 *          CachedRowSetImpl crs2 = new CachedRowSetImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 *                                 "com.fred.providers.HighAvailabilityProvider");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 *     </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 *     <LI>Setting the <code>SyncProvider</code> using the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 *         method <code>setSyncProvider</code><BR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 *      The following line of code resets the <code>SyncProvider</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 *      for <i>crs</i>, the <code>CachedRowSet</code> object created with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 *      default constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 *      <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 *           crs.setSyncProvider("com.fred.providers.HighAvailabilityProvider");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 *      </PRE>
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 6671
diff changeset
   138
 * </UL>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * See the comments for <code>SyncFactory</code> and <code>SyncProvider</code> for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 * more details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 *
20880
1b610151b316 8026812: doclint clean up for java.sql and javax.sql
lancea
parents: 18564
diff changeset
   142
 *
54106
9a90236ab64c 8220253: Fix Headings in java.sql.rowset
lancea
parents: 47216
diff changeset
   143
 * <h2>2.0 Retrieving Data from a <code>CachedRowSet</code> Object</h2>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * Data is retrieved from a <code>CachedRowSet</code> object by using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 * getter methods inherited from the <code>ResultSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 * interface.  The following examples, in which <code>crs</code> is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 * <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 * object, demonstrate how to iterate through the rows, retrieving the column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 * values in each row.  The first example uses the version of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 * getter methods that take a column number; the second example
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 * uses the version that takes a column name. Column numbers are generally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 * used when the <code>RowSet</code> object's command
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 * is of the form <code>SELECT * FROM TABLENAME</code>; column names are most
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * commonly used when the command specifies columns by name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 *    while (crs.next()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 *        String name = crs.getString(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 *        int id = crs.getInt(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 *        Clob comment = crs.getClob(3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 *        short dept = crs.getShort(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 *        System.out.println(name + "  " + id + "  " + comment + "  " + dept);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 *    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 *    while (crs.next()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 *        String name = crs.getString("NAME");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 *        int id = crs.getInt("ID");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
 *        Clob comment = crs.getClob("COM");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
 *        short dept = crs.getShort("DEPT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
 *        System.out.println(name + "  " + id + "  " + comment + "  " + dept);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
 *    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 * </PRE>
54106
9a90236ab64c 8220253: Fix Headings in java.sql.rowset
lancea
parents: 47216
diff changeset
   174
 * <h3>2.1 Retrieving <code>RowSetMetaData</code></h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 * An application can get information about the columns in a <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
 * object by calling <code>ResultSetMetaData</code> and <code>RowSetMetaData</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
 * methods on a <code>RowSetMetaData</code> object. The following code fragment,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
 * in which <i>crs</i> is a <code>CachedRowSet</code> object, illustrates the process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 * The first line creates a <code>RowSetMetaData</code> object with information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 * about the columns in <i>crs</i>.  The method <code>getMetaData</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 * inherited from the <code>ResultSet</code> interface, returns a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
 * <code>ResultSetMetaData</code> object, which is cast to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
 * <code>RowSetMetaData</code> object before being assigned to the variable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
 * <i>rsmd</i>.  The second line finds out how many columns <i>jrs</i> has, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
 * the third line gets the JDBC type of values stored in the second column of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 * <code>jrs</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 *     RowSetMetaData rsmd = (RowSetMetaData)crs.getMetaData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 *     int count = rsmd.getColumnCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 *     int type = rsmd.getColumnType(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 * The <code>RowSetMetaData</code> interface differs from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
 * <code>ResultSetMetaData</code> interface in two ways.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
 * <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
 *   <LI><i>It includes <code>setter</code> methods:</i> A <code>RowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
 *   object uses these methods internally when it is populated with data from a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
 *   different <code>ResultSet</code> object.
20880
1b610151b316 8026812: doclint clean up for java.sql and javax.sql
lancea
parents: 18564
diff changeset
   198
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
 *   <LI><i>It contains fewer <code>getter</code> methods:</i> Some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
 *   <code>ResultSetMetaData</code> methods to not apply to a <code>RowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
 *   object. For example, methods retrieving whether a column value is writable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 *   or read only do not apply because all of a <code>RowSet</code> object's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
 *   columns will be writable or read only, depending on whether the rowset is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
 *   updatable or not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
 * </UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
 * NOTE: In order to return a <code>RowSetMetaData</code> object, implementations must
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
 * override the <code>getMetaData()</code> method defined in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
 * <code>java.sql.ResultSet</code> and return a <code>RowSetMetaData</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
 *
54106
9a90236ab64c 8220253: Fix Headings in java.sql.rowset
lancea
parents: 47216
diff changeset
   210
 * <h2>3.0 Updating a <code>CachedRowSet</code> Object</h2>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
 * Updating a <code>CachedRowSet</code> object is similar to updating a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
 * <code>ResultSet</code> object, but because the rowset is not connected to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
 * its data source while it is being updated, it must take an additional step
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
 * to effect changes in its underlying data source. After calling the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
 * <code>updateRow</code> or <code>insertRow</code>, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
 * <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
 * object must also call the method <code>acceptChanges</code> to have updates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
 * written to the data source. The following example, in which the cursor is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
 * on a row in the <code>CachedRowSet</code> object <i>crs</i>, shows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
 * the code required to update two column values in the current row and also
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
 * update the <code>RowSet</code> object's underlying data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
 *     crs.updateShort(3, 58);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
 *     crs.updateInt(4, 150000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
 *     crs.updateRow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
 *     crs.acceptChanges();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
 * The next example demonstrates moving to the insert row, building a new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
 * row on the insert row, inserting it into the rowset, and then calling the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
 * method <code>acceptChanges</code> to add the new row to the underlying data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
 * source.  Note that as with the getter methods, the  updater methods may take
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
 * either a column index or a column name to designate the column being acted upon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
 *     crs.moveToInsertRow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
 *     crs.updateString("Name", "Shakespeare");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
 *     crs.updateInt("ID", 10098347);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
 *     crs.updateShort("Age", 58);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
 *     crs.updateInt("Sal", 150000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
 *     crs.insertRow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
 *     crs.moveToCurrentRow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
 *     crs.acceptChanges();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
 * NOTE: Where the <code>insertRow()</code> method inserts the contents of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
 * <code>CachedRowSet</code> object's insert row is implementation-defined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
 * The reference implementation for the <code>CachedRowSet</code> interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
 * inserts a new row immediately following the current row, but it could be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
 * implemented to insert new rows in any number of other places.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
 * Another thing to note about these examples is how they use the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
 * <code>acceptChanges</code>.  It is this method that propagates changes in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
 * a <code>CachedRowSet</code> object back to the underlying data source,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
 * calling on the <code>RowSet</code> object's writer internally to write
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
 * changes to the data source. To do this, the writer has to incur the expense
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
 * of establishing a connection with that data source. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
 * preceding two code fragments call the method <code>acceptChanges</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
 * immediately after calling <code>updateRow</code> or <code>insertRow</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
 * However, when there are multiple rows being changed, it is more efficient to call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
 * <code>acceptChanges</code> after all calls to <code>updateRow</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
 * and <code>insertRow</code> have been made.  If <code>acceptChanges</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
 * is called only once, only one connection needs to be established.
20880
1b610151b316 8026812: doclint clean up for java.sql and javax.sql
lancea
parents: 18564
diff changeset
   263
 *
54106
9a90236ab64c 8220253: Fix Headings in java.sql.rowset
lancea
parents: 47216
diff changeset
   264
 * <h2>4.0 Updating the Underlying Data Source</h2>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
 * When the method <code>acceptChanges</code> is executed, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
 * <code>CachedRowSet</code> object's writer, a <code>RowSetWriterImpl</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
 * object, is called behind the scenes to write the changes made to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
 * rowset to the underlying data source. The writer is implemented to make a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
 * connection to the data source and write updates to it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
 * A writer is made available through an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
 * <code>SyncProvider</code> interface, as discussed in section 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
 * "Creating a <code>CachedRowSet</code> Object."
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
 * The default reference implementation provider, <code>RIOptimisticProvider</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
 * has its writer implemented to use an optimistic concurrency control
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
 * mechanism. That is, it maintains no locks in the underlying database while
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
 * the rowset is disconnected from the database and simply checks to see if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
 * are any conflicts before writing data to the data source.  If there are any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
 * conflicts, it does not write anything to the data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
 * The reader/writer facility
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
 * provided by the <code>SyncProvider</code> class is pluggable, allowing for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
 * customization of data retrieval and updating. If a different concurrency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
 * control mechanism is desired, a different implementation of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
 * <code>SyncProvider</code> can be plugged in using the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
 * <code>setSyncProvider</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
 * In order to use the optimistic concurrency control routine, the
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 24968
diff changeset
   289
 * <code>RIOptimisticProvider</code> maintains both its current
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
 * value and its original value (the value it had immediately preceding the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
 * current value). Note that if no changes have been made to the data in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
 * <code>RowSet</code> object, its current values and its original values are the same,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
 * both being the values with which the <code>RowSet</code> object was initially
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
 * populated.  However, once any values in the <code>RowSet</code> object have been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
 * changed, the current values and the original values will be different, though at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
 * this stage, the original values are still the initial values. With any subsequent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
 * changes to data in a <code>RowSet</code> object, its original values and current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
 * values will still differ, but its original values will be the values that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
 * were previously the current values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
 * Keeping track of original values allows the writer to compare the <code>RowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
 * object's original value with the value in the database. If the values in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
 * the database differ from the <code>RowSet</code> object's original values, which means that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
 * the values in the database have been changed, there is a conflict.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
 * Whether a writer checks for conflicts, what degree of checking it does, and how
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
 * it handles conflicts all depend on how it is implemented.
20880
1b610151b316 8026812: doclint clean up for java.sql and javax.sql
lancea
parents: 18564
diff changeset
   307
 *
54106
9a90236ab64c 8220253: Fix Headings in java.sql.rowset
lancea
parents: 47216
diff changeset
   308
 * <h2>5.0 Registering and Notifying Listeners</h2>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
 * Being JavaBeans components, all rowsets participate in the JavaBeans event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
 * model, inheriting methods for registering listeners and notifying them of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
 * changes from the <code>BaseRowSet</code> class.  A listener for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
 * <code>CachedRowSet</code> object is a component that wants to be notified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
 * whenever there is a change in the rowset.  For example, if a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
 * <code>CachedRowSet</code> object contains the results of a query and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
 * those
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
 * results are being displayed in, say, a table and a bar graph, the table and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
 * bar graph could be registered as listeners with the rowset so that they can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
 * update themselves to reflect changes. To become listeners, the table and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
 * bar graph classes must implement the <code>RowSetListener</code> interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
 * Then they can be added to the <Code>CachedRowSet</code> object's list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
 * listeners, as is illustrated in the following lines of code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
 *    crs.addRowSetListener(table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
 *    crs.addRowSetListener(barGraph);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
 * Each <code>CachedRowSet</code> method that moves the cursor or changes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
 * data also notifies registered listeners of the changes, so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
 * <code>table</code> and <code>barGraph</code> will be notified when there is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
 * a change in <code>crs</code>.
20880
1b610151b316 8026812: doclint clean up for java.sql and javax.sql
lancea
parents: 18564
diff changeset
   330
 *
54106
9a90236ab64c 8220253: Fix Headings in java.sql.rowset
lancea
parents: 47216
diff changeset
   331
 * <h2>6.0 Passing Data to Thin Clients</h2>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
 * One of the main reasons to use a <code>CachedRowSet</code> object is to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
 * pass data between different components of an application. Because it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
 * serializable, a <code>CachedRowSet</code> object can be used, for example,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
 * to send the result of a query executed by an enterprise JavaBeans component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
 * running in a server environment over a network to a client running in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
 * web browser.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
 * While a <code>CachedRowSet</code> object is disconnected, it can be much
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
 * leaner than a <code>ResultSet</code> object with the same data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
 * As a result, it can be especially suitable for sending data to a thin client
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
 * such as a PDA, where it would be inappropriate to use a JDBC driver
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
 * due to resource limitations or security considerations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
 * Thus, a <code>CachedRowSet</code> object provides a means to "get rows in"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
 * without the need to implement the full JDBC API.
20880
1b610151b316 8026812: doclint clean up for java.sql and javax.sql
lancea
parents: 18564
diff changeset
   346
 *
54106
9a90236ab64c 8220253: Fix Headings in java.sql.rowset
lancea
parents: 47216
diff changeset
   347
 * <h2>7.0 Scrolling and Updating</h2>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
 * A second major use for <code>CachedRowSet</code> objects is to provide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
 * scrolling and updating for <code>ResultSet</code> objects that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
 * do not provide these capabilities themselves.  In other words, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
 * <code>CachedRowSet</code> object can be used to augment the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
 * capabilities of a JDBC technology-enabled driver (hereafter called a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
 * "JDBC driver") when the DBMS does not provide full support for scrolling and
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 24968
diff changeset
   354
 * updating. To achieve the effect of making a non-scrollable and read-only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
 * <code>ResultSet</code> object scrollable and updatable, a programmer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
 * simply needs to create a <code>CachedRowSet</code> object populated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
 * with that <code>ResultSet</code> object's data.  This is demonstrated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
 * in the following code fragment, where <code>stmt</code> is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
 * <code>Statement</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
 *    ResultSet rs = stmt.executeQuery("SELECT * FROM EMPLOYEES");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
 *    CachedRowSetImpl crs = new CachedRowSetImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
 *    crs.populate(rs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
 * The object <code>crs</code> now contains the data from the table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
 * <code>EMPLOYEES</code>, just as the object <code>rs</code> does.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
 * The difference is that the cursor for <code>crs</code> can be moved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
 * forward, backward, or to a particular row even if the cursor for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
 * <code>rs</code> can move only forward.  In addition, <code>crs</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
 * updatable even if <code>rs</code> is not because by default, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
 * <code>CachedRowSet</code> object is both scrollable and updatable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
 * In summary, a <code>CachedRowSet</code> object can be thought of as simply
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
 * a disconnected set of rows that are being cached outside of a data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
 * Being thin and serializable, it can easily be sent across a wire,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
 * and it is well suited to sending data to a thin client. However, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
 * <code>CachedRowSet</code> object does have a limitation: It is limited in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
 * size by the amount of data it can store in memory at one time.
20880
1b610151b316 8026812: doclint clean up for java.sql and javax.sql
lancea
parents: 18564
diff changeset
   380
 *
54106
9a90236ab64c 8220253: Fix Headings in java.sql.rowset
lancea
parents: 47216
diff changeset
   381
 * <h2>8.0 Getting Universal Data Access</h2>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
 * Another advantage of the <code>CachedRowSet</code> class is that it makes it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
 * possible to retrieve and store data from sources other than a relational
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
 * database. The reader for a rowset can be implemented to read and populate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
 * its rowset with data from any tabular data source, including a spreadsheet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
 * or flat file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
 * Because both a <code>CachedRowSet</code> object and its metadata can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
 * created from scratch, a component that acts as a factory for rowsets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
 * can use this capability to create a rowset containing data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
 * non-SQL data sources. Nevertheless, it is expected that most of the time,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
 * <code>CachedRowSet</code> objects will contain data that was fetched
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
 * from an SQL database using the JDBC API.
20880
1b610151b316 8026812: doclint clean up for java.sql and javax.sql
lancea
parents: 18564
diff changeset
   393
 *
54106
9a90236ab64c 8220253: Fix Headings in java.sql.rowset
lancea
parents: 47216
diff changeset
   394
 * <h2>9.0 Setting Properties</h2>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
 * All rowsets maintain a set of properties, which will usually be set using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
 * a tool.  The number and kinds of properties a rowset has will vary,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
 * depending on what the rowset does and how it gets its data.  For example,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
 * rowsets that get their data from a <code>ResultSet</code> object need to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
 * set the properties that are required for making a database connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
 * If a rowset uses the <code>DriverManager</code> facility to make a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
 * connection, it needs to set a property for the JDBC URL that identifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
 * the appropriate driver, and it needs to set the properties that give the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
 * user name and password.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
 * If, on the other hand, the rowset uses a <code>DataSource</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
 * to make the connection, which is the preferred method, it does not need to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
 * set the property for the JDBC URL.  Instead, it needs to set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
 * properties for the logical name of the data source, for the user name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
 * and for the password.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
 * NOTE:  In order to use a <code>DataSource</code> object for making a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
 * connection, the <code>DataSource</code> object must have been registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
 * with a naming service that uses the Java Naming and Directory
18564
f9db68ff2cbb 8017471: Fix JDBC -Xdoclint public errors
lancea
parents: 18156
diff changeset
   413
 * Interface&trade; (JNDI) API.  This registration
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
 * is usually done by a person acting in the capacity of a system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
 * administrator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
 * In order to be able to populate itself with data from a database, a rowset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
 * needs to set a command property.  This property is a query that is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
 * <code>PreparedStatement</code> object, which allows the query to have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
 * parameter placeholders that are set at run time, as opposed to design time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
 * To set these placeholder parameters with values, a rowset provides
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
 * setter methods for setting values of each data type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
 * similar to the setter methods provided by the <code>PreparedStatement</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
 * interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
 * The following code fragment illustrates how the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
 * object <code>crs</code> might have its command property set.  Note that if a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
 * tool is used to set properties, this is the code that the tool would use.
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 6671
diff changeset
   429
 * <PRE>{@code
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
 *    crs.setCommand("SELECT FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
 *                   "WHERE CREDIT_LIMIT > ? AND REGION = ?");
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 6671
diff changeset
   432
 * } </PRE>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
 * The values that will be used to set the command's placeholder parameters are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
 * contained in the <code>RowSet</code> object's <code>params</code> field, which is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
 * <code>Vector</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
 * The <code>CachedRowSet</code> class provides a set of setter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
 * methods for setting the elements in its <code>params</code> field.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
 * following code fragment demonstrates setting the two parameters in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
 * query from the previous example.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
 *    crs.setInt(1, 5000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
 *    crs.setString(2, "West");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
 * The <code>params</code> field now contains two elements, each of which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
 * an array two elements long.  The first element is the parameter number;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
 * the second is the value to be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
 * In this case, the first element of <code>params</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
 * <code>1</code>, <code>5000</code>, and the second element is <code>2</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
 * <code>"West"</code>.  When an application calls the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
 * <code>execute</code>, it will in turn call on this <code>RowSet</code> object's reader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
 * which will in turn invoke its <code>readData</code> method. As part of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
 * its implementation, <code>readData</code> will get the values in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
 * <code>params</code> and use them to set the command's placeholder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
 * parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
 * The following code fragment gives an idea of how the reader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
 * does this, after obtaining the <code>Connection</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
 * <code>con</code>.
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 6671
diff changeset
   460
 * <PRE>{@code
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
 *    PreparedStatement pstmt = con.prepareStatement(crs.getCommand());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
 *    reader.decodeParams();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
 *    // decodeParams figures out which setter methods to use and does something
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
 *    // like the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
 *    //    for (i = 0; i < params.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
 *    //        pstmt.setObject(i + 1, params[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
 *    //    }
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 6671
diff changeset
   468
 * }</PRE>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
 * <P>
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 6671
diff changeset
   470
 * At this point, the command for <code>crs</code> is the query {@code "SELECT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
 * FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS WHERE CREDIT_LIMIT > 5000
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 6671
diff changeset
   472
 * AND REGION = "West"}.  After the <code>readData</code> method executes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
 * this command with the following line of code, it will have the data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
 * <code>rs</code> with which to populate <code>crs</code>.
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 6671
diff changeset
   475
 * <PRE>{@code
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
 *     ResultSet rs = pstmt.executeQuery();
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 6671
diff changeset
   477
 * }</PRE>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
 * The preceding code fragments give an idea of what goes on behind the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
 * scenes; they would not appear in an application, which would not invoke
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
 * methods like <code>readData</code> and <code>decodeParams</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
 * In contrast, the following code fragment shows what an application might do.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
 * It sets the rowset's command, sets the command's parameters, and executes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
 * the command. Simply by calling the <code>execute</code> method,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
 * <code>crs</code> populates itself with the requested data from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
 * table <code>CUSTOMERS</code>.
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 6671
diff changeset
   487
 * <PRE>{@code
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
 *    crs.setCommand("SELECT FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
 *                   "WHERE CREDIT_LIMIT > ? AND REGION = ?");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
 *    crs.setInt(1, 5000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
 *    crs.setString(2, "West");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
 *    crs.execute();
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 6671
diff changeset
   493
 * }</PRE>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
 *
54106
9a90236ab64c 8220253: Fix Headings in java.sql.rowset
lancea
parents: 47216
diff changeset
   495
 * <h2>10.0 Paging Data</h2>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
 * Because a <code>CachedRowSet</code> object stores data in memory,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
 * the amount of data that it can contain at any one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
 * time is determined by the amount of memory available. To get around this limitation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
 * a <code>CachedRowSet</code> object can retrieve data from a <code>ResultSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
 * object in chunks of data, called <i>pages</i>. To take advantage of this mechanism,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
 * an application sets the number of rows to be included in a page using the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
 * <code>setPageSize</code>. In other words, if the page size is set to five, a chunk
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
 * of five rows of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
 * data will be fetched from the data source at one time. An application can also
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
 * optionally set the maximum number of rows that may be fetched at one time.  If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
 * maximum number of rows is set to zero, or no maximum number of rows is set, there is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
 * no limit to the number of rows that may be fetched at a time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
 * After properties have been set,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
 * the <code>CachedRowSet</code> object must be populated with data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
 * using either the method <code>populate</code> or the method <code>execute</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
 * The following lines of code demonstrate using the method <code>populate</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
 * Note that this version of the method takes two parameters, a <code>ResultSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
 * handle and the row in the <code>ResultSet</code> object from which to start
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
 * retrieving rows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
 *     CachedRowSet crs = new CachedRowSetImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
 *     crs.setMaxRows(20);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
 *     crs.setPageSize(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
 *     crs.populate(rsHandle, 10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
 * When this code runs, <i>crs</i> will be populated with four rows from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
 * <i>rsHandle</i> starting with the tenth row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
 * The next code fragment shows populating a <code>CachedRowSet</code> object using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
 * method <code>execute</code>, which may or may not take a <code>Connection</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
 * object as a parameter.  This code passes <code>execute</code> the <code>Connection</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
 * object <i>conHandle</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
 * Note that there are two differences between the following code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
 * fragment and the previous one. First, the method <code>setMaxRows</code> is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
 * called, so there is no limit set for the number of rows that <i>crs</i> may contain.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
 * (Remember that <i>crs</i> always has the overriding limit of how much data it can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
 * store in memory.) The second difference is that the you cannot pass the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
 * <code>execute</code> the number of the row in the <code>ResultSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
 * from which to start retrieving rows. This method always starts with the first row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
 *     CachedRowSet crs = new CachedRowSetImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
 *     crs.setPageSize(5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
 *     crs.execute(conHandle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
 * After this code has run, <i>crs</i> will contain five rows of data from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
 * <code>ResultSet</code> object produced by the command for <i>crs</i>. The writer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
 * for <i>crs</i> will use <i>conHandle</i> to connect to the data source and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
 * execute the command for <i>crs</i>. An application is then able to operate on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
 * data in <i>crs</i> in the same way that it would operate on data in any other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
 * <code>CachedRowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
 * To access the next page (chunk of data), an application calls the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
 * <code>nextPage</code>.  This method creates a new <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
 * and fills it with the next page of data.  For example, assume that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
 * <code>CachedRowSet</code> object's command returns a <code>ResultSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
 * <i>rs</i> with 1000 rows of data.  If the page size has been set to 100, the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
 *  call to the method <code>nextPage</code> will create a <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
 * containing the first 100 rows of <i>rs</i>. After doing what it needs to do with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
 * data in these first 100 rows, the application can again call the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
 * <code>nextPage</code> to create another <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
 * with the second 100 rows from <i>rs</i>. The data from the first <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
 * object will no longer be in memory because it is replaced with the data from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
 * second <code>CachedRowSet</code> object. After the tenth call to the method <code>nextPage</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
 * the tenth <code>CachedRowSet</code> object will contain the last 100 rows of data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
 * <i>rs</i>, which are stored in memory. At any given time, the data from only one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
 * <code>CachedRowSet</code> object is stored in memory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
 * The method <code>nextPage</code> returns <code>true</code> as long as the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
 * page is not the last page of rows and <code>false</code> when there are no more pages.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
 * It can therefore be used in a <code>while</code> loop to retrieve all of the pages,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
 * as is demonstrated in the following lines of code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
 *     CachedRowSet crs = CachedRowSetImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
 *     crs.setPageSize(100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
 *     crs.execute(conHandle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
 *     while(crs.nextPage()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
 *         while(crs.next()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
 *             . . . // operate on chunks (of 100 rows each) in crs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
 *                   // row by row
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
 *         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
 *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
 * After this code fragment has been run, the application will have traversed all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
 * 1000 rows, but it will have had no more than 100 rows in memory at a time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
 * The <code>CachedRowSet</code> interface also defines the method <code>previousPage</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
 * Just as the method <code>nextPage</code> is analogous to the <code>ResultSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
 * method <code>next</code>, the method <code>previousPage</code> is analogous to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
 * the <code>ResultSet</code> method <code>previous</code>.  Similar to the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
 * <code>nextPage</code>, <code>previousPage</code> creates a <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
 * object containing the number of rows set as the page size.  So, for instance, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
 * method <code>previousPage</code> could be used in a <code>while</code> loop at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
 * the end of the preceding code fragment to navigate back through the pages from the last
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
 * page to the first page.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
 * The method <code>previousPage</code> is also similar to <code>nextPage</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
 * in that it can be used in a <code>while</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
 * loop, except that it returns <code>true</code> as long as there is another page
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
 * preceding it and <code>false</code> when there are no more pages ahead of it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
 * By positioning the cursor after the last row for each page,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
 * as is done in the following code fragment, the method <code>previous</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
 * navigates from the last row to the first row in each page.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
 * The code could also have left the cursor before the first row on each page and then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
 * used the method <code>next</code> in a <code>while</code> loop to navigate each page
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
 * from the first row to the last row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
 * The following code fragment assumes a continuation from the previous code fragment,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
 * meaning that the cursor for the tenth <code>CachedRowSet</code> object is on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
 * last row.  The code moves the cursor to after the last row so that the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
 * call to the method <code>previous</code> will put the cursor back on the last row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
 * After going through all of the rows in the last page (the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
 * object <i>crs</i>), the code then enters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
 * the <code>while</code> loop to get to the ninth page, go through the rows backwards,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
 * go to the eighth page, go through the rows backwards, and so on to the first row
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
 * of the first page.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
 *     crs.afterLast();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
 *     while(crs.previous())  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
 *         . . . // navigate through the rows, last to first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
 *     {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
 *     while(crs.previousPage())  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
 *         crs.afterLast();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
 *         while(crs.previous())  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
 *             . . . // go from the last row to the first row of each page
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
 *         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
 *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
 * @author Jonathan Bruce
24968
3308660aa3f2 8046389: Add missing @since tag under javax.sql.**
henryjen
parents: 24197
diff changeset
   629
 * @since 1.5
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
public interface CachedRowSet extends RowSet, Joinable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    * Populates this <code>CachedRowSet</code> object with data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    * the given <code>ResultSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    * This method can be used as an alternative to the <code>execute</code> method when an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    * application has a connection to an open <code>ResultSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    * Using the method <code>populate</code> can be more efficient than using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    * the version of the <code>execute</code> method that takes no parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    * because it does not open a new connection and re-execute this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    * <code>CachedRowSet</code> object's command. Using the <code>populate</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    * method is more a matter of convenience when compared to using the version
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    * of <code>execute</code> that takes a <code>ResultSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    * @param data the <code>ResultSet</code> object containing the data
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   648
    * to be read into this <code>CachedRowSet</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    * @throws SQLException if a null <code>ResultSet</code> object is supplied
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   650
    * or this <code>CachedRowSet</code> object cannot
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   651
    * retrieve the associated <code>ResultSetMetaData</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    * @see #execute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    * @see java.sql.ResultSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    * @see java.sql.ResultSetMetaData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    public void populate(ResultSet data) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    * Populates this <code>CachedRowSet</code> object with data, using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    * given connection to produce the result set from which the data will be read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    * This method should close any database connections that it creates to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    * ensure that this <code>CachedRowSet</code> object is disconnected except when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    * it is reading data from its data source or writing data to its data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    * The reader for this <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    * will use <i>conn</i> to establish a connection to the data source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    * so that it can execute the rowset's command and read data from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    * the resulting <code>ResultSet</code> object into this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    * <code>CachedRowSet</code> object. This method also closes <i>conn</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    * after it has populated this <code>CachedRowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    * If this method is called when an implementation has already been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    * populated, the contents and the metadata are (re)set. Also, if this method is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    * called before the method <code>acceptChanges</code> has been called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    * to commit outstanding updates, those updates are lost.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    * @param conn a standard JDBC <code>Connection</code> object with valid
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   678
    * properties
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    * @throws SQLException if an invalid <code>Connection</code> object is supplied
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   680
    * or an error occurs in establishing the connection to the
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   681
    * data source
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    * @see #populate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    * @see java.sql.Connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    public void execute(Connection conn) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    * Propagates row update, insert and delete changes made to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    * <code>CachedRowSet</code> object to the underlying data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    * This method calls on this <code>CachedRowSet</code> object's writer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    * to do the work behind the scenes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    * Standard <code>CachedRowSet</code> implementations should use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    * <code>SyncFactory</code> singleton
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    * to obtain a <code>SyncProvider</code> instance providing a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    * <code>RowSetWriter</code> object (writer).  The writer will attempt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    * to propagate changes made in this <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    * back to the data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    * When the method <code>acceptChanges</code> executes successfully, in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    * addition to writing changes to the data source, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    * makes the values in the current row be the values in the original row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    * Depending on the synchronization level of the <code>SyncProvider</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    * implementation being used, the writer will compare the original values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    * with those in the data source to check for conflicts. When there is a conflict,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    * the <code>RIOptimisticProvider</code> implementation, for example, throws a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    * <code>SyncProviderException</code> and does not write anything to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    * data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    * An application may choose to catch the <code>SyncProviderException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    * object and retrieve the <code>SyncResolver</code> object it contains.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    * The <code>SyncResolver</code> object lists the conflicts row by row and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    * sets a lock on the data source to avoid further conflicts while the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    * current conflicts are being resolved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    * Further, for each conflict, it provides methods for examining the conflict
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    * and setting the value that should be persisted in the data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    * After all conflicts have been resolved, an application must call the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    * <code>acceptChanges</code> method again to write resolved values to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    * data source.  If all of the values in the data source are already the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    * values to be persisted, the method <code>acceptChanges</code> does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    * Some provider implementations may use locks to ensure that there are no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    * conflicts.  In such cases, it is guaranteed that the writer will succeed in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    * writing changes to the data source when the method <code>acceptChanges</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    * is called.  This method may be called immediately after the methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    * <code>updateRow</code>, <code>insertRow</code>, or <code>deleteRow</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    * have been called, but it is more efficient to call it only once after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    * all changes have been made so that only one connection needs to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    * established.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    * Note: The <code>acceptChanges()</code> method will determine if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    * <code>COMMIT_ON_ACCEPT_CHANGES</code> is set to true or not. If it is set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    * to true, all updates in the synchronization are committed to the data
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 24968
diff changeset
   735
    * source. Otherwise, the application <b>must</b> explicitly call the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    * <code>commit()</code> or <code>rollback()</code> methods as appropriate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    * @throws SyncProviderException if the underlying
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   739
    * synchronization provider's writer fails to write the updates
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   740
    * back to the data source
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    * @see #acceptChanges(java.sql.Connection)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
    * @see javax.sql.RowSetWriter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    * @see javax.sql.rowset.spi.SyncFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    * @see javax.sql.rowset.spi.SyncProvider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    * @see javax.sql.rowset.spi.SyncProviderException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
    * @see javax.sql.rowset.spi.SyncResolver
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    public void acceptChanges() throws SyncProviderException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    * Propagates all row update, insert and delete changes to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
    * data source backing this <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    * using the specified <code>Connection</code> object to establish a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
    * connection to the data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    * The other version of the <code>acceptChanges</code> method is not passed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    * a connection because it uses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    * the <code>Connection</code> object already defined within the <code>RowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    * object, which is the connection used for populating it initially.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    * This form of the method <code>acceptChanges</code> is similar to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    * form that takes no arguments; however, unlike the other form, this form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    * can be used only when the underlying data source is a JDBC data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    * The updated <code>Connection</code> properties must be used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    * <code>SyncProvider</code> to reset the <code>RowSetWriter</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    * configuration to ensure that the contents of the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    * object are synchronized correctly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    * When the method <code>acceptChanges</code> executes successfully, in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    * addition to writing changes to the data source, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    * makes the values in the current row be the values in the original row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
    * Depending on the synchronization level of the <code>SyncProvider</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
    * implementation being used, the writer will compare the original values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
    * with those in the data source to check for conflicts. When there is a conflict,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    * the <code>RIOptimisticProvider</code> implementation, for example, throws a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
    * <code>SyncProviderException</code> and does not write anything to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
    * data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    * An application may choose to catch the <code>SyncProviderException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    * object and retrieve the <code>SyncResolver</code> object it contains.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
    * The <code>SyncResolver</code> object lists the conflicts row by row and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    * sets a lock on the data source to avoid further conflicts while the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
    * current conflicts are being resolved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    * Further, for each conflict, it provides methods for examining the conflict
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    * and setting the value that should be persisted in the data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    * After all conflicts have been resolved, an application must call the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    * <code>acceptChanges</code> method again to write resolved values to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    * data source.  If all of the values in the data source are already the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    * values to be persisted, the method <code>acceptChanges</code> does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    * Some provider implementations may use locks to ensure that there are no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    * conflicts.  In such cases, it is guaranteed that the writer will succeed in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    * writing changes to the data source when the method <code>acceptChanges</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    * is called.  This method may be called immediately after the methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    * <code>updateRow</code>, <code>insertRow</code>, or <code>deleteRow</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    * have been called, but it is more efficient to call it only once after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    * all changes have been made so that only one connection needs to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
    * established.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    * Note: The <code>acceptChanges()</code> method will determine if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    * <code>COMMIT_ON_ACCEPT_CHANGES</code> is set to true or not. If it is set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
    * to true, all updates in the synchronization are committed to the data
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 24968
diff changeset
   804
    * source. Otherwise, the application <b>must</b> explicitly call the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
    * <code>commit</code> or <code>rollback</code> methods as appropriate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
    * @param con a standard JDBC <code>Connection</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    * @throws SyncProviderException if the underlying
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   809
    * synchronization provider's writer fails to write the updates
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   810
    * back to the data source
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    * @see #acceptChanges()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    * @see javax.sql.RowSetWriter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    * @see javax.sql.rowset.spi.SyncFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    * @see javax.sql.rowset.spi.SyncProvider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    * @see javax.sql.rowset.spi.SyncProviderException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    * @see javax.sql.rowset.spi.SyncResolver
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    public void acceptChanges(Connection con) throws SyncProviderException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    * Restores this <code>CachedRowSet</code> object to its original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    * value, that is, its value before the last set of changes. If there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    * have been no changes to the rowset or only one set of changes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
    * the original value is the value with which this <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    * was populated; otherwise, the original value is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
    * the value it had immediately before its current value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    * When this method is called, a <code>CachedRowSet</code> implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    * must ensure that all updates, inserts, and deletes to the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    * rowset instance are replaced by the previous values. In addition,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    * the cursor should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
    * reset to the first row and a <code>rowSetChanged</code> event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
    * should be fired to notify all registered listeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    * @throws SQLException if an error occurs rolling back the current value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    *       this <code>CachedRowSet</code> object to its previous value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    * @see javax.sql.RowSetListener#rowSetChanged
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    public void restoreOriginal() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
    * Releases the current contents of this <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    * object and sends a <code>rowSetChanged</code> event to all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
    * registered listeners. Any outstanding updates are discarded and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
    * the rowset contains no rows after this method is called. There
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    * are no interactions with the underlying data source, and any rowset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    * content, metadata, and content updates should be non-recoverable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    * This <code>CachedRowSet</code> object should lock until its contents and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    * associated updates are fully cleared, thus preventing 'dirty' reads by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
    * other components that hold a reference to this <code>RowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    * In addition, the contents cannot be released
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 24968
diff changeset
   853
    * until all components reading this <code>CachedRowSet</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    * have completed their reads. This <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    * should be returned to normal behavior after firing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    * <code>rowSetChanged</code> event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    * The metadata, including JDBC properties and Synchronization SPI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    * properties, are maintained for future use. It is important that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    * properties such as the <code>command</code> property be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
    * relevant to the originating data source from which this <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
    * object was originally established.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    * This method empties a rowset, as opposed to the <code>close</code> method,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    * which marks the entire rowset as recoverable to allow the garbage collector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    * the rowset's Java VM resources.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
    * @throws SQLException if an error occurs flushing the contents of this
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   869
    * <code>CachedRowSet</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
    * @see javax.sql.RowSetListener#rowSetChanged
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    * @see java.sql.ResultSet#close
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    public void release() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    * Cancels the deletion of the current row and notifies listeners that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    * a row has changed. After this method is called, the current row is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    * no longer marked for deletion. This method can be called at any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    * time during the lifetime of the rowset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
    * In addition, multiple cancellations of row deletions can be made
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    * by adjusting the position of the cursor using any of the cursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    * position control methods such as:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
    * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    * <li><code>CachedRowSet.absolute</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
    * <li><code>CachedRowSet.first</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    * <li><code>CachedRowSet.last</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
    * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    * @throws SQLException if (1) the current row has not been deleted or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
    * (2) the cursor is on the insert row, before the first row, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    * after the last row
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
    * @see javax.sql.rowset.CachedRowSet#undoInsert
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    * @see java.sql.ResultSet#cancelRowUpdates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    public void undoDelete() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    * Immediately removes the current row from this <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
    * object if the row has been inserted, and also notifies listeners that a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
    * row has changed. This method can be called at any time during the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    * lifetime of a rowset and assuming the current row is within
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
    * the exception limitations (see below), it cancels the row insertion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    * of the current row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
    * In addition, multiple cancellations of row insertions can be made
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    * by adjusting the position of the cursor using any of the cursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    * position control methods such as:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
    * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    * <li><code>CachedRowSet.absolute</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
    * <li><code>CachedRowSet.first</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    * <li><code>CachedRowSet.last</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    * @throws SQLException if (1) the current row has not been inserted or (2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    * the cursor is before the first row, after the last row, or on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    * insert row
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
    * @see javax.sql.rowset.CachedRowSet#undoDelete
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
    * @see java.sql.ResultSet#cancelRowUpdates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
    public void undoInsert() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
    * Immediately reverses the last update operation if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
    * row has been modified. This method can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
    * called to reverse updates on all columns until all updates in a row have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
    * been rolled back to their state just prior to the last synchronization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    * (<code>acceptChanges</code>) or population. This method may also be called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
    * while performing updates to the insert row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
    * <code>undoUpdate</code> may be called at any time during the lifetime of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
    * rowset; however, after a synchronization has occurred, this method has no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
    * effect until further modification to the rowset data has occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    * @throws SQLException if the cursor is before the first row or after the last
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 24968
diff changeset
   937
    *     row in this <code>CachedRowSet</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
    * @see #undoDelete
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
    * @see #undoInsert
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
    * @see java.sql.ResultSet#cancelRowUpdates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
    public void undoUpdate() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
    * Indicates whether the designated column in the current row of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
    * <code>CachedRowSet</code> object has been updated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
    * @param idx an <code>int</code> identifying the column to be checked for updates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
    * @return <code>true</code> if the designated column has been visibly updated;
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   950
    * <code>false</code> otherwise
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    * @throws SQLException if the cursor is on the insert row, before the first row,
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   952
    *     or after the last row
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
    * @see java.sql.DatabaseMetaData#updatesAreDetected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
    public boolean columnUpdated(int idx) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
    * Indicates whether the designated column in the current row of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
    * <code>CachedRowSet</code> object has been updated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
    * @param columnName a <code>String</code> object giving the name of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
    *        column to be checked for updates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
    * @return <code>true</code> if the column has been visibly updated;
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   965
    * <code>false</code> otherwise
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
    * @throws SQLException if the cursor is on the insert row, before the first row,
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
   967
    *      or after the last row
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
    * @see java.sql.DatabaseMetaData#updatesAreDetected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
    public boolean columnUpdated(String columnName) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
    * Converts this <code>CachedRowSet</code> object to a <code>Collection</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
    * object that contains all of this <code>CachedRowSet</code> object's data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
    * Implementations have some latitude in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
    * how they can represent this <code>Collection</code> object because of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
    * abstract nature of the <code>Collection</code> framework.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
    * Each row must be fully represented in either a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
    * general purpose <code>Collection</code> implementation or a specialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
    * <code>Collection</code> implementation, such as a <code>TreeMap</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
    * object or a <code>Vector</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
    * An SQL <code>NULL</code> column value must be represented as a <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
    * in the Java programming language.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
    * The standard reference implementation for the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
    * interface uses a <code>TreeMap</code> object for the rowset, with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
    * values in each row being contained in  <code>Vector</code> objects. It is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
    * expected that most implementations will do the same.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
    * The <code>TreeMap</code> type of collection guarantees that the map will be in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
    * ascending key order, sorted according to the natural order for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    * key's class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
    * Each key references a <code>Vector</code> object that corresponds to one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
    * row of a <code>RowSet</code> object. Therefore, the size of each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    * <code>Vector</code> object  must be exactly equal to the number of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
    * columns in the <code>RowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
    * The key used by the <code>TreeMap</code> collection is determined by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
    * implementation, which may choose to leverage a set key that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
    * available within the internal <code>RowSet</code> tabular structure by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
    * virtue of a key already set either on the <code>RowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
    * itself or on the underlying SQL data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
    * @return a <code>Collection</code> object that contains the values in
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1004
    * each row in this <code>CachedRowSet</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
    * @throws SQLException if an error occurs generating the collection
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
    * @see #toCollection(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
    * @see #toCollection(String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
    public Collection<?> toCollection() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
    * Converts the designated column in this <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
    * to a <code>Collection</code> object. Implementations have some latitude in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
    * how they can represent this <code>Collection</code> object because of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
    * abstract nature of the <code>Collection</code> framework.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
    * Each column value should be fully represented in either a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
    * general purpose <code>Collection</code> implementation or a specialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
    * <code>Collection</code> implementation, such as a <code>Vector</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
    * An SQL <code>NULL</code> column value must be represented as a <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
    * in the Java programming language.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
    * The standard reference implementation uses a <code>Vector</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
    * to contain the column values, and it is expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
    * that most implementations will do the same. If a <code>Vector</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
    * is used, it size must be exactly equal to the number of rows
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
    * in this <code>CachedRowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
    * @param column an <code>int</code> indicating the column whose values
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
    *        are to be represented in a <code>Collection</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
    * @return a <code>Collection</code> object that contains the values
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1031
    * stored in the specified column of this <code>CachedRowSet</code>
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1032
    * object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
    * @throws SQLException if an error occurs generating the collection or
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1034
    * an invalid column id is provided
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
    * @see #toCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
    * @see #toCollection(String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
    public Collection<?> toCollection(int column) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
    * Converts the designated column in this <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
    * to a <code>Collection</code> object. Implementations have some latitude in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
    * how they can represent this <code>Collection</code> object because of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
    * abstract nature of the <code>Collection</code> framework.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
    * Each column value should be fully represented in either a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
    * general purpose <code>Collection</code> implementation or a specialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
    * <code>Collection</code> implementation, such as a <code>Vector</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
    * An SQL <code>NULL</code> column value must be represented as a <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
    * in the Java programming language.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
    * The standard reference implementation uses a <code>Vector</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
    * to contain the column values, and it is expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
    * that most implementations will do the same. If a <code>Vector</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
    * is used, it size must be exactly equal to the number of rows
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
    * in this <code>CachedRowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
    * @param column a <code>String</code> object giving the name of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
    *        column whose values are to be represented in a collection
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
    * @return a <code>Collection</code> object that contains the values
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1060
    * stored in the specified column of this <code>CachedRowSet</code>
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1061
    * object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
    * @throws SQLException if an error occurs generating the collection or
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1063
    * an invalid column id is provided
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
    * @see #toCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
    * @see #toCollection(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
    public Collection<?> toCollection(String column) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
    * Retrieves the <code>SyncProvider</code> implementation for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
    * <code>CachedRowSet</code> object. Internally, this method is used by a rowset
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
    * to trigger read or write actions between the rowset
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
    * and the data source. For example, a rowset may need to get a handle
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 24968
diff changeset
  1074
    * on the rowset reader (<code>RowSetReader</code> object) from the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
    * <code>SyncProvider</code> to allow the rowset to be populated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
    * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
    *     RowSetReader rowsetReader = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
    *     SyncProvider provider =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
    *         SyncFactory.getInstance("javax.sql.rowset.provider.RIOptimisticProvider");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
    *         if (provider instanceof RIOptimisticProvider) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
    *             rowsetReader = provider.getRowSetReader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
    *         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
    * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
    * Assuming <i>rowsetReader</i> is a private, accessible field within
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
    * the rowset implementation, when an application calls the <code>execute</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
    * method, it in turn calls on the reader's <code>readData</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
    * to populate the <code>RowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
    *<pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
    *     rowsetReader.readData((RowSetInternal)this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
    * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
    * In addition, an application can use the <code>SyncProvider</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
    * returned by this method to call methods that return information about the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
    * <code>SyncProvider</code> object, including information about the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
    * vendor, version, provider identification, synchronization grade, and locks
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
    * it currently has set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
    * @return the <code>SyncProvider</code> object that was set when the rowset
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 24968
diff changeset
  1099
    *      was instantiated, or if none was set, the default provider
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
    * @throws SQLException if an error occurs while returning the
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1101
    * <code>SyncProvider</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
    * @see #setSyncProvider
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
    public SyncProvider getSyncProvider() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
   /**
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20880
diff changeset
  1107
    * Sets the <code>SyncProvider</code> object for this <code>CachedRowSet</code>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
    * object to the one specified.  This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
    * allows the <code>SyncProvider</code> object to be reset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
    * A <code>CachedRowSet</code> implementation should always be instantiated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
    * with an available <code>SyncProvider</code> mechanism, but there are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
    * cases where resetting the <code>SyncProvider</code> object is desirable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
    * or necessary. For example, an application might want to use the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
    * <code>SyncProvider</code> object for a time and then choose to use a provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
    * that has more recently become available and better fits its needs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
    * Resetting the <code>SyncProvider</code> object causes the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
    * <code>RowSet</code> object to request a new <code>SyncProvider</code> implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
    * from the <code>SyncFactory</code>. This has the effect of resetting
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
    * all previous connections and relationships with the originating
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
    * data source and can potentially drastically change the synchronization
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
    * behavior of a disconnected rowset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
    * @param provider a <code>String</code> object giving the fully qualified class
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
    *        name of a <code>SyncProvider</code> implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
    * @throws SQLException if an error occurs while attempting to reset the
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1128
    * <code>SyncProvider</code> implementation
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
    * @see #getSyncProvider
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
    public void setSyncProvider(String provider) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
    * Returns the number of rows in this <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
    * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
    * @return number of rows in the rowset
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
    public int size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
    * Sets the metadata for this <code>CachedRowSet</code> object with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
    * the given <code>RowSetMetaData</code> object. When a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
    * <code>RowSetReader</code> object is reading the contents of a rowset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
    * it creates a <code>RowSetMetaData</code> object and initializes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
    * it using the methods in the <code>RowSetMetaData</code> implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
    * The reference implementation uses the <code>RowSetMetaDataImpl</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
    * class. When the reader has completed reading the rowset contents,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
    * this method is called internally to pass the <code>RowSetMetaData</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
    * object to the rowset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
    * @param md a <code>RowSetMetaData</code> object containing
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1153
    * metadata about the columns in this <code>CachedRowSet</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
    * @throws SQLException if invalid metadata is supplied to the
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1155
    * rowset
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
    public void setMetaData(RowSetMetaData md) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
    * Returns a <code>ResultSet</code> object containing the original value of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
    * <code>CachedRowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
    * The cursor for the <code>ResultSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
    * object should be positioned before the first row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
    * In addition, the returned <code>ResultSet</code> object should have the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
    * properties:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
    * <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
    * <LI>ResultSet.TYPE_SCROLL_INSENSITIVE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
    * <LI>ResultSet.CONCUR_UPDATABLE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
    * </UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
    * The original value for a <code>RowSet</code> object is the value it had before
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
    * the last synchronization with the underlying data source.  If there have been
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
    * no synchronizations, the original value will be the value with which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
    * <code>RowSet</code> object was populated.  This method is called internally
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20880
diff changeset
  1176
    * when an application calls the method <code>acceptChanges</code> and the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
    * <code>SyncProvider</code> object has been implemented to check for conflicts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
    * If this is the case, the writer compares the original value with the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
    * currently in the data source to check for conflicts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
    * @return a <code>ResultSet</code> object that contains the original value for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
    *         this <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
    * @throws SQLException if an error occurs producing the
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1184
    * <code>ResultSet</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
   public ResultSet getOriginal() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
    * Returns a <code>ResultSet</code> object containing the original value for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
    * current row only of this <code>CachedRowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
    * The cursor for the <code>ResultSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
    * object should be positioned before the first row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
    * In addition, the returned <code>ResultSet</code> object should have the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
    * properties:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
    * <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
    * <LI>ResultSet.TYPE_SCROLL_INSENSITIVE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
    * <LI>ResultSet.CONCUR_UPDATABLE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
    * </UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
    * @return the original result set of the row
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
    * @throws SQLException if there is no current row
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
    * @see #setOriginalRow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
    public ResultSet getOriginalRow() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
    * Sets the current row in this <code>CachedRowSet</code> object as the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
    * row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
    * This method is called internally after the any modified values in the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
    * row have been synchronized with the data source. The current row must be tagged
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
    * as no longer inserted, deleted or updated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
    * A call to <code>setOriginalRow</code> is irreversible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
    * @throws SQLException if there is no current row or an error is
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1218
    * encountered resetting the contents of the original row
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
    * @see #getOriginalRow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
    public void setOriginalRow() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
    * Returns an identifier for the object (table) that was used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
    * create this <code>CachedRowSet</code> object. This name may be set on multiple occasions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
    * and the specification imposes no limits on how many times this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
    * may occur or whether standard implementations should keep track
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
    * of previous table names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
    * @return a <code>String</code> object giving the name of the table that is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
    *         source of data for this <code>CachedRowSet</code> object or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
    *         if no name has been set for the table
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
    * @throws SQLException if an error is encountered returning the table name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
    * @see javax.sql.RowSetMetaData#getTableName
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
    public String getTableName() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
    * Sets the identifier for the table from which this <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
    * object was derived to the given table name. The writer uses this name to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
    * determine which table to use when comparing the values in the data source with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
    * <code>CachedRowSet</code> object's values during a synchronization attempt.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
    * The table identifier also indicates where modified values from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
    * <code>CachedRowSet</code> object should be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
    * The implementation of this <code>CachedRowSet</code> object may obtain the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
    * the name internally from the <code>RowSetMetaDataImpl</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
    * @param tabName a <code>String</code> object identifying the table from which this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
             <code>CachedRowSet</code> object was derived; cannot be <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
    *         but may be an empty string
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
    * @throws SQLException if an error is encountered naming the table or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
    *     <i>tabName</i> is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
    * @see javax.sql.RowSetMetaData#setTableName
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
    * @see javax.sql.RowSetWriter
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
    * @see javax.sql.rowset.spi.SyncProvider
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
   public void setTableName(String tabName) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
    * Returns an array containing one or more column numbers indicating the columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
    * that form a key that uniquely
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
    * identifies a row in this <code>CachedRowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
    * @return an array containing the column number or numbers that indicate which columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
    *       constitute a primary key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
    *       for a row in this <code>CachedRowSet</code> object. This array should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
    *       empty if no columns are representative of a primary key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
    * @throws SQLException if this <code>CachedRowSet</code> object is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
    * @see #setKeyColumns
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
    * @see Joinable#getMatchColumnIndexes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
    * @see Joinable#getMatchColumnNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
    public int[] getKeyColumns() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
    * Sets this <code>CachedRowSet</code> object's <code>keyCols</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
    * field with the given array of column numbers, which forms a key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
    * for uniquely identifying a row in this <code>CachedRowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
    * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
    * If a <code>CachedRowSet</code> object becomes part of a <code>JoinRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
    * object, the keys defined by this method and the resulting constraints are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
    * maintained if the columns designated as key columns also become match
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
    * columns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
    * @param keys an array of <code>int</code> indicating the columns that form
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
    *        a primary key for this <code>CachedRowSet</code> object; every
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
    *        element in the array must be greater than <code>0</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
    *        less than or equal to the number of columns in this rowset
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
    * @throws SQLException if any of the numbers in the given array
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
    *            are not valid for this rowset
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
    * @see #getKeyColumns
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
    * @see Joinable#setMatchColumn(String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
    * @see Joinable#setMatchColumn(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
    public void setKeyColumns(int[] keys) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
    * Returns a new <code>RowSet</code> object backed by the same data as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
    * that of this <code>CachedRowSet</code> object. In effect, both
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
    * <code>CachedRowSet</code> objects have a cursor over the same data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
    * As a result, any changes made by a duplicate are visible to the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
    * and to any other duplicates, just as a change made by the original is visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
    * to all of its duplicates. If a duplicate calls a method that changes the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
    * underlying data, the method it calls notifies all registered listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
    * just as it would when it is called by the original <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
    * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
    * In addition, any <code>RowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
    * created by this method will have the same properties as this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
    * <code>CachedRowSet</code> object. For example, if this <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
    * object is read-only, all of its duplicates will also be read-only. If it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
    * changed to be updatable, the duplicates also become updatable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
    * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
    * NOTE: If multiple threads access <code>RowSet</code> objects created from
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
    * the <code>createShared()</code> method, the following behavior is specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
    * to preserve shared data integrity: reads and writes of all
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
    * shared <code>RowSet</code> objects should be made serially between each
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
    * object and the single underlying tabular structure.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
    * @return a new shared <code>RowSet</code> object that has the same properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
    *         as this <code>CachedRowSet</code> object and that has a cursor over
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
    *         the same data
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
    * @throws SQLException if an error occurs or cloning is not
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1327
    * supported in the underlying platform
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
    * @see javax.sql.RowSetEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
    * @see javax.sql.RowSetListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
    public RowSet createShared() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
    * Creates a <code>RowSet</code> object that is a deep copy of the data in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
    * this <code>CachedRowSet</code> object. In contrast to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
    * the <code>RowSet</code> object generated from a <code>createShared</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
    * call, updates made to the copy of the original <code>RowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
    * must not be visible to the original <code>RowSet</code> object. Also, any
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
    * event listeners that are registered with the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
    * <code>RowSet</code> must not have scope over the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
    * <code>RowSet</code> copies. In addition, any constraint restrictions
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
    * established must be maintained.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
    * @return a new <code>RowSet</code> object that is a deep copy
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1345
    * of this <code>CachedRowSet</code> object and is
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1346
    * completely independent of this <code>CachedRowSet</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
    * @throws SQLException if an error occurs in generating the copy of
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1348
    * the of this <code>CachedRowSet</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
    * @see #createShared
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
    * @see #createCopySchema
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
    * @see #createCopyNoConstraints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
    * @see javax.sql.RowSetEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
    * @see javax.sql.RowSetListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
    public CachedRowSet createCopy() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
     * Creates a <code>CachedRowSet</code> object that is an empty copy of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
     * <code>CachedRowSet</code> object.  The copy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
     * must not contain any contents but only represent the table
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
     * structure of the original <code>CachedRowSet</code> object. In addition, primary
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
     * or foreign key constraints set in the originating <code>CachedRowSet</code> object must
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
     * be equally enforced in the new empty <code>CachedRowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
     * In contrast to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
     * the <code>RowSet</code> object generated from a <code>createShared</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
     * call, updates made to a copy of this <code>CachedRowSet</code> object with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
     * <code>createCopySchema</code> method must not be visible to it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
     * Applications can form a <code>WebRowSet</code> object from the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
     * object returned by this method in order
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
     * to export the <code>RowSet</code> schema definition to XML for future use.
18564
f9db68ff2cbb 8017471: Fix JDBC -Xdoclint public errors
lancea
parents: 18156
diff changeset
  1372
     * @return An empty copy of this {@code CachedRowSet} object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
     * @throws SQLException if an error occurs in cloning the structure of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
     *         <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
     * @see #createShared
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
     * @see #createCopySchema
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
     * @see #createCopyNoConstraints
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
     * @see javax.sql.RowSetEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
     * @see javax.sql.RowSetListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
    public CachedRowSet createCopySchema() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
     * Creates a <code>CachedRowSet</code> object that is a deep copy of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
     * this <code>CachedRowSet</code> object's data but is independent of it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
     * In contrast to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
     * the <code>RowSet</code> object generated from a <code>createShared</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
     * method call, updates made to a copy of this <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
     * must not be visible to it. Also, any
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
     * event listeners that are registered with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
     * <code>CachedRowSet</code> object must not have scope over the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
     * <code>RowSet</code> object. In addition, any constraint restrictions
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
     * established for this <code>CachedRowSet</code> object must <b>not</b> be maintained
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
     * in the copy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
     * @return a new <code>CachedRowSet</code> object that is a deep copy
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1397
     *     of this <code>CachedRowSet</code> object and is
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1398
     *     completely independent of this  <code>CachedRowSet</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
     * @throws SQLException if an error occurs in generating the copy of
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1400
     *     the of this <code>CachedRowSet</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
     * @see #createCopy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
     * @see #createShared
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
     * @see #createCopySchema
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
     * @see javax.sql.RowSetEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
     * @see javax.sql.RowSetListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
    public CachedRowSet createCopyNoConstraints() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
     * Retrieves the first warning reported by calls on this <code>RowSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
     * Subsequent warnings on this <code>RowSet</code> object will be chained to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
     * <code>RowSetWarning</code> object that this method returns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
     * The warning chain is automatically cleared each time a new row is read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
     * This method may not be called on a RowSet object that has been closed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
     * doing so will cause a <code>SQLException</code> to be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
     * @return RowSetWarning the first <code>RowSetWarning</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
     * object reported or null if there are none
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
     * @throws SQLException if this method is called on a closed RowSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
     * @see RowSetWarning
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
    public RowSetWarning getRowSetWarnings() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
     * Retrieves a <code>boolean</code> indicating whether rows marked
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
     * for deletion appear in the set of current rows. If <code>true</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
     * returned, deleted rows are visible with the current rows. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
     * <code>false</code> is returned, rows are not visible with the set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
     * current rows. The default value is <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
     * Standard rowset implementations may choose to restrict this behavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
     * due to security considerations or to better fit certain deployment
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
     * scenarios. This is left as implementation defined and does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
     * represent standard behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
     * Note: Allowing deleted rows to remain visible complicates the behavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
     * of some standard JDBC <code>RowSet</code> Implementations methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
     * However, most rowset users can simply ignore this extra detail because
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
     * only very specialized applications will likely want to take advantage of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
     * this feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
     * @return <code>true</code> if deleted rows are visible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
     *         <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
     * @throws SQLException if a rowset implementation is unable to
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1446
     * to determine whether rows marked for deletion are visible
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
     * @see #setShowDeleted
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
    public boolean getShowDeleted() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
     * Sets the property <code>showDeleted</code> to the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
     * <code>boolean</code> value, which determines whether
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
     * rows marked for deletion appear in the set of current rows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
     * If the value is set to <code>true</code>, deleted rows are immediately
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
     * visible with the set of current rows. If the value is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
     * <code>false</code>, the deleted rows are set as invisible with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
     * current set of rows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
     * Standard rowset implementations may choose to restrict this behavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
     * due to security considerations or to better fit certain deployment
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
     * scenarios. This is left as implementations defined and does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
     * represent standard behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
     * @param b <code>true</code> if deleted rows should be shown;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
     *              <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
     * @exception SQLException if a rowset implementation is unable to
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1468
     * to reset whether deleted rows should be visible
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
     * @see #getShowDeleted
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
    public void setShowDeleted(boolean b) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
     * Each <code>CachedRowSet</code> object's <code>SyncProvider</code> contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
     * a <code>Connection</code> object from the <code>ResultSet</code> or JDBC
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
     * properties passed to it's constructors. This method wraps the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
     * <code>Connection</code> commit method to allow flexible
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
     * auto commit or non auto commit transactional control support.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
     * Makes all changes that are performed by the <code>acceptChanges()</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
     * method since the previous commit/rollback permanent. This method should
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
     * be used only when auto-commit mode has been disabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
     * @throws SQLException if a database access error occurs or this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
     * Connection object within this <code>CachedRowSet</code> is in auto-commit mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
     * @see java.sql.Connection#setAutoCommit
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
    public void commit() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
     * Each <code>CachedRowSet</code> object's <code>SyncProvider</code> contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
     * a <code>Connection</code> object from the original <code>ResultSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
     * or JDBC properties passed to it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
     * Undoes all changes made in the current transaction.  This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
     * should be used only when auto-commit mode has been disabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
     * @throws SQLException if a database access error occurs or this Connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
     * object within this <code>CachedRowSet</code> is in auto-commit mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
    public void rollback() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
     * Each <code>CachedRowSet</code> object's <code>SyncProvider</code> contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
     * a <code>Connection</code> object from the original <code>ResultSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
     * or JDBC properties passed to it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
     * Undoes all changes made in the current transaction back to the last
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
     * <code>Savepoint</code> transaction marker. This method should be used only
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
     * when auto-commit mode has been disabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
     * @param s A <code>Savepoint</code> transaction marker
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
     * @throws SQLException if a database access error occurs or this Connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
     * object within this <code>CachedRowSet</code> is in auto-commit mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
    public void rollback(Savepoint s) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
     * Causes the <code>CachedRowSet</code> object's <code>SyncProvider</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
     * to commit the changes when <code>acceptChanges()</code> is called. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
     * set to false, the changes will <b>not</b> be committed until one of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
     * <code>CachedRowSet</code> interface transaction methods is called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
     *
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1524
     * @deprecated Because this field is final (it is part of an interface),
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1525
     *  its value cannot be changed.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
     * @see #commit
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
     * @see #rollback
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
     */
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1529
    @Deprecated
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
    public static final boolean COMMIT_ON_ACCEPT_CHANGES = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
     * Notifies registered listeners that a RowSet object in the given RowSetEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
     * object has populated a number of additional rows. The <code>numRows</code> parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
     * ensures that this event will only be fired every <code>numRow</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
     * The source of the event can be retrieved with the method event.getSource.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
     * @param event a <code>RowSetEvent</code> object that contains the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
     *     <code>RowSet</code> object that is the source of the events
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
     * @param numRows when populating, the number of rows interval on which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
     *     <code>CachedRowSet</code> populated should fire; the default value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
     *     is zero; cannot be less than <code>fetchSize</code> or zero
18564
f9db68ff2cbb 8017471: Fix JDBC -Xdoclint public errors
lancea
parents: 18156
diff changeset
  1544
     * @throws SQLException {@code numRows < 0 or numRows < getFetchSize() }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
    public void rowSetPopulated(RowSetEvent event, int numRows) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
     * Populates this <code>CachedRowSet</code> object with data from
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
     * the given <code>ResultSet</code> object. While related to the <code>populate(ResultSet)</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
     * method, an additional parameter is provided to allow starting position within
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
     * the <code>ResultSet</code> from where to populate the CachedRowSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
     * instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
     * This method can be used as an alternative to the <code>execute</code> method when an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
     * application has a connection to an open <code>ResultSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
     * Using the method <code>populate</code> can be more efficient than using
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
     * the version of the <code>execute</code> method that takes no parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
     * because it does not open a new connection and re-execute this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
     * <code>CachedRowSet</code> object's command. Using the <code>populate</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
     *  method is more a matter of convenience when compared to using the version
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
     * of <code>execute</code> that takes a <code>ResultSet</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
     * @param startRow the position in the <code>ResultSet</code> from where to start
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
     *                populating the records in this <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
     * @param rs the <code>ResultSet</code> object containing the data
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1567
     * to be read into this <code>CachedRowSet</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
     * @throws SQLException if a null <code>ResultSet</code> object is supplied
6529
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1569
     * or this <code>CachedRowSet</code> object cannot
bdf98f8db729 6843995: RowSet 1.1 updates
lancea
parents: 5506
diff changeset
  1570
     * retrieve the associated <code>ResultSetMetaData</code> object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
     * @see #execute
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
     * @see #populate(ResultSet)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
     * @see java.sql.ResultSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
     * @see java.sql.ResultSetMetaData
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
    public void populate(ResultSet rs, int startRow) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
     * Sets the <code>CachedRowSet</code> object's page-size. A <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
     * may be configured to populate itself in page-size sized batches of rows. When
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
     * either <code>populate()</code> or <code>execute()</code> are called, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
     * <code>CachedRowSet</code> fetches an additional page according to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
     * original SQL query used to populate the RowSet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
     * @param size the page-size of the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
     * @throws SQLException if an error occurs setting the <code>CachedRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
     *      page size or if the page size is less than 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
    public void setPageSize(int size) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
     * Returns the page-size for the <code>CachedRowSet</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
     * @return an <code>int</code> page size
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
    public int getPageSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
     * Increments the current page of the <code>CachedRowSet</code>. This causes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
     * the <code>CachedRowSet</code> implementation to fetch the next page-size
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
     * rows and populate the RowSet, if remaining rows remain within scope of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
     * original SQL query used to populated the RowSet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
     * @return true if more pages exist; false if this is the last page
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
     * @throws SQLException if an error occurs fetching the next page, or if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
     *     method is called prematurely before populate or execute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
    public boolean nextPage() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
     * Decrements the current page of the <code>CachedRowSet</code>. This causes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
     * the <code>CachedRowSet</code> implementation to fetch the previous page-size
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
     * rows and populate the RowSet. The amount of rows returned in the previous
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
     * page must always remain within scope of the original SQL query used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
     * populate the RowSet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
     * @return true if the previous page is successfully retrieved; false if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
     *     is the first page.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
     * @throws SQLException if an error occurs fetching the previous page, or if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
     *     this method is called prematurely before populate or execute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
    public boolean previousPage() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
}