KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > spi > persistence > support > sqlstore > connection > StatementImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * StatementImpl.java
26  *
27  * Create on March 3, 2000
28  */

29
30 package com.sun.jdo.spi.persistence.support.sqlstore.connection;
31
32 import java.sql.*;
33
34 /**
35  * This class implements the <code>java.sql.Statement</code>
36  * interface, which is part of the JDBC API. You should use
37  * the <code>java.sql.Statement</code> interface as an object
38  * type instead of this class.
39  */

40
41 public class StatementImpl implements Statement {
42     ConnectionImpl conn;
43     Statement stmt;
44
45     //
46
// Create a new StatementImpl object.
47
//
48
public StatementImpl() {
49         super();
50         this.conn = null;
51         this.stmt = null;
52     }
53
54     /**
55      * @ForteInternal
56      * Create a new StatementImpl object. Keep references to
57      * corresponding JDBC Connection and Statement objects.
58      *
59      * @param conn ConnectionImpl
60      * @param stmt JDBC Statement
61      */

62     public StatementImpl(ConnectionImpl conn, Statement stmt) {
63         super();
64         this.conn = conn;
65         this.stmt = stmt;
66     }
67
68     //----------------------------------------------------------------------
69
// Wrapper methods for JDBC Statement:
70

71     public ResultSet executeQuery(String JavaDoc sql) throws SQLException {
72         try {
73             this.conn.checkXact();
74             return (this.stmt.executeQuery(sql));
75         } catch (SQLException se) {
76             throw se;
77         }
78     }
79
80     public int executeUpdate(String JavaDoc sql) throws SQLException {
81         try {
82             this.conn.checkXact();
83             return (this.stmt.executeUpdate(sql));
84         } catch (SQLException se) {
85             throw se;
86         }
87     }
88
89     public void close() throws SQLException {
90         try {
91             this.stmt.close();
92         } catch (SQLException se) {
93             throw se;
94         }
95     }
96
97     public int getMaxFieldSize() throws SQLException {
98         try {
99             return (this.stmt.getMaxFieldSize());
100         } catch (SQLException se) {
101             throw se;
102         }
103     }
104
105     public void setMaxFieldSize(int max) throws SQLException {
106         try {
107             this.stmt.setMaxFieldSize(max);
108         } catch (SQLException se) {
109             throw se;
110         }
111     }
112
113     public int getMaxRows() throws SQLException {
114         try {
115             return (this.stmt.getMaxRows());
116         } catch (SQLException se) {
117             throw se;
118         }
119     }
120
121     public void setMaxRows(int max) throws SQLException {
122         try {
123             this.stmt.setMaxRows(max);
124         } catch (SQLException se) {
125             throw se;
126         }
127     }
128
129     public void setEscapeProcessing(boolean enable) throws SQLException {
130         try {
131             this.stmt.setEscapeProcessing(enable);
132         } catch (SQLException se) {
133             throw se;
134         }
135     }
136
137     public int getQueryTimeout() throws SQLException {
138         try {
139             return (this.stmt.getQueryTimeout());
140         } catch (SQLException se) {
141             throw se;
142         }
143     }
144
145     public void setQueryTimeout(int seconds) throws SQLException {
146         try {
147             this.stmt.setQueryTimeout(seconds);
148         } catch (SQLException se) {
149             throw se;
150         }
151     }
152
153     public void cancel() throws SQLException {
154         try {
155             this.stmt.cancel();
156         } catch (SQLException se) {
157             throw se;
158         }
159     }
160
161     public SQLWarning getWarnings() throws SQLException {
162         try {
163             return (this.stmt.getWarnings());
164         } catch (SQLException se) {
165             throw se;
166         }
167     }
168
169     public void clearWarnings() throws SQLException {
170         try {
171             this.stmt.clearWarnings();
172         } catch (SQLException se) {
173             throw se;
174         }
175     }
176
177     public void setCursorName(String JavaDoc name) throws SQLException {
178         try {
179             this.stmt.setCursorName(name);
180         } catch (SQLException se) {
181             throw se;
182         }
183     }
184
185     public boolean execute(String JavaDoc sql) throws SQLException {
186         try {
187             this.conn.checkXact();
188             return (this.stmt.execute(sql));
189         } catch (SQLException se) {
190             throw se;
191         }
192     }
193
194     public ResultSet getResultSet() throws SQLException {
195         try {
196             return (this.stmt.getResultSet());
197         } catch (SQLException se) {
198             throw se;
199         }
200     }
201
202     public int getUpdateCount() throws SQLException {
203         try {
204             return (this.stmt.getUpdateCount());
205         } catch (SQLException se) {
206             throw se;
207         }
208     }
209
210     public boolean getMoreResults() throws SQLException {
211         try {
212             return (this.stmt.getMoreResults());
213         } catch (SQLException se) {
214             throw se;
215         }
216     }
217
218     public int getResultSetConcurrency() throws SQLException {
219         try {
220             return (this.stmt.getResultSetConcurrency());
221         } catch (SQLException se) {
222             throw se;
223         }
224     }
225
226     //--------------------------JDBC 2.0-----------------------------
227

228     public void setFetchDirection(int direction) throws SQLException {
229         try {
230             this.stmt.setFetchDirection(direction);
231         } catch (SQLException se) {
232             throw se;
233         }
234     }
235
236     public int getFetchDirection() throws SQLException {
237         try {
238             return (this.stmt.getFetchDirection());
239         } catch (SQLException se) {
240             throw se;
241         }
242     }
243
244     public void setFetchSize(int rows) throws SQLException {
245         try {
246             this.stmt.setFetchSize(rows);
247         } catch (SQLException se) {
248             throw se;
249         }
250     }
251
252     public int getFetchSize() throws SQLException {
253         try {
254             return (this.stmt.getFetchSize());
255         } catch (SQLException se) {
256             throw se;
257         }
258     }
259
260     public int getResultSetType()
261             throws SQLException {
262         try {
263             return (this.stmt.getResultSetType());
264         } catch (SQLException se) {
265             throw se;
266         }
267     }
268
269     public void addBatch(String JavaDoc sql) throws SQLException {
270         try {
271             this.stmt.addBatch(sql);
272         } catch (SQLException se) {
273             throw se;
274         }
275     }
276
277     public void clearBatch() throws SQLException {
278         try {
279             this.stmt.clearBatch();
280         } catch (SQLException se) {
281             throw se;
282         }
283     }
284
285     public int[] executeBatch() throws SQLException {
286         try {
287             this.conn.checkXact();
288             return (this.stmt.executeBatch());
289         } catch (SQLException se) {
290             throw se;
291         }
292     }
293
294     public Connection getConnection() throws SQLException {
295         try {
296             return (this.stmt.getConnection());
297         } catch (SQLException se) {
298             throw se;
299         }
300     }
301
302
303     //-------------Begin New methods added in JDBC 3.0 --------------
304
public boolean getMoreResults(int current) throws SQLException {
305         try {
306             return (this.stmt.getMoreResults(current));
307         } catch (SQLException se) {
308             throw se;
309         }
310     }
311
312     public ResultSet getGeneratedKeys() throws SQLException {
313         try {
314             return (this.stmt.getGeneratedKeys());
315         } catch (SQLException se) {
316             throw se;
317         }
318     }
319
320     public int executeUpdate(String JavaDoc sql, int autoGeneratedKeys) throws SQLException {
321         try {
322             return (this.stmt.executeUpdate(sql,autoGeneratedKeys) );
323         } catch (SQLException se) {
324             throw se;
325         }
326     }
327
328     public int executeUpdate(String JavaDoc sql, int[] columnIndexes) throws SQLException {
329         try {
330             return (this.stmt.executeUpdate(sql,columnIndexes));
331         } catch (SQLException se) {
332             throw se;
333         }
334     }
335
336     public int executeUpdate(String JavaDoc sql, String JavaDoc[] columnNames) throws SQLException {
337         try {
338             return (this.stmt.executeUpdate(sql,columnNames));
339         } catch (SQLException se) {
340             throw se;
341         }
342     }
343
344     public boolean execute(String JavaDoc sql, int autoGeneratedKeys) throws SQLException {
345         try {
346             return (this.stmt.execute(sql,autoGeneratedKeys));
347         } catch (SQLException se) {
348             throw se;
349         }
350     }
351
352     public boolean execute(String JavaDoc sql, int[] columnIndexes) throws SQLException {
353         try {
354             return (this.stmt.execute(sql,columnIndexes));
355         } catch (SQLException se) {
356             throw se;
357         }
358     }
359
360     public boolean execute(String JavaDoc sql, String JavaDoc[] columnNames) throws SQLException {
361         try {
362             return (this.stmt.execute(sql,columnNames));
363         } catch (SQLException se) {
364             throw se;
365         }
366     }
367
368     public int getResultSetHoldability() throws SQLException {
369         try {
370             return (this.stmt.getResultSetHoldability());
371         } catch (SQLException se) {
372             throw se;
373         }
374     }
375
376     //-------------End New methods added in JDBC 3.0 --------------
377

378     /*
379      * This method unwraps given Statement and return the Statement from
380      * JDBC driver.
381      */

382     public Statement unwrapStatement() {
383         return this.stmt;
384     }
385 }
386
Popular Tags