KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > uk > org > primrose > pool > core > PoolCallableStatement


1 /**
2 * Library name : Primrose - A Java Database Connection Pool.
3 * Published by Ben Keeping, http://primrose.org.uk .
4 * Copyright (C) 2004 Ben Keeping, primrose.org.uk
5 * Email: Use "Contact Us Form" on website
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */

21
22 package uk.org.primrose.pool.core;
23
24 import java.math.BigDecimal JavaDoc;
25 import java.util.Calendar JavaDoc;
26 import java.sql.*;
27
28 /**
29 * A wrapper for a vendor specific implementation of CallableStatement.
30 * Allows for complete logging of SQL transactions, aswell as identifying
31 * unclosed statements before Connection close() calls.
32 */

33 public class PoolCallableStatement extends PoolPreparedStatement implements CallableStatement {
34     CallableStatement cs = null;
35     PoolSqlMonitor poolSqlMonitor = null;
36
37     public PoolCallableStatement(CallableStatement cs, PoolSqlMonitor poolSqlMonitor) {
38         super(cs, poolSqlMonitor);
39         this.poolSqlMonitor = poolSqlMonitor;
40         poolSqlMonitor.setStatementClosed(false);
41         poolSqlMonitor.setStatement(this);
42         this.cs = cs;
43     }
44
45     public PoolCallableStatement(){
46         super();
47     }
48
49     public void setPoolSqlMonitor(PoolSqlMonitor poolSqlMonitor) {
50         this.poolSqlMonitor = poolSqlMonitor;
51     }
52
53     public PoolSqlMonitor getPoolSqlMonitor() {
54         return poolSqlMonitor;
55     }
56
57     public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {
58         cs.registerOutParameter(parameterIndex, sqlType);
59     }
60
61     public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException {
62         cs.registerOutParameter(parameterIndex, sqlType, scale);
63     }
64
65     public boolean wasNull() throws SQLException {
66         return cs.wasNull();
67     }
68
69     public String JavaDoc getString(int parameterIndex) throws SQLException {
70         return cs.getString(parameterIndex);
71     }
72
73     public boolean getBoolean(int parameterIndex) throws SQLException {
74         return cs.getBoolean(parameterIndex);
75     }
76
77     public byte getByte(int parameterIndex) throws SQLException {
78         return cs.getByte(parameterIndex);
79     }
80
81     public short getShort(int parameterIndex) throws SQLException {
82         return cs.getShort(parameterIndex);
83     }
84
85     public int getInt(int parameterIndex) throws SQLException {
86         return cs.getInt(parameterIndex);
87     }
88
89     public long getLong(int parameterIndex) throws SQLException {
90         return cs.getLong(parameterIndex);
91     }
92
93     public float getFloat(int parameterIndex) throws SQLException {
94         return cs.getFloat(parameterIndex);
95     }
96
97     public double getDouble(int parameterIndex) throws SQLException {
98         return cs.getDouble(parameterIndex);
99     }
100
101     public BigDecimal JavaDoc getBigDecimal(int parameterIndex, int scale) throws SQLException {
102         return cs.getBigDecimal(parameterIndex, scale);
103     }
104
105     public byte[] getBytes(int parameterIndex) throws SQLException {
106         return cs.getBytes(parameterIndex);
107     }
108
109     public java.sql.Date JavaDoc getDate(int parameterIndex) throws SQLException {
110         return cs.getDate(parameterIndex);
111     }
112
113     public java.sql.Time JavaDoc getTime(int parameterIndex) throws SQLException {
114         return cs.getTime(parameterIndex);
115     }
116
117     public java.sql.Timestamp JavaDoc getTimestamp(int parameterIndex) throws SQLException {
118         return cs.getTimestamp(parameterIndex);
119     }
120
121     public Object JavaDoc getObject(int parameterIndex) throws SQLException {
122         return cs.getObject(parameterIndex);
123     }
124
125     public BigDecimal JavaDoc getBigDecimal(int parameterIndex) throws SQLException {
126         return cs.getBigDecimal(parameterIndex);
127     }
128
129     public Object JavaDoc getObject (int i, java.util.Map JavaDoc map) throws SQLException {
130         return cs.getObject(i, map);
131     }
132
133     public Ref getRef (int i) throws SQLException {
134         return cs.getRef(i);
135     }
136
137     public Blob getBlob (int i) throws SQLException {
138         return cs.getBlob(i);
139     }
140
141     public Clob getClob (int i) throws SQLException {
142         return cs.getClob(i);
143     }
144
145     public Array getArray (int i) throws SQLException {
146         return cs.getArray(i);
147     }
148
149     public java.sql.Date JavaDoc getDate(int parameterIndex, Calendar JavaDoc cal) throws SQLException {
150         return cs.getDate(parameterIndex, cal);
151     }
152
153     public java.sql.Time JavaDoc getTime(int parameterIndex, Calendar JavaDoc cal) throws SQLException {
154         return cs.getTime(parameterIndex, cal);
155     }
156
157     public java.sql.Timestamp JavaDoc getTimestamp(int parameterIndex, Calendar JavaDoc cal) throws SQLException {
158         return cs.getTimestamp(parameterIndex, cal);
159     }
160
161
162     public void registerOutParameter(int paramIndex, int sqlType, String JavaDoc typeName) throws SQLException {
163         cs.registerOutParameter(paramIndex, sqlType, typeName);
164     }
165
166     public void registerOutParameter(String JavaDoc parameterName, int sqlType) throws SQLException {
167         cs.registerOutParameter(parameterName, sqlType);
168     }
169
170     public void registerOutParameter(String JavaDoc parameterName, int sqlType, int scale) throws SQLException {
171         cs.registerOutParameter(parameterName, sqlType, scale);
172     }
173
174     public void registerOutParameter(String JavaDoc parameterName, int sqlType, String JavaDoc typeName) throws SQLException {
175         cs.registerOutParameter(parameterName, sqlType, typeName);
176     }
177
178     public java.net.URL JavaDoc getURL(int parameterIndex) throws SQLException {
179         return cs.getURL(parameterIndex);
180     }
181
182     public void setURL(String JavaDoc parameterName, java.net.URL JavaDoc val) throws SQLException {
183         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +val +")");
184         cs.setURL(parameterName, val);
185     }
186
187     public void setNull(String JavaDoc parameterName, int sqlType) throws SQLException {
188         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +sqlType +")");
189         cs.setNull(parameterName, sqlType);
190     }
191
192     public void setBoolean(String JavaDoc parameterName, boolean x) throws SQLException {
193         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
194         cs.setBoolean(parameterName, x);
195     }
196
197     public void setByte(String JavaDoc parameterName, byte x) throws SQLException {
198         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
199         cs.setByte(parameterName, x);
200     }
201
202     public void setShort(String JavaDoc parameterName, short x) throws SQLException {
203         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
204         cs.setShort(parameterName, x);
205     }
206
207     public void setInt(String JavaDoc parameterName, int x) throws SQLException {
208         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
209         cs.setInt(parameterName, x);
210     }
211
212     public void setLong(String JavaDoc parameterName, long x) throws SQLException {
213         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
214         cs.setLong(parameterName, x);
215     }
216
217     public void setFloat(String JavaDoc parameterName, float x) throws SQLException {
218         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
219         cs.setFloat(parameterName, x);
220     }
221
222     public void setDouble(String JavaDoc parameterName, double x) throws SQLException {
223         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
224         cs.setDouble(parameterName, x);
225     }
226
227     public void setBigDecimal(String JavaDoc parameterName, BigDecimal JavaDoc x) throws SQLException {
228         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
229         cs.setBigDecimal(parameterName, x);
230     }
231
232     public void setString(String JavaDoc parameterName, String JavaDoc x) throws SQLException {
233         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
234         cs.setString(parameterName, x);
235     }
236
237     public void setBytes(String JavaDoc parameterName, byte x[]) throws SQLException {
238         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
239         cs.setBytes(parameterName, x);
240     }
241
242     public void setDate(String JavaDoc parameterName, java.sql.Date JavaDoc x) throws SQLException {
243         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
244         cs.setDate(parameterName, x);
245     }
246
247     public void setTime(String JavaDoc parameterName, java.sql.Time JavaDoc x) throws SQLException {
248         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
249         cs.setTime(parameterName, x);
250     }
251
252     public void setTimestamp(String JavaDoc parameterName, java.sql.Timestamp JavaDoc x) throws SQLException {
253         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
254         cs.setTimestamp(parameterName, x);
255     }
256
257     public void setAsciiStream(String JavaDoc parameterName, java.io.InputStream JavaDoc x, int length) throws SQLException {
258         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
259         cs.setAsciiStream(parameterName, x, length);
260     }
261
262     public void setBinaryStream(String JavaDoc parameterName, java.io.InputStream JavaDoc x, int length) throws SQLException {
263         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
264         cs.setBinaryStream(parameterName, x, length);
265     }
266
267     public void setObject(String JavaDoc parameterName, Object JavaDoc x, int targetSqlType, int scale) throws SQLException {
268         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
269         cs.setObject(parameterName, x, targetSqlType, scale);
270     }
271
272     public void setObject(String JavaDoc parameterName, Object JavaDoc x, int targetSqlType) throws SQLException {
273         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
274         cs.setObject(parameterName, x, targetSqlType);
275     }
276
277     public void setObject(String JavaDoc parameterName, Object JavaDoc x) throws SQLException {
278         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
279         cs.setObject(parameterName, x);
280     }
281
282     public void setCharacterStream(String JavaDoc parameterName, java.io.Reader JavaDoc reader, int length) throws SQLException {
283         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +reader +")");
284         cs.setCharacterStream(parameterName, reader, length);
285     }
286
287     public void setDate(String JavaDoc parameterName, java.sql.Date JavaDoc x, Calendar JavaDoc cal) throws SQLException {
288         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
289         cs.setDate(parameterName, x, cal);
290     }
291
292     public void setTime(String JavaDoc parameterName, java.sql.Time JavaDoc x, Calendar JavaDoc cal) throws SQLException {
293         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
294         cs.setTime(parameterName, x, cal);
295     }
296
297     public void setTimestamp(String JavaDoc parameterName, java.sql.Timestamp JavaDoc x, Calendar JavaDoc cal) throws SQLException {
298         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +x +")");
299         cs.setTimestamp(parameterName, x, cal);
300     }
301
302     public void setNull(String JavaDoc parameterName, int sqlType, String JavaDoc typeName) throws SQLException {
303         poolSqlMonitor.setSql(poolSqlMonitor.getSql() +" " +parameterName +"(" +typeName +")");
304         cs.setNull(parameterName, sqlType, typeName);
305     }
306
307     public String JavaDoc getString(String JavaDoc parameterName) throws SQLException {
308         return cs.getString(parameterName);
309     }
310
311     public boolean getBoolean(String JavaDoc parameterName) throws SQLException {
312         return cs.getBoolean(parameterName);
313     }
314
315     public byte getByte(String JavaDoc parameterName) throws SQLException {
316         return cs.getByte(parameterName);
317     }
318
319     public short getShort(String JavaDoc parameterName) throws SQLException {
320         return cs.getShort(parameterName);
321     }
322
323     public int getInt(String JavaDoc parameterName) throws SQLException {
324         return cs.getInt(parameterName);
325     }
326
327     public long getLong(String JavaDoc parameterName) throws SQLException {
328         return cs.getLong(parameterName);
329     }
330
331     public float getFloat(String JavaDoc parameterName) throws SQLException {
332         return cs.getFloat(parameterName);
333     }
334
335     public double getDouble(String JavaDoc parameterName) throws SQLException {
336         return cs.getDouble(parameterName);
337     }
338
339     public byte[] getBytes(String JavaDoc parameterName) throws SQLException {
340         return cs.getBytes(parameterName);
341     }
342
343     public java.sql.Date JavaDoc getDate(String JavaDoc parameterName) throws SQLException {
344         return cs.getDate(parameterName);
345     }
346
347     public java.sql.Time JavaDoc getTime(String JavaDoc parameterName) throws SQLException {
348         return cs.getTime(parameterName);
349     }
350
351     public java.sql.Timestamp JavaDoc getTimestamp(String JavaDoc parameterName) throws SQLException {
352         return cs.getTimestamp(parameterName);
353     }
354
355     public Object JavaDoc getObject(String JavaDoc parameterName) throws SQLException {
356         return cs.getObject(parameterName);
357     }
358
359     public BigDecimal JavaDoc getBigDecimal(String JavaDoc parameterName) throws SQLException {
360         return cs.getBigDecimal(parameterName);
361     }
362
363     public Object JavaDoc getObject (String JavaDoc parameterName, java.util.Map JavaDoc map) throws SQLException {
364         return cs.getObject(parameterName, map);
365     }
366
367     public Ref getRef (String JavaDoc parameterName) throws SQLException {
368         return cs.getRef(parameterName);
369     }
370
371     public Blob getBlob (String JavaDoc parameterName) throws SQLException {
372         return cs.getBlob(parameterName);
373     }
374
375     public Clob getClob (String JavaDoc parameterName) throws SQLException {
376         return cs.getClob(parameterName);
377     }
378
379     public Array getArray (String JavaDoc parameterName) throws SQLException {
380         return cs.getArray(parameterName);
381     }
382
383     public java.sql.Date JavaDoc getDate(String JavaDoc parameterName, Calendar JavaDoc cal) throws SQLException {
384         return cs.getDate(parameterName, cal);
385     }
386
387     public java.sql.Time JavaDoc getTime(String JavaDoc parameterName, Calendar JavaDoc cal) throws SQLException {
388         return cs.getTime(parameterName, cal);
389     }
390
391     public java.sql.Timestamp JavaDoc getTimestamp(String JavaDoc parameterName, Calendar JavaDoc cal) throws SQLException {
392         return cs.getTimestamp(parameterName, cal);
393     }
394
395     public java.net.URL JavaDoc getURL(String JavaDoc parameterName) throws SQLException {
396         return cs.getURL(parameterName);
397     }
398
399 }
400
401
402
403
404
405
Popular Tags