001: /**
002: * Library name : Primrose - A Java Database Connection Pool.
003: * Published by Ben Keeping, http://primrose.org.uk .
004: * Copyright (C) 2004 Ben Keeping, primrose.org.uk
005: * Email: Use "Contact Us Form" on website
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */package uk.org.primrose.pool.core;
021:
022: import java.math.BigDecimal;
023: import java.util.Calendar;
024: import java.sql.*;
025:
026: /**
027: * A wrapper for a vendor specific implementation of ResultSet.
028: * Allows for identifying unclosed statements before Connection close() calls.
029: */
030: public class PoolResultSet implements ResultSet {
031:
032: ResultSet rs = null;
033: ConnectionHolder connHolder = null;
034:
035: public PoolResultSet(ResultSet rs, ConnectionHolder connHolder) {
036: this .connHolder = connHolder;
037: connHolder.resultsetObjects.push(this );
038: this .rs = rs;
039: }
040:
041: protected void closeNoPop() throws SQLException {
042: if (this .connHolder.bDumpConnectionOnSQLException) {
043: try {
044: rs.close();
045: } catch (SQLException sqle) {
046: this .connHolder.closeBehaviour = Pool.ON_CLOSE_SHOULD_DIE;
047: this .connHolder.logger
048: .warn("Closing connection due to SQLException on close()");
049: this .connHolder.myPool.notifyExceptionEvent();
050: throw sqle;
051: }
052: } else {
053: rs.close();
054: }
055: }
056:
057: public void close() throws SQLException {
058: for (int i = 0; i < connHolder.resultsetObjects.size(); i++) {
059: PoolResultSet trs = connHolder.resultsetObjects.get(i);
060: if (trs == this ) {
061: connHolder.resultsetObjects.remove(this );
062: break;
063: }
064: }
065:
066: if (this .connHolder.bDumpConnectionOnSQLException) {
067: try {
068: rs.close();
069: } catch (SQLException sqle) {
070: this .connHolder.closeBehaviour = Pool.ON_CLOSE_SHOULD_DIE;
071: this .connHolder.logger
072: .warn("Closing connection due to SQLException on close()");
073: this .connHolder.myPool.notifyExceptionEvent();
074: throw sqle;
075: }
076: } else {
077: rs.close();
078: }
079:
080: }
081:
082: public boolean next() throws SQLException {
083: return rs.next();
084: }
085:
086: public boolean wasNull() throws SQLException {
087: return rs.wasNull();
088: }
089:
090: public String getString(int columnIndex) throws SQLException {
091: return rs.getString(columnIndex);
092: }
093:
094: public boolean getBoolean(int columnIndex) throws SQLException {
095: return rs.getBoolean(columnIndex);
096: }
097:
098: public byte getByte(int columnIndex) throws SQLException {
099: return rs.getByte(columnIndex);
100: }
101:
102: public short getShort(int columnIndex) throws SQLException {
103: return rs.getShort(columnIndex);
104: }
105:
106: public int getInt(int columnIndex) throws SQLException {
107: return rs.getInt(columnIndex);
108: }
109:
110: public long getLong(int columnIndex) throws SQLException {
111: return rs.getLong(columnIndex);
112: }
113:
114: public float getFloat(int columnIndex) throws SQLException {
115: return rs.getFloat(columnIndex);
116: }
117:
118: public double getDouble(int columnIndex) throws SQLException {
119: return rs.getDouble(columnIndex);
120: }
121:
122: @SuppressWarnings("deprecation")
123: public BigDecimal getBigDecimal(int columnIndex, int scale)
124: throws SQLException {
125: return rs.getBigDecimal(columnIndex, scale);
126: }
127:
128: public byte[] getBytes(int columnIndex) throws SQLException {
129: return rs.getBytes(columnIndex);
130: }
131:
132: public java.sql.Date getDate(int columnIndex) throws SQLException {
133: return rs.getDate(columnIndex);
134: }
135:
136: public java.sql.Time getTime(int columnIndex) throws SQLException {
137: return rs.getTime(columnIndex);
138: }
139:
140: public java.sql.Timestamp getTimestamp(int columnIndex)
141: throws SQLException {
142: return rs.getTimestamp(columnIndex);
143: }
144:
145: public java.io.InputStream getAsciiStream(int columnIndex)
146: throws SQLException {
147: return rs.getAsciiStream(columnIndex);
148: }
149:
150: public java.io.InputStream getUnicodeStream(int columnIndex)
151: throws SQLException {
152: return rs.getUnicodeStream(columnIndex);
153: }
154:
155: public java.io.InputStream getBinaryStream(int columnIndex)
156: throws SQLException {
157: return rs.getBinaryStream(columnIndex);
158: }
159:
160: public String getString(String columnName) throws SQLException {
161: return rs.getString(columnName);
162: }
163:
164: public boolean getBoolean(String columnName) throws SQLException {
165: return rs.getBoolean(columnName);
166: }
167:
168: public byte getByte(String columnName) throws SQLException {
169: return rs.getByte(columnName);
170: }
171:
172: public short getShort(String columnName) throws SQLException {
173: return rs.getShort(columnName);
174: }
175:
176: public int getInt(String columnName) throws SQLException {
177: return rs.getInt(columnName);
178: }
179:
180: public long getLong(String columnName) throws SQLException {
181: return rs.getLong(columnName);
182: }
183:
184: public float getFloat(String columnName) throws SQLException {
185: return rs.getFloat(columnName);
186: }
187:
188: public double getDouble(String columnName) throws SQLException {
189: return rs.getDouble(columnName);
190: }
191:
192: public BigDecimal getBigDecimal(String columnName, int scale)
193: throws SQLException {
194: return rs.getBigDecimal(columnName);
195: }
196:
197: public byte[] getBytes(String columnName) throws SQLException {
198: return rs.getBytes(columnName);
199: }
200:
201: public java.sql.Date getDate(String columnName) throws SQLException {
202: return rs.getDate(columnName);
203: }
204:
205: public java.sql.Time getTime(String columnName) throws SQLException {
206: return rs.getTime(columnName);
207: }
208:
209: public java.sql.Timestamp getTimestamp(String columnName)
210: throws SQLException {
211: return rs.getTimestamp(columnName);
212: }
213:
214: public java.io.InputStream getAsciiStream(String columnName)
215: throws SQLException {
216: return rs.getAsciiStream(columnName);
217: }
218:
219: public java.io.InputStream getUnicodeStream(String columnName)
220: throws SQLException {
221: return rs.getUnicodeStream(columnName);
222: }
223:
224: public java.io.InputStream getBinaryStream(String columnName)
225: throws SQLException {
226: return rs.getBinaryStream(columnName);
227: }
228:
229: public SQLWarning getWarnings() throws SQLException {
230: return rs.getWarnings();
231: }
232:
233: public void clearWarnings() throws SQLException {
234: rs.clearWarnings();
235: }
236:
237: public String getCursorName() throws SQLException {
238: return rs.getCursorName();
239: }
240:
241: public ResultSetMetaData getMetaData() throws SQLException {
242: return rs.getMetaData();
243: }
244:
245: public Object getObject(int columnIndex) throws SQLException {
246: return rs.getObject(columnIndex);
247: }
248:
249: public Object getObject(String columnName) throws SQLException {
250: return rs.getObject(columnName);
251: }
252:
253: public int findColumn(String columnName) throws SQLException {
254: return rs.findColumn(columnName);
255: }
256:
257: public java.io.Reader getCharacterStream(int columnIndex)
258: throws SQLException {
259: return rs.getCharacterStream(columnIndex);
260: }
261:
262: public java.io.Reader getCharacterStream(String columnName)
263: throws SQLException {
264: return rs.getCharacterStream(columnName);
265: }
266:
267: public BigDecimal getBigDecimal(int columnIndex)
268: throws SQLException {
269: return rs.getBigDecimal(columnIndex);
270: }
271:
272: public BigDecimal getBigDecimal(String columnName)
273: throws SQLException {
274: return rs.getBigDecimal(columnName);
275: }
276:
277: public boolean isBeforeFirst() throws SQLException {
278: return rs.isBeforeFirst();
279: }
280:
281: public boolean isAfterLast() throws SQLException {
282: return rs.isAfterLast();
283: }
284:
285: public boolean isFirst() throws SQLException {
286: return rs.isFirst();
287: }
288:
289: public boolean isLast() throws SQLException {
290: return rs.isLast();
291: }
292:
293: public void beforeFirst() throws SQLException {
294: rs.beforeFirst();
295: }
296:
297: public void afterLast() throws SQLException {
298: rs.afterLast();
299: }
300:
301: public boolean first() throws SQLException {
302: return rs.first();
303: }
304:
305: public boolean last() throws SQLException {
306: return rs.last();
307: }
308:
309: public int getRow() throws SQLException {
310: return rs.getRow();
311: }
312:
313: public boolean absolute(int row) throws SQLException {
314: return rs.absolute(row);
315: }
316:
317: public boolean relative(int rows) throws SQLException {
318: return rs.relative(rows);
319: }
320:
321: public boolean previous() throws SQLException {
322: return rs.previous();
323: }
324:
325: public void setFetchDirection(int direction) throws SQLException {
326: rs.setFetchDirection(direction);
327: }
328:
329: public int getFetchDirection() throws SQLException {
330: return rs.getFetchDirection();
331: }
332:
333: public void setFetchSize(int rows) throws SQLException {
334: rs.setFetchSize(rows);
335: }
336:
337: public int getFetchSize() throws SQLException {
338: return rs.getFetchSize();
339: }
340:
341: public int getConcurrency() throws SQLException {
342: return rs.getConcurrency();
343: }
344:
345: public boolean rowUpdated() throws SQLException {
346: return rs.rowUpdated();
347: }
348:
349: public int getType() throws SQLException {
350: return rs.getType();
351: }
352:
353: public boolean rowInserted() throws SQLException {
354: return rs.rowInserted();
355: }
356:
357: public boolean rowDeleted() throws SQLException {
358: return rs.rowDeleted();
359: }
360:
361: public void updateNull(int columnIndex) throws SQLException {
362: rs.updateNull(columnIndex);
363: }
364:
365: public void updateBoolean(int columnIndex, boolean x)
366: throws SQLException {
367: rs.updateBoolean(columnIndex, x);
368: }
369:
370: public void updateByte(int columnIndex, byte x) throws SQLException {
371: rs.updateByte(columnIndex, x);
372: }
373:
374: public void updateShort(int columnIndex, short x)
375: throws SQLException {
376: rs.updateShort(columnIndex, x);
377: }
378:
379: public void updateInt(int columnIndex, int x) throws SQLException {
380: rs.updateInt(columnIndex, x);
381: }
382:
383: public void updateLong(int columnIndex, long x) throws SQLException {
384: rs.updateLong(columnIndex, x);
385: }
386:
387: public void updateFloat(int columnIndex, float x)
388: throws SQLException {
389: rs.updateFloat(columnIndex, x);
390: }
391:
392: public void updateDouble(int columnIndex, double x)
393: throws SQLException {
394: rs.updateDouble(columnIndex, x);
395: }
396:
397: public void updateBigDecimal(int columnIndex, BigDecimal x)
398: throws SQLException {
399: rs.updateBigDecimal(columnIndex, x);
400: }
401:
402: public void updateString(int columnIndex, String x)
403: throws SQLException {
404: rs.updateString(columnIndex, x);
405: }
406:
407: public void updateBytes(int columnIndex, byte x[])
408: throws SQLException {
409: rs.updateBytes(columnIndex, x);
410: }
411:
412: public void updateDate(int columnIndex, java.sql.Date x)
413: throws SQLException {
414: rs.updateDate(columnIndex, x);
415: }
416:
417: public void updateTime(int columnIndex, java.sql.Time x)
418: throws SQLException {
419: rs.updateTime(columnIndex, x);
420: }
421:
422: public void updateTimestamp(int columnIndex, java.sql.Timestamp x)
423: throws SQLException {
424: rs.updateTimestamp(columnIndex, x);
425: }
426:
427: public void updateAsciiStream(int columnIndex,
428: java.io.InputStream x, int length) throws SQLException {
429: rs.updateAsciiStream(columnIndex, x, length);
430: }
431:
432: public void updateBinaryStream(int columnIndex,
433: java.io.InputStream x, int length) throws SQLException {
434: rs.updateBinaryStream(columnIndex, x, length);
435: }
436:
437: public void updateCharacterStream(int columnIndex,
438: java.io.Reader x, int length) throws SQLException {
439: rs.updateCharacterStream(columnIndex, x, length);
440: }
441:
442: public void updateObject(int columnIndex, Object x, int scale)
443: throws SQLException {
444: rs.updateObject(columnIndex, x, scale);
445: }
446:
447: public void updateObject(int columnIndex, Object x)
448: throws SQLException {
449: rs.updateObject(columnIndex, x);
450: }
451:
452: public void updateNull(String columnName) throws SQLException {
453: rs.updateNull(columnName);
454: }
455:
456: public void updateBoolean(String columnName, boolean x)
457: throws SQLException {
458: rs.updateBoolean(columnName, x);
459: }
460:
461: public void updateByte(String columnName, byte x)
462: throws SQLException {
463: rs.updateByte(columnName, x);
464: }
465:
466: public void updateShort(String columnName, short x)
467: throws SQLException {
468: rs.updateShort(columnName, x);
469: }
470:
471: public void updateInt(String columnName, int x) throws SQLException {
472: rs.updateInt(columnName, x);
473: }
474:
475: public void updateLong(String columnName, long x)
476: throws SQLException {
477: rs.updateLong(columnName, x);
478: }
479:
480: public void updateFloat(String columnName, float x)
481: throws SQLException {
482: rs.updateFloat(columnName, x);
483: }
484:
485: public void updateDouble(String columnName, double x)
486: throws SQLException {
487: rs.updateDouble(columnName, x);
488: }
489:
490: public void updateBigDecimal(String columnName, BigDecimal x)
491: throws SQLException {
492: rs.updateBigDecimal(columnName, x);
493: }
494:
495: public void updateString(String columnName, String x)
496: throws SQLException {
497: rs.updateString(columnName, x);
498: }
499:
500: public void updateBytes(String columnName, byte x[])
501: throws SQLException {
502: rs.updateBytes(columnName, x);
503: }
504:
505: public void updateDate(String columnName, java.sql.Date x)
506: throws SQLException {
507: rs.updateDate(columnName, x);
508: }
509:
510: public void updateTime(String columnName, java.sql.Time x)
511: throws SQLException {
512: rs.updateTime(columnName, x);
513: }
514:
515: public void updateTimestamp(String columnName, java.sql.Timestamp x)
516: throws SQLException {
517: rs.updateTimestamp(columnName, x);
518: }
519:
520: public void updateAsciiStream(String columnName,
521: java.io.InputStream x, int length) throws SQLException {
522: rs.updateAsciiStream(columnName, x, length);
523: }
524:
525: public void updateBinaryStream(String columnName,
526: java.io.InputStream x, int length) throws SQLException {
527: rs.updateBinaryStream(columnName, x, length);
528: }
529:
530: public void updateCharacterStream(String columnName,
531: java.io.Reader reader, int length) throws SQLException {
532: rs.updateCharacterStream(columnName, reader, length);
533: }
534:
535: public void updateObject(String columnName, Object x, int scale)
536: throws SQLException {
537: rs.updateObject(columnName, x, scale);
538: }
539:
540: public void updateObject(String columnName, Object x)
541: throws SQLException {
542: rs.updateObject(columnName, x);
543: }
544:
545: public void insertRow() throws SQLException {
546: rs.insertRow();
547: }
548:
549: public void updateRow() throws SQLException {
550: rs.updateRow();
551: }
552:
553: public void deleteRow() throws SQLException {
554: rs.deleteRow();
555: }
556:
557: public void refreshRow() throws SQLException {
558: rs.refreshRow();
559: }
560:
561: public void cancelRowUpdates() throws SQLException {
562: rs.cancelRowUpdates();
563: }
564:
565: public void moveToInsertRow() throws SQLException {
566: rs.moveToInsertRow();
567: }
568:
569: public void moveToCurrentRow() throws SQLException {
570: rs.moveToCurrentRow();
571: }
572:
573: public Statement getStatement() throws SQLException {
574: return rs.getStatement();
575: }
576:
577: public Object getObject(int i,
578: java.util.Map<java.lang.String, java.lang.Class<?>> map)
579: throws SQLException {
580: return rs.getObject(i, map);
581: }
582:
583: public Ref getRef(int i) throws SQLException {
584: return rs.getRef(i);
585: }
586:
587: public Blob getBlob(int i) throws SQLException {
588: return rs.getBlob(i);
589: }
590:
591: public Clob getClob(int i) throws SQLException {
592: return rs.getClob(i);
593: }
594:
595: public Array getArray(int i) throws SQLException {
596: return rs.getArray(i);
597: }
598:
599: public Object getObject(String colName,
600: java.util.Map<java.lang.String, java.lang.Class<?>> map)
601: throws SQLException {
602: return rs.getObject(colName, map);
603: }
604:
605: public Ref getRef(String colName) throws SQLException {
606: return rs.getRef(colName);
607: }
608:
609: public Blob getBlob(String colName) throws SQLException {
610: return rs.getBlob(colName);
611: }
612:
613: public Clob getClob(String colName) throws SQLException {
614: return rs.getClob(colName);
615: }
616:
617: public Array getArray(String colName) throws SQLException {
618: return rs.getArray(colName);
619: }
620:
621: public java.sql.Date getDate(int columnIndex, Calendar cal)
622: throws SQLException {
623: return rs.getDate(columnIndex, cal);
624: }
625:
626: public java.sql.Date getDate(String columnName, Calendar cal)
627: throws SQLException {
628: return rs.getDate(columnName, cal);
629: }
630:
631: public java.sql.Time getTime(int columnIndex, Calendar cal)
632: throws SQLException {
633: return rs.getTime(columnIndex, cal);
634: }
635:
636: public java.sql.Time getTime(String columnName, Calendar cal)
637: throws SQLException {
638: return rs.getTime(columnName, cal);
639: }
640:
641: public java.sql.Timestamp getTimestamp(int columnIndex, Calendar cal)
642: throws SQLException {
643: return rs.getTimestamp(columnIndex, cal);
644: }
645:
646: public java.sql.Timestamp getTimestamp(String columnName,
647: Calendar cal) throws SQLException {
648: return rs.getTimestamp(columnName, cal);
649: }
650:
651: public java.net.URL getURL(int columnIndex) throws SQLException {
652: return rs.getURL(columnIndex);
653: }
654:
655: public java.net.URL getURL(String columnName) throws SQLException {
656: return rs.getURL(columnName);
657: }
658:
659: public void updateRef(int columnIndex, java.sql.Ref x)
660: throws SQLException {
661: rs.updateRef(columnIndex, x);
662: }
663:
664: public void updateRef(String columnName, java.sql.Ref x)
665: throws SQLException {
666: rs.updateRef(columnName, x);
667: }
668:
669: public void updateBlob(int columnIndex, java.sql.Blob x)
670: throws SQLException {
671: rs.updateBlob(columnIndex, x);
672: }
673:
674: public void updateBlob(String columnName, java.sql.Blob x)
675: throws SQLException {
676: rs.updateBlob(columnName, x);
677: }
678:
679: public void updateClob(int columnIndex, java.sql.Clob x)
680: throws SQLException {
681: rs.updateClob(columnIndex, x);
682: }
683:
684: public void updateClob(String columnName, java.sql.Clob x)
685: throws SQLException {
686: rs.updateClob(columnName, x);
687: }
688:
689: public void updateArray(int columnIndex, java.sql.Array x)
690: throws SQLException {
691: rs.updateArray(columnIndex, x);
692: }
693:
694: public void updateArray(String columnName, java.sql.Array x)
695: throws SQLException {
696: rs.updateArray(columnName, x);
697: }
698: }
|