KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > smartlib > pool > core > SmartPreparedStatement


1 /*
2  * @(#) SmartPreparedStatement 1.0 02/08/01
3  */

4
5 package org.smartlib.pool.core;
6
7 import java.sql.*;
8 import java.math.BigDecimal JavaDoc;
9 import java.util.Calendar JavaDoc;
10 import java.net.URL JavaDoc;
11
12
13 /**
14  * This class encapsulates a SmartPreparedStatement.
15  * Dont expect me to document this class, if you want refer Sun's Documentation.
16  *
17  * @author Sachin Shekar Shetty
18  * @version 1.0, 02/08/01
19  */

20
21 public class SmartPreparedStatement extends SmartStatement
22                 implements PreparedStatement , Close {
23
24     private PreparedStatement pstmt;
25     private SmartConnection sConn ;
26     private boolean isClosed;
27     Debugger debug =
28         new Debugger("org.smartlib.pool.core.SmartPreparedStatement", true);
29
30
31     // default access
32
SmartPreparedStatement(PreparedStatement pstmt , SmartConnection sConn) {
33
34         super(pstmt,sConn);
35         this.pstmt = pstmt;
36         this.sConn = sConn;
37
38     }
39
40     private void preProcess() throws SQLException {
41
42         if (isClosed())
43             throw new SQLException("Prepared Statement already closed");
44         sConn.setLastAccessedTime();
45
46     }
47
48
49     public ResultSet executeQuery() throws SQLException {
50
51         preProcess();
52         return pstmt.executeQuery();
53
54     }
55
56     public int executeUpdate() throws SQLException {
57
58         preProcess();
59         return pstmt.executeUpdate();
60
61     }
62
63     public void setNull(int parameterIndex, int sqlType) throws SQLException {
64
65         preProcess();
66         pstmt.setNull(parameterIndex , sqlType);
67
68     }
69
70     public void setBoolean(int parameterIndex, boolean x) throws SQLException {
71
72         preProcess();
73         pstmt.setBoolean(parameterIndex , x );
74
75     }
76
77     public void setByte(int parameterIndex, byte x) throws SQLException {
78
79         preProcess();
80         pstmt.setByte(parameterIndex , x);
81
82     }
83
84     public void setShort(int parameterIndex, short x) throws SQLException {
85
86         preProcess();
87         pstmt.setShort(parameterIndex , x);
88
89     }
90
91     public void setInt(int parameterIndex, int x) throws SQLException {
92
93         preProcess();
94         pstmt.setInt(parameterIndex , x);
95
96     }
97
98     public void setLong(int parameterIndex, long x) throws SQLException {
99
100         preProcess();
101         pstmt.setLong(parameterIndex , x );
102
103     }
104
105     public void setFloat(int parameterIndex, float x) throws SQLException {
106
107         preProcess();
108         pstmt.setFloat(parameterIndex , x );
109
110     }
111
112     public void setDouble(int parameterIndex, double x) throws SQLException {
113
114         preProcess();
115         pstmt.setDouble(parameterIndex , x );
116
117     }
118
119     public void setBigDecimal(int parameterIndex, BigDecimal JavaDoc x) throws SQLException {
120
121         preProcess();
122         pstmt.setBigDecimal(parameterIndex , x);
123
124     }
125
126     public void setString(int parameterIndex, String JavaDoc x)
127             throws SQLException {
128
129         preProcess();
130         pstmt.setString(parameterIndex , x );
131
132     }
133
134     public void setBytes(int parameterIndex, byte x[])
135             throws SQLException {
136
137         preProcess();
138         pstmt.setBytes(parameterIndex , x);
139
140     }
141
142     public void setDate(int parameterIndex, java.sql.Date JavaDoc x)
143         throws SQLException {
144
145         preProcess();
146         pstmt.setDate(parameterIndex , x);
147
148     }
149
150     public void setTime(int parameterIndex, java.sql.Time JavaDoc x)
151         throws SQLException {
152
153         preProcess();
154         pstmt.setTime(parameterIndex , x );
155
156     }
157
158     public void setTimestamp(int parameterIndex, java.sql.Timestamp JavaDoc x)
159         throws SQLException {
160
161         preProcess();
162         pstmt.setTimestamp(parameterIndex, x);
163
164     }
165
166     public void setAsciiStream(int parameterIndex, java.io.InputStream JavaDoc x, int length)
167         throws SQLException {
168
169         preProcess();
170         pstmt.setAsciiStream( parameterIndex , x , length);
171
172     }
173
174     public void setUnicodeStream(int parameterIndex, java.io.InputStream JavaDoc x,
175                                  int length) throws SQLException {
176
177         preProcess();
178         pstmt.setUnicodeStream(parameterIndex , x , length);
179
180     }
181
182     public void setBinaryStream(int parameterIndex, java.io.InputStream JavaDoc x,
183                                 int length) throws SQLException {
184
185         preProcess();
186         pstmt.setBinaryStream(parameterIndex , x , length);
187
188     }
189
190     public void clearParameters() throws SQLException {
191
192         preProcess();
193         pstmt.clearParameters();
194
195     }
196
197     public void setObject(int parameterIndex, Object JavaDoc x,
198                           int targetSqlType, int scale) throws SQLException {
199
200         preProcess();
201         pstmt.setObject(parameterIndex , x , targetSqlType , scale);
202
203     }
204
205     public void setObject(int parameterIndex, Object JavaDoc x, int targetSqlType)
206         throws SQLException {
207
208         preProcess();
209         pstmt.setObject(parameterIndex , x , targetSqlType);
210
211     }
212
213     public void setObject(int parameterIndex, Object JavaDoc x) throws SQLException {
214
215         preProcess();
216         pstmt.setObject(parameterIndex , x);
217
218     }
219
220     public boolean execute() throws SQLException {
221
222         preProcess();
223         return pstmt.execute();
224
225     }
226
227     public void addBatch() throws SQLException {
228
229         preProcess();
230         pstmt.addBatch();
231
232     }
233
234     public void setCharacterStream(int parameterIndex,
235                                    java.io.Reader JavaDoc reader, int length) throws SQLException {
236
237         preProcess();
238         pstmt.setCharacterStream(parameterIndex , reader , length );
239
240     }
241     public void setRef (int i, Ref x) throws SQLException {
242
243         preProcess();
244         pstmt.setRef(i , x);
245
246     }
247     public void setBlob (int i, Blob x) throws SQLException {
248
249         preProcess();
250         pstmt.setBlob(i,x);
251
252     }
253
254     public void setClob (int i, Clob x) throws SQLException {
255
256         preProcess();
257         pstmt.setClob(i , x );
258
259     }
260
261     public void setArray (int i, Array x) throws SQLException {
262
263         preProcess();
264         pstmt.setArray(i , x);
265
266     }
267
268     public ResultSetMetaData getMetaData() throws SQLException {
269
270         preProcess();
271         return pstmt.getMetaData();
272
273     }
274
275     public void setDate(int parameterIndex, java.sql.Date JavaDoc x, Calendar JavaDoc cal)
276         throws SQLException {
277
278         preProcess();
279         pstmt.setDate(parameterIndex , x , cal);
280
281     }
282
283     public void setTime(int parameterIndex, java.sql.Time JavaDoc x, Calendar JavaDoc cal)
284         throws SQLException {
285
286         preProcess();
287         pstmt.setTime(parameterIndex , x , cal);
288
289     }
290
291     public void setTimestamp(int parameterIndex, java.sql.Timestamp JavaDoc x
292             , Calendar JavaDoc cal) throws SQLException {
293
294         preProcess();
295         pstmt.setTimestamp(parameterIndex , x , cal);
296
297     }
298
299     public void setNull (int paramIndex, int sqlType, String JavaDoc typeName)
300         throws SQLException {
301
302         preProcess();
303         pstmt.setNull(paramIndex , sqlType , typeName);
304
305     }
306
307     public void setURL(int parameterIndex, URL JavaDoc x) throws SQLException {
308         //To change body of implemented methods use File | Settings | File Templates.
309
}
310
311     public ParameterMetaData getParameterMetaData() throws SQLException {
312         return null; //To change body of implemented methods use File | Settings | File Templates.
313
}
314
315     public Connection getConnection() throws SQLException {
316
317         preProcess();
318         return pstmt.getConnection();
319
320     }
321
322     public int[] executeBatch() throws SQLException {
323
324         preProcess();
325         return pstmt.executeBatch();
326
327     }
328
329     public void clearBatch() throws SQLException {
330
331         preProcess();
332         pstmt.clearBatch();
333
334     }
335
336     public void addBatch( String JavaDoc sql ) throws SQLException {
337
338         preProcess();
339         pstmt.addBatch(sql);
340
341     }
342
343     public ResultSet executeQuery(String JavaDoc sql) throws SQLException {
344
345         preProcess();
346         return pstmt.executeQuery(sql);
347
348     }
349
350     public int executeUpdate(String JavaDoc sql) throws SQLException {
351
352         preProcess();
353         return pstmt.executeUpdate(sql);
354
355     }
356
357     public void close() throws SQLException {
358
359         debug.print("PreparedStatement Closed for:" + sConn.getOwner());
360         if (isClosed)
361             throw new SQLException("PreparedStatement already closed");
362         pstmt.close();
363         isClosed=true;
364
365     }
366
367     public boolean isClosed() throws SQLException {
368
369         return isClosed;
370
371     }
372
373     public int getMaxFieldSize() throws SQLException {
374
375         preProcess();
376         return pstmt.getMaxFieldSize();
377
378     }
379
380     public void setMaxFieldSize(int max) throws SQLException {
381
382         preProcess();
383         pstmt.setMaxFieldSize(max);
384
385     }
386
387     public int getMaxRows() throws SQLException {
388
389         preProcess();
390         return pstmt.getMaxRows();
391
392     }
393
394     public void setMaxRows(int max) throws SQLException {
395
396         preProcess();
397         pstmt.setMaxRows(max);
398
399     }
400
401     public void setEscapeProcessing(boolean enable) throws SQLException {
402
403         preProcess();
404         pstmt.setEscapeProcessing(enable);
405
406     }
407
408     public int getQueryTimeout() throws SQLException {
409
410         preProcess();
411         return pstmt.getQueryTimeout();
412
413     }
414
415     public void setQueryTimeout(int seconds) throws SQLException {
416
417         preProcess();
418         pstmt.setQueryTimeout(seconds);
419
420     }
421
422     public void cancel() throws SQLException {
423
424         preProcess();
425         pstmt.cancel();
426
427     }
428
429     public SQLWarning getWarnings() throws SQLException {
430
431         preProcess();
432         return pstmt.getWarnings();
433
434     }
435
436     public void clearWarnings() throws SQLException {
437
438         preProcess();
439         pstmt.clearWarnings();
440
441     }
442
443     public void setCursorName(String JavaDoc name) throws SQLException {
444
445         preProcess();
446         pstmt.setCursorName(name);
447
448     }
449
450     public boolean execute(String JavaDoc sql) throws SQLException {
451
452         preProcess();
453         return pstmt.execute(sql);
454
455     }
456
457     public ResultSet getResultSet() throws SQLException {
458
459         preProcess();
460         return pstmt.getResultSet();
461
462     }
463
464     public int getUpdateCount() throws SQLException {
465
466         preProcess();
467         return pstmt.getUpdateCount();
468
469
470     }
471
472     public boolean getMoreResults() throws SQLException {
473
474         preProcess();
475         return pstmt.getMoreResults();
476
477     }
478
479     public void setFetchDirection(int direction) throws SQLException {
480
481         preProcess();
482         pstmt.setFetchDirection(direction);
483
484     }
485
486     public int getFetchDirection() throws SQLException {
487
488         preProcess();
489         return pstmt.getFetchDirection();
490
491     }
492
493     public void setFetchSize(int rows) throws SQLException {
494
495         preProcess();
496         pstmt.setFetchSize(rows);
497
498     }
499
500     public int getFetchSize() throws SQLException {
501
502         preProcess();
503         return pstmt.getFetchSize();
504
505     }
506
507     public int getResultSetConcurrency() throws SQLException {
508
509         preProcess();
510         return pstmt.getResultSetConcurrency();
511
512     }
513
514     public int getResultSetType() throws SQLException {
515
516         preProcess();
517         return pstmt.getResultSetType();
518
519     }
520
521     public String JavaDoc toString() {
522
523         return pstmt.toString();
524
525     }
526
527 }
528
Popular Tags