PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Java|javax|sql|rowset|JdbcRowSet.java =

page 1 of 3



/*
 * @(#)JdbcRowSet.java	1.6 06/05/28
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package javax.sql.rowset;

import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import java.io.*;
import java.math.*;
import java.io.*;

/**
 * The standard interface that all standard implementations of 
 * <code>JdbcRowSet</code> must implement.
 *
 * <h3>1.0 Overview</h3>
 * A wrapper around a <code>ResultSet</code> object that makes it possible
 * to use the result set as a JavaBeans<sup><font size=-2>TM</font></sup>
 * component.  Thus, a <code>JdbcRowSet</code> object can be one of the Beans that 
 * a tool makes available for composing an application.  Because 
 * a <code>JdbcRowSet</code> is a connected rowset, that is, it continually
 * maintains its connection to a database using a JDBC technology-enabled
 * driver, it also effectively makes the driver a JavaBeans component.
 * <P>
 * Because it is always connected to its database, an instance of 
 * <code>JdbcRowSet</code>
 * can simply take calls invoked on it and in turn call them on its
 * <code>ResultSet</code> object. As a consequence, a result set can, for
 * example, be a component in a Swing application.
 * <P>
 * Another advantage of a <code>JdbcRowSet</code> object is that it can be
 * used to make a <code>ResultSet</code> object scrollable and updatable.  All
 * <code>RowSet</code> objects are by default scrollable and updatable. If
 * the driver and database being used do not support scrolling and/or updating
 * of result sets, an application can populate a <code>JdbcRowSet</code> object
 * with the data of a <code>ResultSet</code> object and then operate on the
 * <code>JdbcRowSet</code> object as if it were the <code>ResultSet</code>
 * object.   
 * <P>
 * <h3>2.0 Creating a <code>JdbcRowSet</code> Object</h3>
 * The reference implementation of the <code>JdbcRowSet</code> interface, 
 * <code>JdbcRowSetImpl</code>, provides an implementation of
 * the default constructor.  A new instance is initialized with
 * default values, which can be set with new values as needed. A
 * new instance is not really functional until its <code>execute</code>
 * method is called. In general, this method does the following:
 * <UL>
 *   <LI> establishes a connection with a database
 *   <LI> creates a <code>PreparedStatement</code> object and sets any of its
 *        placeholder parameters
 *   <LI> executes the statement to create a <code>ResultSet</code> object
 * </UL>
 * If the <code>execute</code> method is successful, it will set the 
 * appropriate private <code>JdbcRowSet</code> fields with the following:
 * <UL>
 *  <LI> a <code>Connection</code> object -- the connection between the rowset
 *       and the database
 *  <LI> a <code>PreparedStatement</code> object -- the query that produces
 *       the result set
 *  <LI> a <code>ResultSet</code> object -- the result set that the rowset's
 *       command produced and that is being made, in effect, a JavaBeans
 *       component       
 * </UL>
 * If these fields have not been set, meaning that the <code>execute</code>
 * method has not executed successfully, no methods other than
 * <code>execute</code> and <code>close</code> may be called on the
 * rowset.  All other public methods will throw an exception.
 * <P>
 * Before calling the <code>execute</code> method, however, the command
 * and properties needed for establishing a connection must be set.
 * The following code fragment creates a <code>JdbcRowSetImpl</code> object,
 * sets the command and connection properties, sets the placeholder parameter,
 * and then invokes the method <code>execute</code>.
 * <PRE>
 *     JdbcRowSetImpl jrs = new JdbcRowSetImpl();
 *     jrs.setCommand("SELECT * FROM TITLES WHERE TYPE = ?");
 *     jrs.setURL("jdbc:myDriver:myAttribute");
 *     jrs.setUsername("cervantes");
 *     jrs.setPassword("sancho");
 *     jrs.setString(1, "BIOGRAPHY");
 *     jrs.execute();
 * </PRE>
 * The variable <code>jrs</code> now represents an instance of
 * <code>JdbcRowSetImpl</code> that is a thin wrapper around the
 * <code>ResultSet</code> object containing all the rows in the
 * table <code>TITLES</code> where the type of book is biography.
 * At this point, operations called on <code>jrs</code> will
 * affect the rows in the result set, which is effectively a JavaBeans
 * component.
 * <P>
 * The implementation of the <code>RowSet</code> method <code>execute</code> in the  
 * <code>JdbcRowSet</code> reference implementation differs from that in the 
 * <code>CachedRowSet</code><sup><font size=-2>TM</font></sup> 
 * reference implementation to account for the different
 * requirements of connected and disconnected <code>RowSet</code> objects.
=1=

= PAGE 1 = NEXT > |2|3

UP TO ROOT | UP TO DIR

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.0236568 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU)