Source Code Cross Referenced for JdbcRowSet.java in  » 6.0-JDK-Core » sql » javax » sql » rowset » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » sql » javax.sql.rowset 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package javax.sql.rowset;
027
028        import java.sql.*;
029        import javax.sql.*;
030        import javax.naming.*;
031        import java.io.*;
032        import java.math.*;
033        import java.io.*;
034
035        /**
036         * The standard interface that all standard implementations of 
037         * <code>JdbcRowSet</code> must implement.
038         *
039         * <h3>1.0 Overview</h3>
040         * A wrapper around a <code>ResultSet</code> object that makes it possible
041         * to use the result set as a JavaBeans<sup><font size=-2>TM</font></sup>
042         * component.  Thus, a <code>JdbcRowSet</code> object can be one of the Beans that 
043         * a tool makes available for composing an application.  Because 
044         * a <code>JdbcRowSet</code> is a connected rowset, that is, it continually
045         * maintains its connection to a database using a JDBC technology-enabled
046         * driver, it also effectively makes the driver a JavaBeans component.
047         * <P>
048         * Because it is always connected to its database, an instance of 
049         * <code>JdbcRowSet</code>
050         * can simply take calls invoked on it and in turn call them on its
051         * <code>ResultSet</code> object. As a consequence, a result set can, for
052         * example, be a component in a Swing application.
053         * <P>
054         * Another advantage of a <code>JdbcRowSet</code> object is that it can be
055         * used to make a <code>ResultSet</code> object scrollable and updatable.  All
056         * <code>RowSet</code> objects are by default scrollable and updatable. If
057         * the driver and database being used do not support scrolling and/or updating
058         * of result sets, an application can populate a <code>JdbcRowSet</code> object
059         * with the data of a <code>ResultSet</code> object and then operate on the
060         * <code>JdbcRowSet</code> object as if it were the <code>ResultSet</code>
061         * object.   
062         * <P>
063         * <h3>2.0 Creating a <code>JdbcRowSet</code> Object</h3>
064         * The reference implementation of the <code>JdbcRowSet</code> interface, 
065         * <code>JdbcRowSetImpl</code>, provides an implementation of
066         * the default constructor.  A new instance is initialized with
067         * default values, which can be set with new values as needed. A
068         * new instance is not really functional until its <code>execute</code>
069         * method is called. In general, this method does the following:
070         * <UL>
071         *   <LI> establishes a connection with a database
072         *   <LI> creates a <code>PreparedStatement</code> object and sets any of its
073         *        placeholder parameters
074         *   <LI> executes the statement to create a <code>ResultSet</code> object
075         * </UL>
076         * If the <code>execute</code> method is successful, it will set the 
077         * appropriate private <code>JdbcRowSet</code> fields with the following:
078         * <UL>
079         *  <LI> a <code>Connection</code> object -- the connection between the rowset
080         *       and the database
081         *  <LI> a <code>PreparedStatement</code> object -- the query that produces
082         *       the result set
083         *  <LI> a <code>ResultSet</code> object -- the result set that the rowset's
084         *       command produced and that is being made, in effect, a JavaBeans
085         *       component       
086         * </UL>
087         * If these fields have not been set, meaning that the <code>execute</code>
088         * method has not executed successfully, no methods other than
089         * <code>execute</code> and <code>close</code> may be called on the
090         * rowset.  All other public methods will throw an exception.
091         * <P>
092         * Before calling the <code>execute</code> method, however, the command
093         * and properties needed for establishing a connection must be set.
094         * The following code fragment creates a <code>JdbcRowSetImpl</code> object,
095         * sets the command and connection properties, sets the placeholder parameter,
096         * and then invokes the method <code>execute</code>.
097         * <PRE>
098         *     JdbcRowSetImpl jrs = new JdbcRowSetImpl();
099         *     jrs.setCommand("SELECT * FROM TITLES WHERE TYPE = ?");
100         *     jrs.setURL("jdbc:myDriver:myAttribute");
101         *     jrs.setUsername("cervantes");
102         *     jrs.setPassword("sancho");
103         *     jrs.setString(1, "BIOGRAPHY");
104         *     jrs.execute();
105         * </PRE>
106         * The variable <code>jrs</code> now represents an instance of
107         * <code>JdbcRowSetImpl</code> that is a thin wrapper around the
108         * <code>ResultSet</code> object containing all the rows in the
109         * table <code>TITLES</code> where the type of book is biography.
110         * At this point, operations called on <code>jrs</code> will
111         * affect the rows in the result set, which is effectively a JavaBeans
112         * component.
113         * <P>
114         * The implementation of the <code>RowSet</code> method <code>execute</code> in the  
115         * <code>JdbcRowSet</code> reference implementation differs from that in the 
116         * <code>CachedRowSet</code><sup><font size=-2>TM</font></sup> 
117         * reference implementation to account for the different
118         * requirements of connected and disconnected <code>RowSet</code> objects.
119         * <p>
120         *
121         * @author Jonathan Bruce
122         */
123
124        public interface JdbcRowSet extends RowSet, Joinable {
125
126            /**
127             * Retrieves a <code>boolean</code> indicating whether rows marked
128             * for deletion appear in the set of current rows. If <code>true</code> is 
129             * returned, deleted rows are visible with the current rows. If 
130             * <code>false</code> is returned, rows are not visible with the set of 
131             * current rows. The default value is <code>false</code>.
132             * <P>
133             * Standard rowset implementations may choose to restrict this behavior
134             * for security considerations or for certain deployment
135             * scenarios. The visibility of deleted rows is implementation-defined 
136             * and does not represent standard behavior.          
137             * <P>
138             * Note: Allowing deleted rows to remain visible complicates the behavior
139             * of some standard JDBC <code>RowSet</code> implementations methods. 
140             * However, most rowset users can simply ignore this extra detail because 
141             * only very specialized applications will likely want to take advantage of
142             * this feature.
143             *
144             * @return <code>true</code> if deleted rows are visible;
145             *         <code>false</code> otherwise
146             * @exception SQLException if a rowset implementation is unable to
147             *		to determine whether rows marked for deletion remain visible
148             * @see #setShowDeleted
149             */
150            public boolean getShowDeleted() throws SQLException;
151
152            /**
153             * Sets the property <code>showDeleted</code> to the given
154             * <code>boolean</code> value. This property determines whether
155             * rows marked for deletion continue to appear in the set of current rows.
156             * If the value is set to <code>true</code>, deleted rows are immediately
157             * visible with the set of current rows. If the value is set to 
158             * <code>false</code>, the deleted rows are set as invisible with the
159             * current set of rows.
160             * <P>
161             * Standard rowset implementations may choose to restrict this behavior
162             * for security considerations or for certain deployment
163             * scenarios. This is left as implementation-defined and does not
164             * represent standard behavior.
165             *
166             * @param b <code>true</code> if deleted rows should be shown;
167             *              <code>false</code> otherwise
168             * @exception SQLException if a rowset implementation is unable to
169             *		to reset whether deleted rows should be visible
170             * @see #getShowDeleted
171             */
172            public void setShowDeleted(boolean b) throws SQLException;
173
174            /**
175             * Retrieves the first warning reported by calls on this <code>JdbcRowSet</code>
176             * object.
177             * If a second warning was reported on this <code>JdbcRowSet</code> object,
178             * it will be chained to the first warning and can be retrieved by
179             * calling the method <code>RowSetWarning.getNextWarning</code> on the
180             * first warning. Subsequent warnings on this <code>JdbcRowSet</code> 
181             * object will be chained to the <code>RowSetWarning</code> objects
182             * returned by the method <code>RowSetWarning.getNextWarning</code>.
183             *
184             * The warning chain is automatically cleared each time a new row is read.
185             * This method may not be called on a <code>RowSet</code> object 
186             * that has been closed;
187             * doing so will cause an <code>SQLException</code> to be thrown.
188             * <P>
189             * Because it is always connected to its data source, a <code>JdbcRowSet</code>
190             * object can rely on the presence of active 
191             * <code>Statement</code>, <code>Connection</code>, and <code>ResultSet</code>
192             * instances. This means that  applications can obtain additional 
193             * <code>SQLWarning</code> 
194             * notifications by calling the <code>getNextWarning</code> methods that 
195             * they provide.
196             * Disconnected <code>Rowset</code> objects, such as a 
197             * <code>CachedRowSet</code> object, do not have access to 
198             * these <code>getNextWarning</code> methods. 
199             * 
200             * @return the first <code>RowSetWarning</code> 
201             * object reported on this <code>JdbcRowSet</code> object
202             * or <code>null</code> if there are none
203             * @throws SQLException if this method is called on a closed 
204             * <code>JdbcRowSet</code> object
205             * @see RowSetWarning
206             */
207            public RowSetWarning getRowSetWarnings() throws SQLException;
208
209            /**
210             * Each <code>JdbcRowSet</code> contains a <code>Connection</code> object from
211             * the <code>ResultSet</code> or JDBC properties passed to it's constructors.
212             * This method wraps the <code>Connection</code> commit method to allow flexible
213             * auto commit or non auto commit transactional control support.
214             * <p>
215             * Makes all changes made since the previous commit/rollback permanent 
216             * and releases any database locks currently held by this Connection 
217             * object. This method should be used only when auto-commit mode has 
218             * been disabled.
219             *
220             * @throws SQLException if a database access error occurs or this 
221             * Connection object within this <code>JdbcRowSet</code> is in auto-commit mode
222             * @see java.sql.Connection#setAutoCommit
223             */
224            public void commit() throws SQLException;
225
226            /** 
227             * Each <code>JdbcRowSet</code> contains a <code>Connection</code> object from
228             * the original <code>ResultSet</code> or JDBC properties passed to it. This 
229             * method wraps the <code>Connection</code>'s <code>getAutoCommit</code> method
230             * to allow an application to determine the <code>JdbcRowSet</code> transaction
231             * behavior.
232             * <p>
233             * Sets this connection's auto-commit mode to the given state. If a   
234             * connection is in auto-commit mode, then all its SQL statements will   
235             * be executed and committed as individual transactions. Otherwise, its  
236             * SQL statements are grouped into transactions that are terminated by a 
237             * call to either the method commit or the method rollback. By default,  
238             * new connections are in auto-commit mode.
239             *
240             * @throws SQLException if a database access error occurs
241             * @see java.sql.Connection#getAutoCommit()
242             */
243            public boolean getAutoCommit() throws SQLException;
244
245            /**
246             * Each <code>JdbcRowSet</code> contains a <code>Connection</code> object from
247             * the original <code>ResultSet</code> or JDBC properties passed to it. This
248             * method wraps the <code>Connection</code>'s <code>getAutoCommit</code> method
249             * to allow an application to set the <code>JdbcRowSet</code> transaction behavior.
250             * <p>
251             * Sets the current auto-commit mode for this <code>Connection</code> object.
252             *
253             * @throws SQLException if a database access error occurs
254             * @see java.sql.Connection#setAutoCommit(boolean)
255             */
256            public void setAutoCommit(boolean autoCommit) throws SQLException;
257
258            /**
259             * Each <code>JdbcRowSet</code> contains a <code>Connection</code> object from
260             * the original <code>ResultSet</code> or JDBC properties passed to it.
261             * Undoes all changes made in the current transaction and releases any 
262             * database locks currently held by this <code>Connection</code> object. This method 
263             * should be used only when auto-commit mode has been disabled.
264             * 
265             * @throws SQLException if a database access error occurs or this <code>Connection</code>
266             * object within this <code>JdbcRowSet</code> is in auto-commit mode.
267             * @see #rollback(Savepoint)
268             */
269            public void rollback() throws SQLException;
270
271            /**
272             * Each <code>JdbcRowSet</code> contains a <code>Connection</code> object from
273             * the original <code>ResultSet</code> or JDBC properties passed to it.
274             * Undoes all changes made in the current transaction to the last set savepoint
275             * and releases any database locks currently held by this <code>Connection</code>
276             * object. This method should be used only when auto-commit mode has been disabled.
277             * 
278             * @throws SQLException if a database access error occurs or this <code>Connection</code>
279             * object within this <code>JdbcRowSet</code> is in auto-commit mode.
280             * @see #rollback
281             */
282            public void rollback(Savepoint s) throws SQLException;
283
284        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.