KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > rmijdbc > RJStatementInterface


1
2 /**
3  * RmiJdbc client/server JDBC Driver
4  * (C) GIE Dyade (Groupe BULL / INRIA Research Center) 1997
5  *
6  * @version 1.0
7  * @author Pierre-Yves Gibello (pierreyves.gibello@experlog.com)
8  */

9
10 package org.objectweb.rmijdbc;
11
12 import java.sql.*;
13 import java.rmi.*;
14
15 /**
16  * <P>A Statement object is used for executing a static SQL statement
17  * and obtaining the results produced by it.
18  *
19  * <P>Only one ResultSet per Statement can be open at any point in
20  * time. Therefore, if the reading of one ResultSet is interleaved
21  * with the reading of another, each must have been generated by
22  * different Statements. All statement execute methods implicitly
23  * close a statment's current ResultSet if an open one exists.
24  *
25  * @see Connection#createStatement
26  * @see ResultSet
27  */

28 public interface RJStatementInterface extends java.rmi.Remote JavaDoc {
29
30   /**
31    * Execute a SQL statement that returns a single ResultSet.
32    *
33    * @param sql typically this is a static SQL SELECT statement
34    * @return a ResultSet that contains the data produced by the
35    * query; never null
36    */

37   RJResultSetInterface executeQuery(String JavaDoc sql) throws java.rmi.RemoteException JavaDoc, SQLException;
38
39     /**
40      * Execute a SQL INSERT, UPDATE or DELETE statement. In addition,
41      * SQL statements that return nothing such as SQL DDL statements
42      * can be executed.
43      *
44      * @param sql a SQL INSERT, UPDATE or DELETE statement or a SQL
45      * statement that returns nothing
46      * @return either the row count for INSERT, UPDATE or DELETE or 0
47      * for SQL statements that return nothing
48      */

49   int executeUpdate(String JavaDoc sql) throws java.rmi.RemoteException JavaDoc, SQLException;
50
51     /**
52      * In many cases, it is desirable to immediately release a
53      * Statements's database and JDBC resources instead of waiting for
54      * this to happen when it is automatically closed; the close
55      * method provides this immediate release.
56      *
57      * <P><B>Note:</B> A Statement is automatically closed when it is
58      * garbage collected. When a Statement is closed, its current
59      * ResultSet, if one exists, is also closed.
60      */

61     void close() throws java.rmi.RemoteException JavaDoc, SQLException;
62
63     //----------------------------------------------------------------------
64

65     /**
66      * The maxFieldSize limit (in bytes) is the maximum amount of data
67      * returned for any column value; it only applies to BINARY,
68      * VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR
69      * columns. If the limit is exceeded, the excess data is silently
70      * discarded.
71      *
72      * @return the current max column size limit; zero means unlimited
73      */

74     int getMaxFieldSize() throws java.rmi.RemoteException JavaDoc, SQLException;
75     
76     /**
77      * The maxFieldSize limit (in bytes) is set to limit the size of
78      * data that can be returned for any column value; it only applies
79      * to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and
80      * LONGVARCHAR fields. If the limit is exceeded, the excess data
81      * is silently discarded. For maximum portability use values
82      * greater than 256.
83      *
84      * @param max the new max column size limit; zero means unlimited
85      */

86     void setMaxFieldSize(int max) throws java.rmi.RemoteException JavaDoc, SQLException;
87
88     /**
89      * The maxRows limit is the maximum number of rows that a
90      * ResultSet can contain. If the limit is exceeded, the excess
91      * rows are silently dropped.
92      *
93      * @return the current max row limit; zero means unlimited
94      */

95     int getMaxRows() throws java.rmi.RemoteException JavaDoc, SQLException;
96
97     /**
98      * The maxRows limit is set to limit the number of rows that any
99      * ResultSet can contain. If the limit is exceeded, the excess
100      * rows are silently dropped.
101      *
102      * @param max the new max rows limit; zero means unlimited
103      */

104     void setMaxRows(int max) throws java.rmi.RemoteException JavaDoc, SQLException;
105
106     /**
107      * If escape scanning is on (the default), the driver will do
108      * escape substitution before sending the SQL to the database.
109      *
110      * @param enable true to enable; false to disable
111      */

112     void setEscapeProcessing(boolean enable) throws java.rmi.RemoteException JavaDoc, SQLException;
113
114     /**
115      * The queryTimeout limit is the number of seconds the driver will
116      * wait for a Statement to execute. If the limit is exceeded, a
117      * SQLException is thrown.
118      *
119      * @return the current query timeout limit in seconds; zero means unlimited
120      */

121     int getQueryTimeout() throws java.rmi.RemoteException JavaDoc, SQLException;
122
123     /**
124      * The queryTimeout limit is the number of seconds the driver will
125      * wait for a Statement to execute. If the limit is exceeded, a
126      * SQLException is thrown.
127      *
128      * @param seconds the new query timeout limit in seconds; zero means unlimited
129      */

130     void setQueryTimeout(int seconds) throws java.rmi.RemoteException JavaDoc, SQLException;
131
132     /**
133      * Cancel can be used by one thread to cancel a statement that
134      * is being executed by another thread.
135      */

136     void cancel() throws java.rmi.RemoteException JavaDoc, SQLException;
137
138     /**
139      * The first warning reported by calls on this Statement is
140      * returned. A Statment's execute methods clear its SQLWarning
141      * chain. Subsequent Statement warnings will be chained to this
142      * SQLWarning.
143      *
144      * <p>The warning chain is automatically cleared each time
145      * a statement is (re)executed.
146      *
147      * <P><B>Note:</B> If you are processing a ResultSet then any
148      * warnings associated with ResultSet reads will be chained on the
149      * ResultSet object.
150      *
151      * @return the first SQLWarning or null
152      */

153     SQLWarning getWarnings() throws java.rmi.RemoteException JavaDoc, SQLException;
154
155     /**
156      * After this call, getWarnings returns null until a new warning is
157      * reported for this Statement.
158      */

159     void clearWarnings() throws java.rmi.RemoteException JavaDoc, SQLException;
160
161     /**
162      * setCursorname defines the SQL cursor name that will be used by
163      * subsequent Statement execute methods. This name can then be
164      * used in SQL positioned update/delete statements to identify the
165      * current row in the ResultSet generated by this statement. If
166      * the database doesn't support positioned update/delete, this
167      * method is a noop.
168      *
169      * <P><B>Note:</B> By definition, positioned update/delete
170      * execution must be done by a different Statement than the one
171      * which generated the ResultSet being used for positioning. Also,
172      * cursor names must be unique within a Connection.
173      *
174      * @param name the new cursor name.
175      */

176     void setCursorName(String JavaDoc name) throws java.rmi.RemoteException JavaDoc, SQLException;
177     
178     //----------------------- Multiple Results --------------------------
179

180     /**
181      * Execute a SQL statement that may return multiple results.
182      * Under some (uncommon) situations a single SQL statement may return
183      * multiple result sets and/or update counts. Normally you can ignore
184      * this, unless you're executing a stored procedure that you know may
185      * return multiple results, or unless you're dynamically executing an
186      * unknown SQL string. The "execute", "getMoreResults", "getResultSet"
187      * and "getUpdateCount" methods let you navigate through multiple results.
188      *
189      * The "execute" method executes a SQL statement and indicates the
190      * form of the first result. You can then use getResultSet or
191      * getUpdateCount to retrieve the result, and getMoreResults to
192      * move to any subsequent result(s).
193      *
194      * @param sql any SQL statement
195      * @return true if the next result is a ResultSet; false if it is
196      * an update count or there are no more results
197      * @see #getResultSet
198      * @see #getUpdateCount
199      * @see #getMoreResults
200      */

201     boolean execute(String JavaDoc sql) throws java.rmi.RemoteException JavaDoc, SQLException;
202     
203     /**
204      * getResultSet returns the current result as a ResultSet. It
205      * should only be called once per result.
206      *
207      * @return the current result as a ResultSet; null if the result
208      * is an update count or there are no more results
209      * @see #execute
210      */

211     RJResultSetInterface getResultSet() throws java.rmi.RemoteException JavaDoc, SQLException;
212
213     /**
214      * getUpdateCount returns the current result as an update count;
215      * if the result is a ResultSet or there are no more results, -1
216      * is returned. It should only be called once per result.
217      *
218      * @return the current result as an update count; -1 if it is a
219      * ResultSet or there are no more results
220      * @see #execute
221      */

222     int getUpdateCount() throws java.rmi.RemoteException JavaDoc, SQLException;
223
224     /**
225      * getMoreResults moves to a Statement's next result. It returns true if
226      * this result is a ResultSet. getMoreResults also implicitly
227      * closes any current ResultSet obtained with getResultSet.
228      *
229      * There are no more results when (!getMoreResults() &&
230      * (getUpdateCount() == -1)
231      *
232      * @return true if the next result is a ResultSet; false if it is
233      * an update count or there are no more results
234      * @see #execute
235      */

236     boolean getMoreResults() throws java.rmi.RemoteException JavaDoc, SQLException;
237
238
239 // JDBC 2.0 methods
240
void setFetchSize(int rows) throws RemoteException, SQLException;
241
242   void setFetchDirection(int dir) throws RemoteException, SQLException;
243
244   int getResultSetType() throws RemoteException, SQLException;
245
246   int getResultSetConcurrency() throws RemoteException, SQLException;
247
248   int getFetchSize() throws RemoteException, SQLException;
249
250   int getFetchDirection() throws RemoteException, SQLException;
251
252   RJConnectionInterface getConnection() throws RemoteException, SQLException;
253
254   int[] executeBatch() throws RemoteException, SQLException;
255
256   void clearBatch() throws RemoteException, SQLException;
257
258   void addBatch(String JavaDoc sql) throws RemoteException, SQLException;
259
260 // JDBC 3.0 methods
261
boolean getMoreResults(int current) throws RemoteException, SQLException;
262  RJResultSetInterface getGeneratedKeys() throws RemoteException, SQLException;
263  int executeUpdate(String JavaDoc sql, int autoGeneratedKeys)
264   throws RemoteException, SQLException;
265  int executeUpdate(String JavaDoc sql, int columnIndexes[])
266   throws RemoteException, SQLException;
267  int executeUpdate(String JavaDoc sql, String JavaDoc columnNames[])
268   throws RemoteException, SQLException;
269  boolean execute(String JavaDoc sql, int autoGeneratedKeys)
270   throws RemoteException, SQLException;
271  boolean execute(String JavaDoc sql, int columnIndexes[])
272   throws RemoteException, SQLException;
273  boolean execute(String JavaDoc sql, String JavaDoc columnNames[])
274   throws RemoteException, SQLException;
275  int getResultSetHoldability() throws RemoteException, SQLException;
276 };
277
278
Popular Tags