001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.apache.commons.dbcp2;
019
020import java.io.InputStream;
021import java.io.Reader;
022import java.math.BigDecimal;
023import java.sql.Array;
024import java.sql.Blob;
025import java.sql.Clob;
026import java.sql.Connection;
027import java.sql.Date;
028import java.sql.NClob;
029import java.sql.Ref;
030import java.sql.ResultSet;
031import java.sql.ResultSetMetaData;
032import java.sql.RowId;
033import java.sql.SQLException;
034import java.sql.SQLWarning;
035import java.sql.SQLXML;
036import java.sql.Statement;
037import java.sql.Time;
038import java.sql.Timestamp;
039import java.util.Calendar;
040import java.util.Map;
041
042/**
043 * A base delegating implementation of {@link ResultSet}.
044 * <p>
045 * All of the methods from the {@link ResultSet} interface
046 * simply call the corresponding method on the "delegate"
047 * provided in my constructor.
048 * <p>
049 * Extends AbandonedTrace to implement result set tracking and
050 * logging of code which created the ResultSet. Tracking the
051 * ResultSet ensures that the Statement which created it can
052 * close any open ResultSet's on Statement close.
053 *
054 * @author Glenn L. Nielsen
055 * @author James House
056 * @author Dirk Verbeeck
057 * @since 2.0
058 */
059public final class DelegatingResultSet extends AbandonedTrace implements ResultSet {
060
061    /** My delegate. **/
062    private final ResultSet _res;
063
064    /** The Statement that created me, if any. **/
065    private Statement _stmt;
066
067    /** The Connection that created me, if any. **/
068    private Connection _conn;
069
070    /**
071     * Create a wrapper for the ResultSet which traces this
072     * ResultSet to the Statement which created it and the
073     * code which created it.
074     * <p>
075     * Private to ensure all construction is
076     * {@link #wrapResultSet(Statement, ResultSet)}
077     *
078     * @param stmt Statement which created this ResultSet
079     * @param res ResultSet to wrap
080     */
081    private DelegatingResultSet(final Statement stmt, final ResultSet res) {
082        super((AbandonedTrace)stmt);
083        this._stmt = stmt;
084        this._res = res;
085    }
086
087    /**
088     * Create a wrapper for the ResultSet which traces this
089     * ResultSet to the Connection which created it (via, for
090     * example DatabaseMetadata, and the code which created it.
091     * <p>
092     * Private to ensure all construction is
093     * {@link #wrapResultSet(Connection, ResultSet)}
094     *
095     * @param conn Connection which created this ResultSet
096     * @param res ResultSet to wrap
097     */
098    private DelegatingResultSet(final Connection conn, final ResultSet res) {
099        super((AbandonedTrace)conn);
100        this._conn = conn;
101        this._res = res;
102    }
103
104    public static ResultSet wrapResultSet(final Statement stmt, final ResultSet rset) {
105        if(null == rset) {
106            return null;
107        }
108        return new DelegatingResultSet(stmt,rset);
109    }
110
111    public static ResultSet wrapResultSet(final Connection conn, final ResultSet rset) {
112        if(null == rset) {
113            return null;
114        }
115        return new DelegatingResultSet(conn,rset);
116    }
117
118    public ResultSet getDelegate() {
119        return _res;
120    }
121
122    /**
123     * If my underlying {@link ResultSet} is not a
124     * {@code DelegatingResultSet}, returns it,
125     * otherwise recursively invokes this method on
126     * my delegate.
127     * <p>
128     * Hence this method will return the first
129     * delegate that is not a {@code DelegatingResultSet},
130     * or {@code null} when no non-{@code DelegatingResultSet}
131     * delegate can be found by traversing this chain.
132     * <p>
133     * This method is useful when you may have nested
134     * {@code DelegatingResultSet}s, and you want to make
135     * sure to obtain a "genuine" {@link ResultSet}.
136     */
137    public ResultSet getInnermostDelegate() {
138        ResultSet r = _res;
139        while(r != null && r instanceof DelegatingResultSet) {
140            r = ((DelegatingResultSet)r).getDelegate();
141            if(this == r) {
142                return null;
143            }
144        }
145        return r;
146    }
147
148    @Override
149    public Statement getStatement() throws SQLException {
150        return _stmt;
151    }
152
153    /**
154     * Wrapper for close of ResultSet which removes this
155     * result set from being traced then calls close on
156     * the original ResultSet.
157     */
158    @Override
159    public void close() throws SQLException {
160        try {
161            if(_stmt != null) {
162                ((AbandonedTrace)_stmt).removeTrace(this);
163                _stmt = null;
164            }
165            if(_conn != null) {
166                ((AbandonedTrace)_conn).removeTrace(this);
167                _conn = null;
168            }
169            _res.close();
170        }
171        catch (final SQLException e) {
172            handleException(e);
173        }
174    }
175
176    protected void handleException(final SQLException e) throws SQLException {
177        if (_stmt != null && _stmt instanceof DelegatingStatement) {
178            ((DelegatingStatement)_stmt).handleException(e);
179        }
180        else if (_conn != null && _conn instanceof DelegatingConnection) {
181            ((DelegatingConnection<?>)_conn).handleException(e);
182        }
183        else {
184            throw e;
185        }
186    }
187
188    @Override
189    public boolean next() throws SQLException
190    { try { return _res.next(); } catch (final SQLException e) { handleException(e); return false; } }
191
192    @Override
193    public boolean wasNull() throws SQLException
194    { try { return _res.wasNull(); } catch (final SQLException e) { handleException(e); return false; } }
195
196    @Override
197    public String getString(final int columnIndex) throws SQLException
198    { try { return _res.getString(columnIndex); } catch (final SQLException e) { handleException(e); return null; } }
199
200    @Override
201    public boolean getBoolean(final int columnIndex) throws SQLException
202    { try { return _res.getBoolean(columnIndex); } catch (final SQLException e) { handleException(e); return false; } }
203
204    @Override
205    public byte getByte(final int columnIndex) throws SQLException
206    { try { return _res.getByte(columnIndex); } catch (final SQLException e) { handleException(e); return 0; } }
207
208    @Override
209    public short getShort(final int columnIndex) throws SQLException
210    { try { return _res.getShort(columnIndex); } catch (final SQLException e) { handleException(e); return 0; } }
211
212    @Override
213    public int getInt(final int columnIndex) throws SQLException
214    { try { return _res.getInt(columnIndex); } catch (final SQLException e) { handleException(e); return 0; } }
215
216    @Override
217    public long getLong(final int columnIndex) throws SQLException
218    { try { return _res.getLong(columnIndex); } catch (final SQLException e) { handleException(e); return 0; } }
219
220    @Override
221    public float getFloat(final int columnIndex) throws SQLException
222    { try { return _res.getFloat(columnIndex); } catch (final SQLException e) { handleException(e); return 0; } }
223
224    @Override
225    public double getDouble(final int columnIndex) throws SQLException
226    { try { return _res.getDouble(columnIndex); } catch (final SQLException e) { handleException(e); return 0; } }
227
228    /** @deprecated Use {@link #getBigDecimal(int)} */
229    @Deprecated
230    @Override
231    public BigDecimal getBigDecimal(final int columnIndex, final int scale) throws SQLException
232    { try { return _res.getBigDecimal(columnIndex); } catch (final SQLException e) { handleException(e); return null; } }
233
234    @Override
235    public byte[] getBytes(final int columnIndex) throws SQLException
236    { try { return _res.getBytes(columnIndex); } catch (final SQLException e) { handleException(e); return null; } }
237
238    @Override
239    public Date getDate(final int columnIndex) throws SQLException
240    { try { return _res.getDate(columnIndex); } catch (final SQLException e) { handleException(e); return null; } }
241
242    @Override
243    public Time getTime(final int columnIndex) throws SQLException
244    { try { return _res.getTime(columnIndex); } catch (final SQLException e) { handleException(e); return null; } }
245
246    @Override
247    public Timestamp getTimestamp(final int columnIndex) throws SQLException
248    { try { return _res.getTimestamp(columnIndex); } catch (final SQLException e) { handleException(e); return null; } }
249
250    @Override
251    public InputStream getAsciiStream(final int columnIndex) throws SQLException
252    { try { return _res.getAsciiStream(columnIndex); } catch (final SQLException e) { handleException(e); return null; } }
253
254    /** @deprecated Use {@link #getCharacterStream(int)} */
255    @Deprecated
256    @Override
257    public InputStream getUnicodeStream(final int columnIndex) throws SQLException
258    { try { return _res.getUnicodeStream(columnIndex); } catch (final SQLException e) { handleException(e); return null; } }
259
260    @Override
261    public InputStream getBinaryStream(final int columnIndex) throws SQLException
262    { try { return _res.getBinaryStream(columnIndex); } catch (final SQLException e) { handleException(e); return null; } }
263
264    @Override
265    public String getString(final String columnName) throws SQLException
266    { try { return _res.getString(columnName); } catch (final SQLException e) { handleException(e); return null; } }
267
268    @Override
269    public boolean getBoolean(final String columnName) throws SQLException
270    { try { return _res.getBoolean(columnName); } catch (final SQLException e) { handleException(e); return false; } }
271
272    @Override
273    public byte getByte(final String columnName) throws SQLException
274    { try { return _res.getByte(columnName); } catch (final SQLException e) { handleException(e); return 0; } }
275
276    @Override
277    public short getShort(final String columnName) throws SQLException
278    { try { return _res.getShort(columnName); } catch (final SQLException e) { handleException(e); return 0; } }
279
280    @Override
281    public int getInt(final String columnName) throws SQLException
282    { try { return _res.getInt(columnName); } catch (final SQLException e) { handleException(e); return 0; } }
283
284    @Override
285    public long getLong(final String columnName) throws SQLException
286    { try { return _res.getLong(columnName); } catch (final SQLException e) { handleException(e); return 0; } }
287
288    @Override
289    public float getFloat(final String columnName) throws SQLException
290    { try { return _res.getFloat(columnName); } catch (final SQLException e) { handleException(e); return 0; } }
291
292    @Override
293    public double getDouble(final String columnName) throws SQLException
294    { try { return _res.getDouble(columnName); } catch (final SQLException e) { handleException(e); return 0; } }
295
296    /** @deprecated Use {@link #getBigDecimal(String)} */
297    @Deprecated
298    @Override
299    public BigDecimal getBigDecimal(final String columnName, final int scale) throws SQLException
300    { try { return _res.getBigDecimal(columnName); } catch (final SQLException e) { handleException(e); return null; } }
301
302    @Override
303    public byte[] getBytes(final String columnName) throws SQLException
304    { try { return _res.getBytes(columnName); } catch (final SQLException e) { handleException(e); return null; } }
305
306    @Override
307    public Date getDate(final String columnName) throws SQLException
308    { try { return _res.getDate(columnName); } catch (final SQLException e) { handleException(e); return null; } }
309
310    @Override
311    public Time getTime(final String columnName) throws SQLException
312    { try { return _res.getTime(columnName); } catch (final SQLException e) { handleException(e); return null; } }
313
314    @Override
315    public Timestamp getTimestamp(final String columnName) throws SQLException
316    { try { return _res.getTimestamp(columnName); } catch (final SQLException e) { handleException(e); return null; } }
317
318    @Override
319    public InputStream getAsciiStream(final String columnName) throws SQLException
320    { try { return _res.getAsciiStream(columnName); } catch (final SQLException e) { handleException(e); return null; } }
321
322    /** @deprecated Use {@link #getCharacterStream(String)} */
323    @Deprecated
324    @Override
325    public InputStream getUnicodeStream(final String columnName) throws SQLException
326    { try { return _res.getUnicodeStream(columnName); } catch (final SQLException e) { handleException(e); return null; } }
327
328    @Override
329    public InputStream getBinaryStream(final String columnName) throws SQLException
330    { try { return _res.getBinaryStream(columnName); } catch (final SQLException e) { handleException(e); return null; } }
331
332    @Override
333    public SQLWarning getWarnings() throws SQLException
334    { try { return _res.getWarnings(); } catch (final SQLException e) { handleException(e); return null; } }
335
336    @Override
337    public void clearWarnings() throws SQLException
338    { try { _res.clearWarnings(); } catch (final SQLException e) { handleException(e); } }
339
340    @Override
341    public String getCursorName() throws SQLException
342    { try { return _res.getCursorName(); } catch (final SQLException e) { handleException(e); return null; } }
343
344    @Override
345    public ResultSetMetaData getMetaData() throws SQLException
346    { try { return _res.getMetaData(); } catch (final SQLException e) { handleException(e); return null; } }
347
348    @Override
349    public Object getObject(final int columnIndex) throws SQLException
350    { try { return _res.getObject(columnIndex); } catch (final SQLException e) { handleException(e); return null; } }
351
352    @Override
353    public Object getObject(final String columnName) throws SQLException
354    { try { return _res.getObject(columnName); } catch (final SQLException e) { handleException(e); return null; } }
355
356    @Override
357    public int findColumn(final String columnName) throws SQLException
358    { try { return _res.findColumn(columnName); } catch (final SQLException e) { handleException(e); return 0; } }
359
360    @Override
361    public Reader getCharacterStream(final int columnIndex) throws SQLException
362    { try { return _res.getCharacterStream(columnIndex); } catch (final SQLException e) { handleException(e); return null; } }
363
364    @Override
365    public Reader getCharacterStream(final String columnName) throws SQLException
366    { try { return _res.getCharacterStream(columnName); } catch (final SQLException e) { handleException(e); return null; } }
367
368    @Override
369    public BigDecimal getBigDecimal(final int columnIndex) throws SQLException
370    { try { return _res.getBigDecimal(columnIndex); } catch (final SQLException e) { handleException(e); return null; } }
371
372    @Override
373    public BigDecimal getBigDecimal(final String columnName) throws SQLException
374    { try { return _res.getBigDecimal(columnName); } catch (final SQLException e) { handleException(e); return null; } }
375
376    @Override
377    public boolean isBeforeFirst() throws SQLException
378    { try { return _res.isBeforeFirst(); } catch (final SQLException e) { handleException(e); return false; } }
379
380    @Override
381    public boolean isAfterLast() throws SQLException
382    { try { return _res.isAfterLast(); } catch (final SQLException e) { handleException(e); return false; } }
383
384    @Override
385    public boolean isFirst() throws SQLException
386    { try { return _res.isFirst(); } catch (final SQLException e) { handleException(e); return false; } }
387
388    @Override
389    public boolean isLast() throws SQLException
390    { try { return _res.isLast(); } catch (final SQLException e) { handleException(e); return false; } }
391
392    @Override
393    public void beforeFirst() throws SQLException
394    { try { _res.beforeFirst(); } catch (final SQLException e) { handleException(e); } }
395
396    @Override
397    public void afterLast() throws SQLException
398    { try { _res.afterLast(); } catch (final SQLException e) { handleException(e); } }
399
400    @Override
401    public boolean first() throws SQLException
402    { try { return _res.first(); } catch (final SQLException e) { handleException(e); return false; } }
403
404    @Override
405    public boolean last() throws SQLException
406    { try { return _res.last(); } catch (final SQLException e) { handleException(e); return false; } }
407
408    @Override
409    public int getRow() throws SQLException
410    { try { return _res.getRow(); } catch (final SQLException e) { handleException(e); return 0; } }
411
412    @Override
413    public boolean absolute(final int row) throws SQLException
414    { try { return _res.absolute(row); } catch (final SQLException e) { handleException(e); return false; } }
415
416    @Override
417    public boolean relative(final int rows) throws SQLException
418    { try { return _res.relative(rows); } catch (final SQLException e) { handleException(e); return false; } }
419
420    @Override
421    public boolean previous() throws SQLException
422    { try { return _res.previous(); } catch (final SQLException e) { handleException(e); return false; } }
423
424    @Override
425    public void setFetchDirection(final int direction) throws SQLException
426    { try { _res.setFetchDirection(direction); } catch (final SQLException e) { handleException(e); } }
427
428    @Override
429    public int getFetchDirection() throws SQLException
430    { try { return _res.getFetchDirection(); } catch (final SQLException e) { handleException(e); return 0; } }
431
432    @Override
433    public void setFetchSize(final int rows) throws SQLException
434    { try { _res.setFetchSize(rows); } catch (final SQLException e) { handleException(e); } }
435
436    @Override
437    public int getFetchSize() throws SQLException
438    { try { return _res.getFetchSize(); } catch (final SQLException e) { handleException(e); return 0; } }
439
440    @Override
441    public int getType() throws SQLException
442    { try { return _res.getType(); } catch (final SQLException e) { handleException(e); return 0; } }
443
444    @Override
445    public int getConcurrency() throws SQLException
446    { try { return _res.getConcurrency(); } catch (final SQLException e) { handleException(e); return 0; } }
447
448    @Override
449    public boolean rowUpdated() throws SQLException
450    { try { return _res.rowUpdated(); } catch (final SQLException e) { handleException(e); return false; } }
451
452    @Override
453    public boolean rowInserted() throws SQLException
454    { try { return _res.rowInserted(); } catch (final SQLException e) { handleException(e); return false; } }
455
456    @Override
457    public boolean rowDeleted() throws SQLException
458    { try { return _res.rowDeleted(); } catch (final SQLException e) { handleException(e); return false; } }
459
460    @Override
461    public void updateNull(final int columnIndex) throws SQLException
462    { try { _res.updateNull(columnIndex); } catch (final SQLException e) { handleException(e); } }
463
464    @Override
465    public void updateBoolean(final int columnIndex, final boolean x) throws SQLException
466    { try { _res.updateBoolean(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
467
468    @Override
469    public void updateByte(final int columnIndex, final byte x) throws SQLException
470    { try { _res.updateByte(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
471
472    @Override
473    public void updateShort(final int columnIndex, final short x) throws SQLException
474    { try { _res.updateShort(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
475
476    @Override
477    public void updateInt(final int columnIndex, final int x) throws SQLException
478    { try { _res.updateInt(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
479
480    @Override
481    public void updateLong(final int columnIndex, final long x) throws SQLException
482    { try { _res.updateLong(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
483
484    @Override
485    public void updateFloat(final int columnIndex, final float x) throws SQLException
486    { try { _res.updateFloat(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
487
488    @Override
489    public void updateDouble(final int columnIndex, final double x) throws SQLException
490    { try { _res.updateDouble(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
491
492    @Override
493    public void updateBigDecimal(final int columnIndex, final BigDecimal x) throws SQLException
494    { try { _res.updateBigDecimal(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
495
496    @Override
497    public void updateString(final int columnIndex, final String x) throws SQLException
498    { try { _res.updateString(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
499
500    @Override
501    public void updateBytes(final int columnIndex, final byte[] x) throws SQLException
502    { try { _res.updateBytes(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
503
504    @Override
505    public void updateDate(final int columnIndex, final Date x) throws SQLException
506    { try { _res.updateDate(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
507
508    @Override
509    public void updateTime(final int columnIndex, final Time x) throws SQLException
510    { try { _res.updateTime(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
511
512    @Override
513    public void updateTimestamp(final int columnIndex, final Timestamp x) throws SQLException
514    { try { _res.updateTimestamp(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
515
516    @Override
517    public void updateAsciiStream(final int columnIndex, final InputStream x, final int length) throws SQLException
518    { try { _res.updateAsciiStream(columnIndex, x, length); } catch (final SQLException e) { handleException(e); } }
519
520    @Override
521    public void updateBinaryStream(final int columnIndex, final InputStream x, final int length) throws SQLException
522    { try { _res.updateBinaryStream(columnIndex, x, length); } catch (final SQLException e) { handleException(e); } }
523
524    @Override
525    public void updateCharacterStream(final int columnIndex, final Reader x, final int length) throws SQLException
526    { try { _res.updateCharacterStream(columnIndex, x, length); } catch (final SQLException e) { handleException(e); } }
527
528    @Override
529    public void updateObject(final int columnIndex, final Object x, final int scale) throws SQLException
530    { try { _res.updateObject(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
531
532    @Override
533    public void updateObject(final int columnIndex, final Object x) throws SQLException
534    { try { _res.updateObject(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
535
536    @Override
537    public void updateNull(final String columnName) throws SQLException
538    { try { _res.updateNull(columnName); } catch (final SQLException e) { handleException(e); } }
539
540    @Override
541    public void updateBoolean(final String columnName, final boolean x) throws SQLException
542    { try { _res.updateBoolean(columnName, x); } catch (final SQLException e) { handleException(e); } }
543
544    @Override
545    public void updateByte(final String columnName, final byte x) throws SQLException
546    { try { _res.updateByte(columnName, x); } catch (final SQLException e) { handleException(e); } }
547
548    @Override
549    public void updateShort(final String columnName, final short x) throws SQLException
550    { try { _res.updateShort(columnName, x); } catch (final SQLException e) { handleException(e); } }
551
552    @Override
553    public void updateInt(final String columnName, final int x) throws SQLException
554    { try { _res.updateInt(columnName, x); } catch (final SQLException e) { handleException(e); } }
555
556    @Override
557    public void updateLong(final String columnName, final long x) throws SQLException
558    { try { _res.updateLong(columnName, x); } catch (final SQLException e) { handleException(e); } }
559
560    @Override
561    public void updateFloat(final String columnName, final float x) throws SQLException
562    { try { _res.updateFloat(columnName, x); } catch (final SQLException e) { handleException(e); } }
563
564    @Override
565    public void updateDouble(final String columnName, final double x) throws SQLException
566    { try { _res.updateDouble(columnName, x); } catch (final SQLException e) { handleException(e); } }
567
568    @Override
569    public void updateBigDecimal(final String columnName, final BigDecimal x) throws SQLException
570    { try { _res.updateBigDecimal(columnName, x); } catch (final SQLException e) { handleException(e); } }
571
572    @Override
573    public void updateString(final String columnName, final String x) throws SQLException
574    { try { _res.updateString(columnName, x); } catch (final SQLException e) { handleException(e); } }
575
576    @Override
577    public void updateBytes(final String columnName, final byte[] x) throws SQLException
578    { try { _res.updateBytes(columnName, x); } catch (final SQLException e) { handleException(e); } }
579
580    @Override
581    public void updateDate(final String columnName, final Date x) throws SQLException
582    { try { _res.updateDate(columnName, x); } catch (final SQLException e) { handleException(e); } }
583
584    @Override
585    public void updateTime(final String columnName, final Time x) throws SQLException
586    { try { _res.updateTime(columnName, x); } catch (final SQLException e) { handleException(e); } }
587
588    @Override
589    public void updateTimestamp(final String columnName, final Timestamp x) throws SQLException
590    { try { _res.updateTimestamp(columnName, x); } catch (final SQLException e) { handleException(e); } }
591
592    @Override
593    public void updateAsciiStream(final String columnName, final InputStream x, final int length) throws SQLException
594    { try { _res.updateAsciiStream(columnName, x, length); } catch (final SQLException e) { handleException(e); } }
595
596    @Override
597    public void updateBinaryStream(final String columnName, final InputStream x, final int length) throws SQLException
598    { try { _res.updateBinaryStream(columnName, x, length); } catch (final SQLException e) { handleException(e); } }
599
600    @Override
601    public void updateCharacterStream(final String columnName, final Reader reader, final int length) throws SQLException
602    { try { _res.updateCharacterStream(columnName, reader, length); } catch (final SQLException e) { handleException(e); } }
603
604    @Override
605    public void updateObject(final String columnName, final Object x, final int scale) throws SQLException
606    { try { _res.updateObject(columnName, x); } catch (final SQLException e) { handleException(e); } }
607
608    @Override
609    public void updateObject(final String columnName, final Object x) throws SQLException
610    { try { _res.updateObject(columnName, x); } catch (final SQLException e) { handleException(e); } }
611
612    @Override
613    public void insertRow() throws SQLException
614    { try { _res.insertRow(); } catch (final SQLException e) { handleException(e); } }
615
616    @Override
617    public void updateRow() throws SQLException
618    { try { _res.updateRow(); } catch (final SQLException e) { handleException(e); } }
619
620    @Override
621    public void deleteRow() throws SQLException
622    { try { _res.deleteRow(); } catch (final SQLException e) { handleException(e); } }
623
624    @Override
625    public void refreshRow() throws SQLException
626    { try { _res.refreshRow(); } catch (final SQLException e) { handleException(e); } }
627
628    @Override
629    public void cancelRowUpdates() throws SQLException
630    { try { _res.cancelRowUpdates(); } catch (final SQLException e) { handleException(e); } }
631
632    @Override
633    public void moveToInsertRow() throws SQLException
634    { try { _res.moveToInsertRow(); } catch (final SQLException e) { handleException(e); } }
635
636    @Override
637    public void moveToCurrentRow() throws SQLException
638    { try { _res.moveToCurrentRow(); } catch (final SQLException e) { handleException(e); } }
639
640    @Override
641    public Object getObject(final int i, final Map<String,Class<?>> map) throws SQLException
642    { try { return _res.getObject(i, map); } catch (final SQLException e) { handleException(e); return null; } }
643
644    @Override
645    public Ref getRef(final int i) throws SQLException
646    { try { return _res.getRef(i); } catch (final SQLException e) { handleException(e); return null; } }
647
648    @Override
649    public Blob getBlob(final int i) throws SQLException
650    { try { return _res.getBlob(i); } catch (final SQLException e) { handleException(e); return null; } }
651
652    @Override
653    public Clob getClob(final int i) throws SQLException
654    { try { return _res.getClob(i); } catch (final SQLException e) { handleException(e); return null; } }
655
656    @Override
657    public Array getArray(final int i) throws SQLException
658    { try { return _res.getArray(i); } catch (final SQLException e) { handleException(e); return null; } }
659
660    @Override
661    public Object getObject(final String colName, final Map<String,Class<?>> map) throws SQLException
662    { try { return _res.getObject(colName, map); } catch (final SQLException e) { handleException(e); return null; } }
663
664    @Override
665    public Ref getRef(final String colName) throws SQLException
666    { try { return _res.getRef(colName); } catch (final SQLException e) { handleException(e); return null; } }
667
668    @Override
669    public Blob getBlob(final String colName) throws SQLException
670    { try { return _res.getBlob(colName); } catch (final SQLException e) { handleException(e); return null; } }
671
672    @Override
673    public Clob getClob(final String colName) throws SQLException
674    { try { return _res.getClob(colName); } catch (final SQLException e) { handleException(e); return null; } }
675
676    @Override
677    public Array getArray(final String colName) throws SQLException
678    { try { return _res.getArray(colName); } catch (final SQLException e) { handleException(e); return null; } }
679
680    @Override
681    public Date getDate(final int columnIndex, final Calendar cal) throws SQLException
682    { try { return _res.getDate(columnIndex, cal); } catch (final SQLException e) { handleException(e); return null; } }
683
684    @Override
685    public Date getDate(final String columnName, final Calendar cal) throws SQLException
686    { try { return _res.getDate(columnName, cal); } catch (final SQLException e) { handleException(e); return null; } }
687
688    @Override
689    public Time getTime(final int columnIndex, final Calendar cal) throws SQLException
690    { try { return _res.getTime(columnIndex, cal); } catch (final SQLException e) { handleException(e); return null; } }
691
692    @Override
693    public Time getTime(final String columnName, final Calendar cal) throws SQLException
694    { try { return _res.getTime(columnName, cal); } catch (final SQLException e) { handleException(e); return null; } }
695
696    @Override
697    public Timestamp getTimestamp(final int columnIndex, final Calendar cal) throws SQLException
698    { try { return _res.getTimestamp(columnIndex, cal); } catch (final SQLException e) { handleException(e); return null; } }
699
700    @Override
701    public Timestamp getTimestamp(final String columnName, final Calendar cal) throws SQLException
702    { try { return _res.getTimestamp(columnName, cal); } catch (final SQLException e) { handleException(e); return null; } }
703
704
705    @Override
706    public java.net.URL getURL(final int columnIndex) throws SQLException
707    { try { return _res.getURL(columnIndex); } catch (final SQLException e) { handleException(e); return null; } }
708
709    @Override
710    public java.net.URL getURL(final String columnName) throws SQLException
711    { try { return _res.getURL(columnName); } catch (final SQLException e) { handleException(e); return null; } }
712
713    @Override
714    public void updateRef(final int columnIndex, final Ref x) throws SQLException
715    { try { _res.updateRef(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
716
717    @Override
718    public void updateRef(final String columnName, final Ref x) throws SQLException
719    { try { _res.updateRef(columnName, x); } catch (final SQLException e) { handleException(e); } }
720
721    @Override
722    public void updateBlob(final int columnIndex, final Blob x) throws SQLException
723    { try { _res.updateBlob(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
724
725    @Override
726    public void updateBlob(final String columnName, final Blob x) throws SQLException
727    { try { _res.updateBlob(columnName, x); } catch (final SQLException e) { handleException(e); } }
728
729    @Override
730    public void updateClob(final int columnIndex, final Clob x) throws SQLException
731    { try { _res.updateClob(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
732
733    @Override
734    public void updateClob(final String columnName, final Clob x) throws SQLException
735    { try { _res.updateClob(columnName, x); } catch (final SQLException e) { handleException(e); } }
736
737    @Override
738    public void updateArray(final int columnIndex, final Array x) throws SQLException
739    { try { _res.updateArray(columnIndex, x); } catch (final SQLException e) { handleException(e); } }
740
741    @Override
742    public void updateArray(final String columnName, final Array x) throws SQLException
743    { try { _res.updateArray(columnName, x); } catch (final SQLException e) { handleException(e); } }
744
745
746    @Override
747    public boolean isWrapperFor(final Class<?> iface) throws SQLException {
748        if (iface.isAssignableFrom(getClass())) {
749            return true;
750        } else if (iface.isAssignableFrom(_res.getClass())) {
751            return true;
752        } else {
753            return _res.isWrapperFor(iface);
754        }
755    }
756
757    @Override
758    public <T> T unwrap(final Class<T> iface) throws SQLException {
759        if (iface.isAssignableFrom(getClass())) {
760            return iface.cast(this);
761        } else if (iface.isAssignableFrom(_res.getClass())) {
762            return iface.cast(_res);
763        } else {
764            return _res.unwrap(iface);
765        }
766    }
767
768    @Override
769    public RowId getRowId(final int columnIndex) throws SQLException {
770        try {
771            return _res.getRowId(columnIndex);
772        }
773        catch (final SQLException e) {
774            handleException(e);
775            return null;
776        }
777    }
778
779    @Override
780    public RowId getRowId(final String columnLabel) throws SQLException {
781        try {
782            return _res.getRowId(columnLabel);
783        }
784        catch (final SQLException e) {
785            handleException(e);
786            return null;
787        }
788    }
789
790    @Override
791    public void updateRowId(final int columnIndex, final RowId value) throws SQLException {
792        try {
793            _res.updateRowId(columnIndex, value);
794        }
795        catch (final SQLException e) {
796            handleException(e);
797        }
798    }
799
800    @Override
801    public void updateRowId(final String columnLabel, final RowId value) throws SQLException {
802        try {
803            _res.updateRowId(columnLabel, value);
804        }
805        catch (final SQLException e) {
806            handleException(e);
807        }
808    }
809
810    @Override
811    public int getHoldability() throws SQLException {
812        try {
813            return _res.getHoldability();
814        }
815        catch (final SQLException e) {
816            handleException(e);
817            return 0;
818        }
819    }
820
821    @Override
822    public boolean isClosed() throws SQLException {
823        try {
824            return _res.isClosed();
825        }
826        catch (final SQLException e) {
827            handleException(e);
828            return false;
829        }
830    }
831
832    @Override
833    public void updateNString(final int columnIndex, final String value) throws SQLException {
834        try {
835            _res.updateNString(columnIndex, value);
836        }
837        catch (final SQLException e) {
838            handleException(e);
839        }
840    }
841
842    @Override
843    public void updateNString(final String columnLabel, final String value) throws SQLException {
844        try {
845            _res.updateNString(columnLabel, value);
846        }
847        catch (final SQLException e) {
848            handleException(e);
849        }
850    }
851
852    @Override
853    public void updateNClob(final int columnIndex, final NClob value) throws SQLException {
854        try {
855            _res.updateNClob(columnIndex, value);
856        }
857        catch (final SQLException e) {
858            handleException(e);
859        }
860    }
861
862    @Override
863    public void updateNClob(final String columnLabel, final NClob value) throws SQLException {
864        try {
865            _res.updateNClob(columnLabel, value);
866        }
867        catch (final SQLException e) {
868            handleException(e);
869        }
870    }
871
872    @Override
873    public NClob getNClob(final int columnIndex) throws SQLException {
874        try {
875            return _res.getNClob(columnIndex);
876        }
877        catch (final SQLException e) {
878            handleException(e);
879            return null;
880        }
881    }
882
883    @Override
884    public NClob getNClob(final String columnLabel) throws SQLException {
885        try {
886            return _res.getNClob(columnLabel);
887        }
888        catch (final SQLException e) {
889            handleException(e);
890            return null;
891        }
892    }
893
894    @Override
895    public SQLXML getSQLXML(final int columnIndex) throws SQLException {
896        try {
897            return _res.getSQLXML(columnIndex);
898        }
899        catch (final SQLException e) {
900            handleException(e);
901            return null;
902        }
903    }
904
905    @Override
906    public SQLXML getSQLXML(final String columnLabel) throws SQLException {
907        try {
908            return _res.getSQLXML(columnLabel);
909        }
910        catch (final SQLException e) {
911            handleException(e);
912            return null;
913        }
914    }
915
916    @Override
917    public void updateSQLXML(final int columnIndex, final SQLXML value) throws SQLException {
918        try {
919            _res.updateSQLXML(columnIndex, value);
920        }
921        catch (final SQLException e) {
922            handleException(e);
923        }
924    }
925
926    @Override
927    public void updateSQLXML(final String columnLabel, final SQLXML value) throws SQLException {
928        try {
929            _res.updateSQLXML(columnLabel, value);
930        }
931        catch (final SQLException e) {
932            handleException(e);
933        }
934    }
935
936    @Override
937    public String getNString(final int columnIndex) throws SQLException {
938        try {
939            return _res.getNString(columnIndex);
940        }
941        catch (final SQLException e) {
942            handleException(e);
943            return null;
944        }
945    }
946
947    @Override
948    public String getNString(final String columnLabel) throws SQLException {
949        try {
950            return _res.getNString(columnLabel);
951        }
952        catch (final SQLException e) {
953            handleException(e);
954            return null;
955        }
956    }
957
958    @Override
959    public Reader getNCharacterStream(final int columnIndex) throws SQLException {
960        try {
961            return _res.getNCharacterStream(columnIndex);
962        }
963        catch (final SQLException e) {
964            handleException(e);
965            return null;
966        }
967    }
968
969    @Override
970    public Reader getNCharacterStream(final String columnLabel) throws SQLException {
971        try {
972            return _res.getNCharacterStream(columnLabel);
973        }
974        catch (final SQLException e) {
975            handleException(e);
976            return null;
977        }
978    }
979
980    @Override
981    public void updateNCharacterStream(final int columnIndex, final Reader reader, final long length) throws SQLException {
982        try {
983            _res.updateNCharacterStream(columnIndex, reader, length);
984        }
985        catch (final SQLException e) {
986            handleException(e);
987        }
988    }
989
990    @Override
991    public void updateNCharacterStream(final String columnLabel, final Reader reader, final long length) throws SQLException {
992        try {
993            _res.updateNCharacterStream(columnLabel, reader, length);
994        }
995        catch (final SQLException e) {
996            handleException(e);
997        }
998    }
999
1000    @Override
1001    public void updateAsciiStream(final int columnIndex, final InputStream inputStream, final long length) throws SQLException {
1002        try {
1003            _res.updateAsciiStream(columnIndex, inputStream, length);
1004        }
1005        catch (final SQLException e) {
1006            handleException(e);
1007        }
1008    }
1009
1010    @Override
1011    public void updateBinaryStream(final int columnIndex, final InputStream inputStream, final long length) throws SQLException {
1012        try {
1013            _res.updateBinaryStream(columnIndex, inputStream, length);
1014        }
1015        catch (final SQLException e) {
1016            handleException(e);
1017        }
1018    }
1019
1020    @Override
1021    public void updateCharacterStream(final int columnIndex, final Reader reader, final long length) throws SQLException {
1022        try {
1023            _res.updateCharacterStream(columnIndex, reader, length);
1024        }
1025        catch (final SQLException e) {
1026            handleException(e);
1027        }
1028    }
1029
1030    @Override
1031    public void updateAsciiStream(final String columnLabel, final InputStream inputStream, final long length) throws SQLException {
1032        try {
1033            _res.updateAsciiStream(columnLabel, inputStream, length);
1034        }
1035        catch (final SQLException e) {
1036            handleException(e);
1037        }
1038    }
1039
1040    @Override
1041    public void updateBinaryStream(final String columnLabel, final InputStream inputStream, final long length) throws SQLException {
1042        try {
1043            _res.updateBinaryStream(columnLabel, inputStream, length);
1044        }
1045        catch (final SQLException e) {
1046            handleException(e);
1047        }
1048    }
1049
1050    @Override
1051    public void updateCharacterStream(final String columnLabel, final Reader reader, final long length) throws SQLException {
1052        try {
1053            _res.updateCharacterStream(columnLabel, reader, length);
1054        }
1055        catch (final SQLException e) {
1056            handleException(e);
1057        }
1058    }
1059
1060    @Override
1061    public void updateBlob(final int columnIndex, final InputStream inputStream, final long length) throws SQLException {
1062        try {
1063            _res.updateBlob(columnIndex, inputStream, length);
1064        }
1065        catch (final SQLException e) {
1066            handleException(e);
1067        }
1068    }
1069
1070    @Override
1071    public void updateBlob(final String columnLabel, final InputStream inputStream, final long length) throws SQLException {
1072        try {
1073            _res.updateBlob(columnLabel, inputStream, length);
1074        }
1075        catch (final SQLException e) {
1076            handleException(e);
1077        }
1078    }
1079
1080    @Override
1081    public void updateClob(final int columnIndex, final Reader reader, final long length) throws SQLException {
1082        try {
1083            _res.updateClob(columnIndex, reader, length);
1084        }
1085        catch (final SQLException e) {
1086            handleException(e);
1087        }
1088    }
1089
1090    @Override
1091    public void updateClob(final String columnLabel, final Reader reader, final long length) throws SQLException {
1092        try {
1093            _res.updateClob(columnLabel, reader, length);
1094        }
1095        catch (final SQLException e) {
1096            handleException(e);
1097        }
1098    }
1099
1100    @Override
1101    public void updateNClob(final int columnIndex, final Reader reader, final long length) throws SQLException {
1102        try {
1103            _res.updateNClob(columnIndex, reader, length);
1104        }
1105        catch (final SQLException e) {
1106            handleException(e);
1107        }
1108    }
1109
1110    @Override
1111    public void updateNClob(final String columnLabel, final Reader reader, final long length) throws SQLException {
1112        try {
1113            _res.updateNClob(columnLabel, reader, length);
1114        }
1115        catch (final SQLException e) {
1116            handleException(e);
1117        }
1118    }
1119
1120    @Override
1121    public void updateNCharacterStream(final int columnIndex, final Reader reader) throws SQLException {
1122        try {
1123            _res.updateNCharacterStream(columnIndex, reader);
1124        }
1125        catch (final SQLException e) {
1126            handleException(e);
1127        }
1128    }
1129
1130    @Override
1131    public void updateNCharacterStream(final String columnLabel, final Reader reader) throws SQLException {
1132        try {
1133            _res.updateNCharacterStream(columnLabel, reader);
1134        }
1135        catch (final SQLException e) {
1136            handleException(e);
1137        }
1138    }
1139
1140    @Override
1141    public void updateAsciiStream(final int columnIndex, final InputStream inputStream) throws SQLException {
1142        try {
1143            _res.updateAsciiStream(columnIndex, inputStream);
1144        }
1145        catch (final SQLException e) {
1146            handleException(e);
1147        }
1148    }
1149
1150    @Override
1151    public void updateBinaryStream(final int columnIndex, final InputStream inputStream) throws SQLException {
1152        try {
1153            _res.updateBinaryStream(columnIndex, inputStream);
1154        }
1155        catch (final SQLException e) {
1156            handleException(e);
1157        }
1158    }
1159
1160    @Override
1161    public void updateCharacterStream(final int columnIndex, final Reader reader) throws SQLException {
1162        try {
1163            _res.updateCharacterStream(columnIndex, reader);
1164        }
1165        catch (final SQLException e) {
1166            handleException(e);
1167        }
1168    }
1169
1170    @Override
1171    public void updateAsciiStream(final String columnLabel, final InputStream inputStream) throws SQLException {
1172        try {
1173            _res.updateAsciiStream(columnLabel, inputStream);
1174        }
1175        catch (final SQLException e) {
1176            handleException(e);
1177        }
1178    }
1179
1180    @Override
1181    public void updateBinaryStream(final String columnLabel, final InputStream inputStream) throws SQLException {
1182        try {
1183            _res.updateBinaryStream(columnLabel, inputStream);
1184        }
1185        catch (final SQLException e) {
1186            handleException(e);
1187        }
1188    }
1189
1190    @Override
1191    public void updateCharacterStream(final String columnLabel, final Reader reader) throws SQLException {
1192        try {
1193            _res.updateCharacterStream(columnLabel, reader);
1194        }
1195        catch (final SQLException e) {
1196            handleException(e);
1197        }
1198    }
1199
1200    @Override
1201    public void updateBlob(final int columnIndex, final InputStream inputStream) throws SQLException {
1202        try {
1203            _res.updateBlob(columnIndex, inputStream);
1204        }
1205        catch (final SQLException e) {
1206            handleException(e);
1207        }
1208    }
1209
1210    @Override
1211    public void updateBlob(final String columnLabel, final InputStream inputStream) throws SQLException {
1212        try {
1213            _res.updateBlob(columnLabel, inputStream);
1214        }
1215        catch (final SQLException e) {
1216            handleException(e);
1217        }
1218    }
1219
1220    @Override
1221    public void updateClob(final int columnIndex, final Reader reader) throws SQLException {
1222        try {
1223            _res.updateClob(columnIndex, reader);
1224        }
1225        catch (final SQLException e) {
1226            handleException(e);
1227        }
1228    }
1229
1230    @Override
1231    public void updateClob(final String columnLabel, final Reader reader) throws SQLException {
1232        try {
1233            _res.updateClob(columnLabel, reader);
1234        }
1235        catch (final SQLException e) {
1236            handleException(e);
1237        }
1238    }
1239
1240    @Override
1241    public void updateNClob(final int columnIndex, final Reader reader) throws SQLException {
1242        try {
1243            _res.updateNClob(columnIndex, reader);
1244        }
1245        catch (final SQLException e) {
1246            handleException(e);
1247        }
1248    }
1249
1250    @Override
1251    public void updateNClob(final String columnLabel, final Reader reader) throws SQLException {
1252        try {
1253            _res.updateNClob(columnLabel, reader);
1254        }
1255        catch (final SQLException e) {
1256            handleException(e);
1257        }
1258    }
1259
1260    @Override
1261    public <T> T getObject(final int columnIndex, final Class<T> type) throws SQLException {
1262        try {
1263            return _res.getObject(columnIndex, type);
1264        }
1265        catch (final SQLException e) {
1266            handleException(e);
1267            return null;
1268        }
1269    }
1270
1271    @Override
1272    public <T> T getObject(final String columnLabel, final Class<T> type)
1273            throws SQLException {
1274        try {
1275            return _res.getObject(columnLabel, type);
1276        }
1277        catch (final SQLException e) {
1278            handleException(e);
1279            return null;
1280        }
1281    }
1282
1283    @Override
1284    public String toString() {
1285        return super.toString() + "[_res=" + _res + ", _stmt=" + _stmt + ", _conn=" + _conn + "]";
1286    }
1287}