0001: /*
0002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
0003: * Distributed under the terms of either:
0004: * - the common development and distribution license (CDDL), v1.0; or
0005: * - the GNU Lesser General Public License, v2.1 or later
0006: * $Id: DbResultSet.java 3634 2007-01-08 21:42:24Z gbevin $
0007: */
0008: package com.uwyn.rife.database;
0009:
0010: import java.sql.*;
0011:
0012: import com.uwyn.rife.database.exceptions.DatabaseException;
0013: import com.uwyn.rife.database.exceptions.MissingResultsException;
0014: import com.uwyn.rife.database.exceptions.RowIndexOutOfBoundsException;
0015: import com.uwyn.rife.tools.ExceptionUtils;
0016: import java.io.InputStream;
0017: import java.io.Reader;
0018: import java.math.BigDecimal;
0019: import java.net.URL;
0020: import java.util.Calendar;
0021: import java.util.Map;
0022: import java.util.logging.Logger;
0023:
0024: public abstract class DbResultSet implements ResultSet, Cloneable {
0025: protected DbStatement mStatement = null;
0026: protected ResultSet mResultSet = null;
0027: protected boolean mFirstRowSkew = false;
0028: protected boolean mHasResultRows = false;
0029:
0030: DbResultSet(DbStatement statement, ResultSet resultSet) {
0031: assert statement != null;
0032: assert resultSet != null;
0033:
0034: mStatement = statement;
0035: mResultSet = resultSet;
0036: }
0037:
0038: public final boolean next() throws SQLException {
0039: if (mFirstRowSkew) {
0040: mFirstRowSkew = false;
0041: return true;
0042: } else if (mResultSet.next()) {
0043: mHasResultRows = true;
0044: mFirstRowSkew = false;
0045: return true;
0046: }
0047:
0048: return false;
0049: }
0050:
0051: public final boolean previous() throws SQLException {
0052: if (mFirstRowSkew) {
0053: throw new RowIndexOutOfBoundsException();
0054: }
0055:
0056: if (mResultSet.previous()) {
0057: mHasResultRows = true;
0058: mFirstRowSkew = false;
0059: return true;
0060: }
0061:
0062: return false;
0063: }
0064:
0065: public final boolean absolute(int row) throws SQLException {
0066: if (mResultSet.absolute(row)) {
0067: mHasResultRows = true;
0068: mFirstRowSkew = false;
0069: return true;
0070: }
0071:
0072: return false;
0073: }
0074:
0075: public final boolean relative(int rows) throws SQLException {
0076: if (mFirstRowSkew) {
0077: if (mResultSet.relative(rows - 1)) {
0078: mFirstRowSkew = false;
0079: }
0080: } else if (mResultSet.relative(rows)) {
0081: mHasResultRows = true;
0082: mFirstRowSkew = false;
0083: return true;
0084: }
0085:
0086: return false;
0087: }
0088:
0089: public final void beforeFirst() throws SQLException {
0090: mFirstRowSkew = false;
0091: mResultSet.beforeFirst();
0092: }
0093:
0094: public final boolean first() throws SQLException {
0095: if (mResultSet.first()) {
0096: mHasResultRows = true;
0097: mFirstRowSkew = false;
0098: return true;
0099: }
0100:
0101: return false;
0102: }
0103:
0104: public final boolean last() throws SQLException {
0105: if (mResultSet.last()) {
0106: mHasResultRows = true;
0107: mFirstRowSkew = false;
0108: return true;
0109: }
0110:
0111: return false;
0112: }
0113:
0114: public final void afterLast() throws SQLException {
0115: mResultSet.afterLast();
0116: }
0117:
0118: public final void moveToInsertRow() throws SQLException {
0119: mResultSet.moveToInsertRow();
0120: }
0121:
0122: public final void moveToCurrentRow() throws SQLException {
0123: mResultSet.moveToCurrentRow();
0124: }
0125:
0126: public final boolean isBeforeFirst() throws SQLException {
0127: if (mFirstRowSkew) {
0128: return true;
0129: }
0130:
0131: return mResultSet.isBeforeFirst();
0132: }
0133:
0134: public final boolean isFirst() throws SQLException {
0135: if (mFirstRowSkew) {
0136: return false;
0137: }
0138:
0139: return mResultSet.isFirst();
0140: }
0141:
0142: public final boolean isLast() throws SQLException {
0143: if (mFirstRowSkew) {
0144: return false;
0145: }
0146:
0147: return mResultSet.isLast();
0148: }
0149:
0150: public final boolean isAfterLast() throws SQLException {
0151: if (mFirstRowSkew) {
0152: return false;
0153: }
0154:
0155: return mResultSet.isAfterLast();
0156: }
0157:
0158: public final int getRow() throws SQLException {
0159: if (mFirstRowSkew) {
0160: return mResultSet.getRow() - 1;
0161: } else {
0162: return mResultSet.getRow();
0163: }
0164: }
0165:
0166: public final void refreshRow() throws SQLException {
0167: if (mFirstRowSkew) {
0168: throw new RowIndexOutOfBoundsException();
0169: }
0170:
0171: mResultSet.refreshRow();
0172: }
0173:
0174: public final void insertRow() throws SQLException {
0175: if (mFirstRowSkew) {
0176: throw new RowIndexOutOfBoundsException();
0177: }
0178:
0179: mResultSet.insertRow();
0180: }
0181:
0182: public final void updateRow() throws SQLException {
0183: if (mFirstRowSkew) {
0184: throw new RowIndexOutOfBoundsException();
0185: }
0186:
0187: mResultSet.updateRow();
0188: }
0189:
0190: public final void deleteRow() throws SQLException {
0191: if (mFirstRowSkew) {
0192: throw new RowIndexOutOfBoundsException();
0193: }
0194:
0195: mResultSet.deleteRow();
0196: }
0197:
0198: public final boolean rowInserted() throws SQLException {
0199: return mResultSet.rowInserted();
0200: }
0201:
0202: public final boolean rowUpdated() throws SQLException {
0203: return mResultSet.rowUpdated();
0204: }
0205:
0206: public final boolean rowDeleted() throws SQLException {
0207: return mResultSet.rowDeleted();
0208: }
0209:
0210: public final void close() throws SQLException {
0211: mStatement = null;
0212: if (mResultSet != null) {
0213: mResultSet.close();
0214: }
0215: mFirstRowSkew = false;
0216: mHasResultRows = false;
0217: }
0218:
0219: public final boolean wasNull() throws SQLException {
0220: if (mFirstRowSkew) {
0221: throw new RowIndexOutOfBoundsException();
0222: }
0223:
0224: return mResultSet.wasNull();
0225: }
0226:
0227: public final void setFetchDirection(int direction)
0228: throws SQLException {
0229: mResultSet.setFetchDirection(direction);
0230: }
0231:
0232: public final void setFetchSize(int rows) throws SQLException {
0233: mResultSet.setFetchSize(rows);
0234: }
0235:
0236: public final void cancelRowUpdates() throws SQLException {
0237: mResultSet.cancelRowUpdates();
0238: }
0239:
0240: public final ResultSetMetaData getMetaData() throws SQLException {
0241: return mResultSet.getMetaData();
0242: }
0243:
0244: public final int getConcurrency() throws SQLException {
0245: return mResultSet.getConcurrency();
0246: }
0247:
0248: public final int getFetchDirection() throws SQLException {
0249: return mResultSet.getFetchDirection();
0250: }
0251:
0252: public final int getFetchSize() throws SQLException {
0253: return mResultSet.getFetchSize();
0254: }
0255:
0256: public final void clearWarnings() throws SQLException {
0257: mResultSet.clearWarnings();
0258: }
0259:
0260: public final SQLWarning getWarnings() throws SQLException {
0261: return mResultSet.getWarnings();
0262: }
0263:
0264: public final String getCursorName() throws SQLException {
0265: return mResultSet.getCursorName();
0266: }
0267:
0268: public final Statement getStatement() throws SQLException {
0269: return mResultSet.getStatement();
0270: }
0271:
0272: public final int getType() throws SQLException {
0273: return mResultSet.getType();
0274: }
0275:
0276: public final int findColumn(String columnName) throws SQLException {
0277: if (mFirstRowSkew) {
0278: throw new RowIndexOutOfBoundsException();
0279: }
0280:
0281: return mResultSet.findColumn(columnName);
0282: }
0283:
0284: /**
0285: * Determines if there are rows available in the <code>ResultSet</code>
0286: * object that was returned by an <code>execute</code> method.
0287: * <p>
0288: * If an exception is thrown, the related <code>DbStatement</code> is
0289: * automatically closed and an ongoing transaction will be automatically
0290: * rolled back if it belongs to the executing thread.
0291: *
0292: * @return <code>true</code> if there are result rows available; or
0293: * <p>
0294: * <code>false</code> if no <code>ResultSet</code> object was available or
0295: * it didn't have any result rows.
0296: *
0297: * @throws DatabaseException if a database access error occurs
0298: *
0299: * @since 1.0
0300: */
0301: public boolean hasResultRows() throws DatabaseException {
0302: try {
0303: if (mResultSet != null) {
0304: if (mHasResultRows) {
0305: return true;
0306: }
0307:
0308: if (mFirstRowSkew) {
0309: return true;
0310: }
0311:
0312: if (next()) {
0313: mFirstRowSkew = true;
0314: mHasResultRows = true;
0315: return true;
0316: }
0317: }
0318: } catch (SQLException e) {
0319: mStatement.handleException();
0320: throw new DatabaseException(e);
0321: }
0322:
0323: return false;
0324: }
0325:
0326: /**
0327: * Retrieves the first field of the first row of this
0328: * <code>DbResultSet</code> object as a string. This method works both when
0329: * the <code>next</code> method has never been called or once been called.
0330: * <p>
0331: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0332: * method or alone where catching the <code>MissingResultsException</code>
0333: * is used to indicate the absence of results.
0334: * <p>
0335: * If an exception is thrown, the related <code>DbStatement</code> is
0336: * automatically closed and an ongoing transaction will be automatically
0337: * rolled back if it belongs to the executing thread.
0338: *
0339: * @return the first <code>String</code> object in the results.
0340: *
0341: * @throws DatabaseException if a database access error occurs. If there
0342: * are no results available the thrown exception is
0343: * {@link MissingResultsException}.
0344: *
0345: * @see #hasResultRows
0346: *
0347: * @since 1.0
0348: */
0349: public String getFirstString() throws DatabaseException {
0350: try {
0351: if (mResultSet != null
0352: && (isFirst() || (isBeforeFirst() && next()))) {
0353: return getString(1);
0354: }
0355: } catch (SQLException e) {
0356: mStatement.handleException();
0357: throw new DatabaseException(e);
0358: }
0359:
0360: throw new MissingResultsException(mStatement.getConnection()
0361: .getDatasource());
0362: }
0363:
0364: /**
0365: * Retrieves the first field of the first row of this
0366: * <code>DbResultSet</code> object as a boolean. This method works both when
0367: * the <code>next</code> method has never been called or once been called.
0368: * <p>
0369: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0370: * method or alone where catching the <code>MissingResultsException</code>
0371: * is used to indicate the absence of results.
0372: * <p>
0373: * If an exception is thrown, the related <code>DbStatement</code> is
0374: * automatically closed and an ongoing transaction will be automatically
0375: * rolled back if it belongs to the executing thread.
0376: *
0377: * @return the first <code>boolean</code> object in the results.
0378: *
0379: * @throws DatabaseException if a database access error occurs. If there
0380: * are no results available the thrown exception is
0381: * {@link MissingResultsException}.
0382: *
0383: * @see #hasResultRows
0384: *
0385: * @since 1.0
0386: */
0387: public boolean getFirstBoolean() throws DatabaseException {
0388: try {
0389: if (mResultSet != null
0390: && (isFirst() || (isBeforeFirst() && next()))) {
0391: return getBoolean(1);
0392: }
0393: } catch (SQLException e) {
0394: mStatement.handleException();
0395: throw new DatabaseException(e);
0396: }
0397:
0398: throw new MissingResultsException(mStatement.getConnection()
0399: .getDatasource());
0400: }
0401:
0402: /**
0403: * Retrieves the first field of the first row of this
0404: * <code>DbResultSet</code> object as a byte. This method works both when
0405: * the <code>next</code> method has never been called or once been called.
0406: * <p>
0407: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0408: * method or alone where catching the <code>MissingResultsException</code>
0409: * is used to indicate the absence of results.
0410: * <p>
0411: * If an exception is thrown, the related <code>DbStatement</code> is
0412: * automatically closed and an ongoing transaction will be automatically
0413: * rolled back if it belongs to the executing thread.
0414: *
0415: * @return the first <code>byte</code> object in the results.
0416: *
0417: * @throws DatabaseException if a database access error occurs. If there
0418: * are no results available the thrown exception is
0419: * {@link MissingResultsException}.
0420: *
0421: * @see #hasResultRows
0422: *
0423: * @since 1.0
0424: */
0425: public byte getFirstByte() throws DatabaseException {
0426: try {
0427: if (mResultSet != null
0428: && (isFirst() || (isBeforeFirst() && next()))) {
0429: return getByte(1);
0430: }
0431: } catch (SQLException e) {
0432: mStatement.handleException();
0433: throw new DatabaseException(e);
0434: }
0435:
0436: throw new MissingResultsException(mStatement.getConnection()
0437: .getDatasource());
0438: }
0439:
0440: /**
0441: * Retrieves the first field of the first row of this
0442: * <code>DbResultSet</code> object as a short. This method works both when
0443: * the <code>next</code> method has never been called or once been called.
0444: * <p>
0445: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0446: * method or alone where catching the <code>MissingResultsException</code>
0447: * is used to indicate the absence of results.
0448: * <p>
0449: * If an exception is thrown, the related <code>DbStatement</code> is
0450: * automatically closed and an ongoing transaction will be automatically
0451: * rolled back if it belongs to the executing thread.
0452: *
0453: * @return the first <code>short</code> object in the results.
0454: *
0455: * @throws DatabaseException if a database access error occurs. If there
0456: * are no results available the thrown exception is
0457: * {@link MissingResultsException}.
0458: *
0459: * @see #hasResultRows
0460: *
0461: * @since 1.0
0462: */
0463: public short getFirstShort() throws DatabaseException {
0464: try {
0465: if (mResultSet != null
0466: && (isFirst() || (isBeforeFirst() && next()))) {
0467: return getShort(1);
0468: }
0469: } catch (SQLException e) {
0470: mStatement.handleException();
0471: throw new DatabaseException(e);
0472: }
0473:
0474: throw new MissingResultsException(mStatement.getConnection()
0475: .getDatasource());
0476: }
0477:
0478: /**
0479: * Retrieves the first field of the first row of this
0480: * <code>DbResultSet</code> object as an integer. This method works both when
0481: * the <code>next</code> method has never been called or once been called.
0482: * <p>
0483: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0484: * method or alone where catching the <code>MissingResultsException</code>
0485: * is used to indicate the absence of results.
0486: * <p>
0487: * If an exception is thrown, the related <code>DbStatement</code> is
0488: * automatically closed and an ongoing transaction will be automatically
0489: * rolled back if it belongs to the executing thread.
0490: *
0491: * @return the first <code>int</code> object in the results.
0492: *
0493: * @throws DatabaseException if a database access error occurs. If there
0494: * are no results available the thrown exception is
0495: * {@link MissingResultsException}.
0496: *
0497: * @see #hasResultRows
0498: *
0499: * @since 1.0
0500: */
0501: public int getFirstInt() throws DatabaseException {
0502: try {
0503: if (mResultSet != null
0504: && (isFirst() || (isBeforeFirst() && next()))) {
0505: return getInt(1);
0506: }
0507: } catch (SQLException e) {
0508: mStatement.handleException();
0509: throw new DatabaseException(e);
0510: }
0511:
0512: throw new MissingResultsException(mStatement.getConnection()
0513: .getDatasource());
0514: }
0515:
0516: /**
0517: * Retrieves the first field of the first row of this
0518: * <code>DbResultSet</code> object as a long. This method works both when
0519: * the <code>next</code> method has never been called or once been called.
0520: * <p>
0521: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0522: * method or alone where catching the <code>MissingResultsException</code>
0523: * is used to indicate the absence of results.
0524: * <p>
0525: * If an exception is thrown, the related <code>DbStatement</code> is
0526: * automatically closed and an ongoing transaction will be automatically
0527: * rolled back if it belongs to the executing thread.
0528: *
0529: * @return the first <code>long</code> object in the results.
0530: *
0531: * @throws DatabaseException if a database access error occurs. If there
0532: * are no results available the thrown exception is
0533: * {@link MissingResultsException}.
0534: *
0535: * @see #hasResultRows
0536: *
0537: * @since 1.0
0538: */
0539: public long getFirstLong() throws DatabaseException {
0540: try {
0541: if (mResultSet != null
0542: && (isFirst() || (isBeforeFirst() && next()))) {
0543: return getLong(1);
0544: }
0545: } catch (SQLException e) {
0546: mStatement.handleException();
0547: throw new DatabaseException(e);
0548: }
0549:
0550: throw new MissingResultsException(mStatement.getConnection()
0551: .getDatasource());
0552: }
0553:
0554: /**
0555: * Retrieves the first field of the first row of this
0556: * <code>DbResultSet</code> object as a float. This method works both when
0557: * the <code>next</code> method has never been called or once been called.
0558: * <p>
0559: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0560: * method or alone where catching the <code>MissingResultsException</code>
0561: * is used to indicate the absence of results.
0562: * <p>
0563: * If an exception is thrown, the related <code>DbStatement</code> is
0564: * automatically closed and an ongoing transaction will be automatically
0565: * rolled back if it belongs to the executing thread.
0566: *
0567: * @return the first <code>float</code> object in the results.
0568: *
0569: * @throws DatabaseException if a database access error occurs. If there
0570: * are no results available the thrown exception is
0571: * {@link MissingResultsException}.
0572: *
0573: * @see #hasResultRows
0574: *
0575: * @since 1.0
0576: */
0577: public float getFirstFloat() throws DatabaseException {
0578: try {
0579: if (mResultSet != null
0580: && (isFirst() || (isBeforeFirst() && next()))) {
0581: return getFloat(1);
0582: }
0583: } catch (SQLException e) {
0584: mStatement.handleException();
0585: throw new DatabaseException(e);
0586: }
0587:
0588: throw new MissingResultsException(mStatement.getConnection()
0589: .getDatasource());
0590: }
0591:
0592: /**
0593: * Retrieves the first field of the first row of this
0594: * <code>DbResultSet</code> object as a double. This method works both when
0595: * the <code>next</code> method has never been called or once been called.
0596: * <p>
0597: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0598: * method or alone where catching the <code>MissingResultsException</code>
0599: * is used to indicate the absence of results.
0600: * <p>
0601: * If an exception is thrown, the related <code>DbStatement</code> is
0602: * automatically closed and an ongoing transaction will be automatically
0603: * rolled back if it belongs to the executing thread.
0604: *
0605: * @return the first <code>String</code> object in the results.
0606: *
0607: * @throws DatabaseException if a database access error occurs. If there
0608: * are no results available the thrown exception is
0609: * {@link MissingResultsException}.
0610: *
0611: * @see #hasResultRows
0612: *
0613: * @since 1.0
0614: */
0615: public double getFirstDouble() throws DatabaseException {
0616: try {
0617: if (mResultSet != null
0618: && (isFirst() || (isBeforeFirst() && next()))) {
0619: return getDouble(1);
0620: }
0621: } catch (SQLException e) {
0622: mStatement.handleException();
0623: throw new DatabaseException(e);
0624: }
0625:
0626: throw new MissingResultsException(mStatement.getConnection()
0627: .getDatasource());
0628: }
0629:
0630: /**
0631: * Retrieves the first field of the first row of this
0632: * <code>DbResultSet</code> object as a big decimal. This method works both when
0633: * the <code>next</code> method has never been called or once been called.
0634: * <p>
0635: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0636: * method or alone where catching the <code>MissingResultsException</code>
0637: * is used to indicate the absence of results.
0638: * <p>
0639: * If an exception is thrown, the related <code>DbStatement</code> is
0640: * automatically closed and an ongoing transaction will be automatically
0641: * rolled back if it belongs to the executing thread.
0642: *
0643: * @return the first <code>BigDecimal</code> object in the results.
0644: *
0645: * @throws DatabaseException if a database access error occurs. If there
0646: * are no results available the thrown exception is
0647: * {@link MissingResultsException}.
0648: *
0649: * @see #hasResultRows
0650: *
0651: * @since 1.0
0652: */
0653: public BigDecimal getFirstBigDecimal() throws DatabaseException {
0654: try {
0655: if (mResultSet != null
0656: && (isFirst() || (isBeforeFirst() && next()))) {
0657: return getBigDecimal(1);
0658: }
0659: } catch (SQLException e) {
0660: mStatement.handleException();
0661: throw new DatabaseException(e);
0662: }
0663:
0664: throw new MissingResultsException(mStatement.getConnection()
0665: .getDatasource());
0666: }
0667:
0668: /**
0669: * Retrieves the first field of the first row of this
0670: * <code>DbResultSet</code> object as an array of bytes. This method works
0671: * both when the <code>next</code> method has never been called or once been
0672: * called.
0673: * <p>
0674: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0675: * method or alone where catching the <code>MissingResultsException</code>
0676: * is used to indicate the absence of results.
0677: * <p>
0678: * If an exception is thrown, the related <code>DbStatement</code> is
0679: * automatically closed and an ongoing transaction will be automatically
0680: * rolled back if it belongs to the executing thread.
0681: *
0682: * @return the first <code>byte[]</code> object in the results.
0683: *
0684: * @throws DatabaseException if a database access error occurs. If there
0685: * are no results available the thrown exception is
0686: * {@link MissingResultsException}.
0687: *
0688: * @see #hasResultRows
0689: *
0690: * @since 1.0
0691: */
0692: public byte[] getFirstBytes() throws DatabaseException {
0693: try {
0694: if (mResultSet != null
0695: && (isFirst() || (isBeforeFirst() && next()))) {
0696: return getBytes(1);
0697: }
0698: } catch (SQLException e) {
0699: mStatement.handleException();
0700: throw new DatabaseException(e);
0701: }
0702:
0703: throw new MissingResultsException(mStatement.getConnection()
0704: .getDatasource());
0705: }
0706:
0707: /**
0708: * Retrieves the first field of the first row of this
0709: * <code>DbResultSet</code> object as a sql date. This method works both
0710: * when the <code>next</code> method has never been called or once been
0711: * called.
0712: * <p>
0713: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0714: * method or alone where catching the <code>MissingResultsException</code>
0715: * is used to indicate the absence of results.
0716: * <p>
0717: * If an exception is thrown, the related <code>DbStatement</code> is
0718: * automatically closed and an ongoing transaction will be automatically
0719: * rolled back if it belongs to the executing thread.
0720: *
0721: * @return the first <code>java.sql.Date</code> object in the results.
0722: *
0723: * @throws DatabaseException if a database access error occurs. If there
0724: * are no results available the thrown exception is
0725: * {@link MissingResultsException}.
0726: *
0727: * @see #hasResultRows
0728: *
0729: * @since 1.0
0730: */
0731: public java.sql.Date getFirstDate() throws DatabaseException {
0732: try {
0733: if (mResultSet != null
0734: && (isFirst() || (isBeforeFirst() && next()))) {
0735: return getDate(1);
0736: }
0737: } catch (SQLException e) {
0738: mStatement.handleException();
0739: throw new DatabaseException(e);
0740: }
0741:
0742: throw new MissingResultsException(mStatement.getConnection()
0743: .getDatasource());
0744: }
0745:
0746: /**
0747: * Retrieves the first field of the first row of this
0748: * <code>DbResultSet</code> object as a sql date. This method uses the given
0749: * calendar to construct an appropriate millisecond value for the date if
0750: * the underlying database does not store timezone information.
0751: * This method works both when the <code>next</code> method has never been
0752: * called or once been called.
0753: * <p>
0754: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0755: * method or alone where catching the <code>MissingResultsException</code>
0756: * is used to indicate the absence of results.
0757: * <p>
0758: * If an exception is thrown, the related <code>DbStatement</code> is
0759: * automatically closed and an ongoing transaction will be automatically
0760: * rolled back if it belongs to the executing thread.
0761: *
0762: * @param cal the <code>java.util.Calendar</code> object
0763: * to use in constructing the date
0764: *
0765: * @return the first <code>java.sql.Date</code> object in the resultsn;
0766: * if the value is SQL <code>NULL</code>,
0767: * the value returned is <code>null</code> in the Java programming language
0768: *
0769: * @throws DatabaseException if a database access error occurs. If there
0770: * are no results available the thrown exception is
0771: * {@link MissingResultsException}.
0772: *
0773: * @since 1.0
0774: */
0775: public java.sql.Date getFirstDate(Calendar cal)
0776: throws DatabaseException {
0777: try {
0778: if (mResultSet != null
0779: && (isFirst() || (isBeforeFirst() && next()))) {
0780: return getDate(1, cal);
0781: }
0782: } catch (SQLException e) {
0783: mStatement.handleException();
0784: throw new DatabaseException(e);
0785: }
0786:
0787: throw new MissingResultsException(mStatement.getConnection()
0788: .getDatasource());
0789: }
0790:
0791: /**
0792: * Retrieves the first field of the first row of this
0793: * <code>DbResultSet</code> object as a sql time. This method works both
0794: * when the <code>next</code> method has never been called or once been
0795: * called.
0796: * <p>
0797: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0798: * method or alone where catching the <code>MissingResultsException</code>
0799: * is used to indicate the absence of results.
0800: * <p>
0801: * If an exception is thrown, the related <code>DbStatement</code> is
0802: * automatically closed and an ongoing transaction will be automatically
0803: * rolled back if it belongs to the executing thread.
0804: *
0805: * @return the first <code>java.sql.Time</code> object in the results.
0806: *
0807: * @throws DatabaseException if a database access error occurs. If there
0808: * are no results available the thrown exception is
0809: * {@link MissingResultsException}.
0810: *
0811: * @see #hasResultRows
0812: *
0813: * @since 1.0
0814: */
0815: public java.sql.Time getFirstTime() throws DatabaseException {
0816: try {
0817: if (mResultSet != null
0818: && (isFirst() || (isBeforeFirst() && next()))) {
0819: return getTime(1);
0820: }
0821: } catch (SQLException e) {
0822: mStatement.handleException();
0823: throw new DatabaseException(e);
0824: }
0825:
0826: throw new MissingResultsException(mStatement.getConnection()
0827: .getDatasource());
0828: }
0829:
0830: /**
0831: * Retrieves the first field of the first row of this
0832: * <code>DbResultSet</code> object as a sql time. This method works both
0833: * when the <code>next</code> method has never been called or once been
0834: * called. This method uses the given calendar to construct an appropriate
0835: * millisecond value for the time if the underlying database does not store
0836: * timezone information.
0837: * This method works both when the <code>next</code> method has never been
0838: * called or once been called.
0839: * <p>
0840: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0841: * method or alone where catching the <code>MissingResultsException</code>
0842: * is used to indicate the absence of results.
0843: * <p>
0844: * If an exception is thrown, the related <code>DbStatement</code> is
0845: * automatically closed and an ongoing transaction will be automatically
0846: * rolled back if it belongs to the executing thread.
0847: *
0848: * @param cal the <code>java.util.Calendar</code> object to use in
0849: * constructing the time
0850: *
0851: * @return the first <code>java.sql.Time</code> object in the results.
0852: *
0853: * @throws DatabaseException if a database access error occurs. If there
0854: * are no results available the thrown exception is
0855: * {@link MissingResultsException}.
0856: *
0857: * @see #hasResultRows
0858: *
0859: * @since 1.0
0860: */
0861: public java.sql.Time getFirstTime(Calendar cal)
0862: throws DatabaseException {
0863: try {
0864: if (mResultSet != null
0865: && (isFirst() || (isBeforeFirst() && next()))) {
0866: return getTime(1, cal);
0867: }
0868: } catch (SQLException e) {
0869: mStatement.handleException();
0870: throw new DatabaseException(e);
0871: }
0872:
0873: throw new MissingResultsException(mStatement.getConnection()
0874: .getDatasource());
0875: }
0876:
0877: /**
0878: * Retrieves the first field of the first row of this
0879: * <code>DbResultSet</code> object as a sql timestamo. This method works both
0880: * when the <code>next</code> method has never been called or once been
0881: * called.
0882: * <p>
0883: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0884: * method or alone where catching the <code>MissingResultsException</code>
0885: * is used to indicate the absence of results.
0886: * <p>
0887: * If an exception is thrown, the related <code>DbStatement</code> is
0888: * automatically closed and an ongoing transaction will be automatically
0889: * rolled back if it belongs to the executing thread.
0890: *
0891: * @return the first <code>java.sql.Timestamp</code> object in the results.
0892: *
0893: * @throws DatabaseException if a database access error occurs. If there
0894: * are no results available the thrown exception is
0895: * {@link MissingResultsException}.
0896: *
0897: * @see #hasResultRows
0898: *
0899: * @since 1.0
0900: */
0901: public java.sql.Timestamp getFirstTimestamp()
0902: throws DatabaseException {
0903: try {
0904: if (mResultSet != null
0905: && (isFirst() || (isBeforeFirst() && next()))) {
0906: return getTimestamp(1);
0907: }
0908: } catch (SQLException e) {
0909: mStatement.handleException();
0910: throw new DatabaseException(e);
0911: }
0912:
0913: throw new MissingResultsException(mStatement.getConnection()
0914: .getDatasource());
0915: }
0916:
0917: /**
0918: * Retrieves the first field of the first row of this
0919: * <code>DbResultSet</code> object as a sql timestamp. This method uses the
0920: * given calendar to construct an appropriate millisecond value for the
0921: * timestamp if the underlying database does not store timezone information.
0922: * This method works both when the <code>next</code> method has never been
0923: * called or once been called.
0924: * <p>
0925: * It is perfectly usable after the <code>hasResultRows</code> method or
0926: * alone where catching the <code>MissingResultsException</code> is used to
0927: * indicate the absence of results.
0928: * <p>
0929: * If an exception is thrown, the related <code>DbStatement</code> is
0930: * automatically closed and an ongoing transaction will be automatically
0931: * rolled back if it belongs to the executing thread.
0932: *
0933: * @param cal the <code>java.util.Calendar</code> object to use in
0934: * constructing the date
0935: *
0936: * @return the first <code>java.sql.Timestamp</code> object in the results.
0937: *
0938: * @throws DatabaseException if a database access error occurs. If there
0939: * are no results available the thrown exception is
0940: * {@link MissingResultsException}.
0941: *
0942: * @see #hasResultRows
0943: *
0944: * @since 1.0
0945: */
0946: public java.sql.Timestamp getFirstTimestamp(Calendar cal)
0947: throws DatabaseException {
0948: try {
0949: if (mResultSet != null
0950: && (isFirst() || (isBeforeFirst() && next()))) {
0951: return getTimestamp(1, cal);
0952: }
0953: } catch (SQLException e) {
0954: mStatement.handleException();
0955: throw new DatabaseException(e);
0956: }
0957:
0958: throw new MissingResultsException(mStatement.getConnection()
0959: .getDatasource());
0960: }
0961:
0962: /**
0963: * Retrieves the first field of the first row of this
0964: * <code>DbResultSet</code> object as an ascii stream. This method works both
0965: * when the <code>next</code> method has never been called or once been
0966: * called.
0967: * <p>
0968: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
0969: * method or alone where catching the <code>MissingResultsException</code>
0970: * is used to indicate the absence of results.
0971: * <p>
0972: * If an exception is thrown, the related <code>DbStatement</code> is
0973: * automatically closed and an ongoing transaction will be automatically
0974: * rolled back if it belongs to the executing thread.
0975: *
0976: * @return the first <code>java.io.InputStream</code> object in the results.
0977: *
0978: * @throws DatabaseException if a database access error occurs. If there
0979: * are no results available the thrown exception is
0980: * {@link MissingResultsException}.
0981: *
0982: * @see #hasResultRows
0983: *
0984: * @since 1.0
0985: */
0986: public InputStream getFirstAsciiStream() throws DatabaseException {
0987: try {
0988: if (mResultSet != null
0989: && (isFirst() || (isBeforeFirst() && next()))) {
0990: return getAsciiStream(1);
0991: }
0992: } catch (SQLException e) {
0993: mStatement.handleException();
0994: throw new DatabaseException(e);
0995: }
0996:
0997: throw new MissingResultsException(mStatement.getConnection()
0998: .getDatasource());
0999: }
1000:
1001: /**
1002: * Retrieves the first field of the first row of this
1003: * <code>DbResultSet</code> object as a character stream. This method works
1004: * both when the <code>next</code> method has never been called or once been
1005: * called.
1006: * <p>
1007: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
1008: * method or alone where catching the <code>MissingResultsException</code>
1009: * is used to indicate the absence of results.
1010: * <p>
1011: * If an exception is thrown, the related <code>DbStatement</code> is
1012: * automatically closed and an ongoing transaction will be automatically
1013: * rolled back if it belongs to the executing thread.
1014: *
1015: * @return the first <code>java.io.Reader</code> object in the results.
1016: *
1017: * @throws DatabaseException if a database access error occurs. If there
1018: * are no results available the thrown exception is
1019: * {@link MissingResultsException}.
1020: *
1021: * @see #hasResultRows
1022: *
1023: * @since 1.0
1024: */
1025: public Reader getFirstCharacterStream() throws DatabaseException {
1026: try {
1027: if (mResultSet != null
1028: && (isFirst() || (isBeforeFirst() && next()))) {
1029: return getCharacterStream(1);
1030: }
1031: } catch (SQLException e) {
1032: mStatement.handleException();
1033: throw new DatabaseException(e);
1034: }
1035:
1036: throw new MissingResultsException(mStatement.getConnection()
1037: .getDatasource());
1038: }
1039:
1040: /**
1041: * Retrieves the first field of the first row of this
1042: * <code>DbResultSet</code> object as a binary stream. This method works hiboth
1043: * when the <code>next</code> method has never been called or once been
1044: * called.
1045: * <p>
1046: * Therefore, it's thus perfectly usable after the <code>hasResultRows</code>
1047: * method or alone where catching the <code>MissingResultsException</code>
1048: * is used to indicate the absence of results.
1049: * <p>
1050: * If an exception is thrown, the related <code>DbStatement</code> is
1051: * automatically closed and an ongoing transaction will be automatically
1052: * rolled back if it belongs to the executing thread.
1053: *
1054: * @return the first <code>java.io.InputStream</code> object in the results.
1055: *
1056: * @throws DatabaseException if a database access error occurs. If there
1057: * are no results available the thrown exception is
1058: * {@link MissingResultsException}.
1059: *
1060: * @see #hasResultRows
1061: *
1062: * @since 1.0
1063: */
1064: public InputStream getFirstBinaryStream() throws DatabaseException {
1065: try {
1066: if (mResultSet != null
1067: && (isFirst() || (isBeforeFirst() && next()))) {
1068: return getBinaryStream(1);
1069: }
1070: } catch (SQLException e) {
1071: mStatement.handleException();
1072: throw new DatabaseException(e);
1073: }
1074:
1075: throw new MissingResultsException(mStatement.getConnection()
1076: .getDatasource());
1077: }
1078:
1079: public final String getString(int columnIndex) throws SQLException {
1080: if (mFirstRowSkew) {
1081: throw new RowIndexOutOfBoundsException();
1082: }
1083:
1084: return mResultSet.getString(columnIndex);
1085: }
1086:
1087: public final String getString(String columnName)
1088: throws SQLException {
1089: if (mFirstRowSkew) {
1090: throw new RowIndexOutOfBoundsException();
1091: }
1092:
1093: return mResultSet.getString(columnName);
1094: }
1095:
1096: public final boolean getBoolean(int columnIndex)
1097: throws SQLException {
1098: if (mFirstRowSkew) {
1099: throw new RowIndexOutOfBoundsException();
1100: }
1101:
1102: return mResultSet.getBoolean(columnIndex);
1103: }
1104:
1105: public final boolean getBoolean(String columnName)
1106: throws SQLException {
1107: if (mFirstRowSkew) {
1108: throw new RowIndexOutOfBoundsException();
1109: }
1110:
1111: return mResultSet.getBoolean(columnName);
1112: }
1113:
1114: public final byte getByte(int columnIndex) throws SQLException {
1115: if (mFirstRowSkew) {
1116: throw new RowIndexOutOfBoundsException();
1117: }
1118:
1119: return mResultSet.getByte(columnIndex);
1120: }
1121:
1122: public final byte getByte(String columnName) throws SQLException {
1123: if (mFirstRowSkew) {
1124: throw new RowIndexOutOfBoundsException();
1125: }
1126:
1127: return mResultSet.getByte(columnName);
1128: }
1129:
1130: public final short getShort(int columnIndex) throws SQLException {
1131: if (mFirstRowSkew) {
1132: throw new RowIndexOutOfBoundsException();
1133: }
1134:
1135: return mResultSet.getShort(columnIndex);
1136: }
1137:
1138: public final short getShort(String columnName) throws SQLException {
1139: if (mFirstRowSkew) {
1140: throw new RowIndexOutOfBoundsException();
1141: }
1142:
1143: return mResultSet.getShort(columnName);
1144: }
1145:
1146: public final int getInt(int columnIndex) throws SQLException {
1147: if (mFirstRowSkew) {
1148: throw new RowIndexOutOfBoundsException();
1149: }
1150:
1151: return mResultSet.getInt(columnIndex);
1152: }
1153:
1154: public final int getInt(String columnName) throws SQLException {
1155: if (mFirstRowSkew) {
1156: throw new RowIndexOutOfBoundsException();
1157: }
1158:
1159: return mResultSet.getInt(columnName);
1160: }
1161:
1162: public final long getLong(int columnIndex) throws SQLException {
1163: if (mFirstRowSkew) {
1164: throw new RowIndexOutOfBoundsException();
1165: }
1166:
1167: return mResultSet.getLong(columnIndex);
1168: }
1169:
1170: public final long getLong(String columnName) throws SQLException {
1171: if (mFirstRowSkew) {
1172: throw new RowIndexOutOfBoundsException();
1173: }
1174:
1175: return mResultSet.getLong(columnName);
1176: }
1177:
1178: public final float getFloat(int columnIndex) throws SQLException {
1179: if (mFirstRowSkew) {
1180: throw new RowIndexOutOfBoundsException();
1181: }
1182:
1183: return mResultSet.getFloat(columnIndex);
1184: }
1185:
1186: public final float getFloat(String columnName) throws SQLException {
1187: if (mFirstRowSkew) {
1188: throw new RowIndexOutOfBoundsException();
1189: }
1190:
1191: return mResultSet.getFloat(columnName);
1192: }
1193:
1194: public final double getDouble(int columnIndex) throws SQLException {
1195: if (mFirstRowSkew) {
1196: throw new RowIndexOutOfBoundsException();
1197: }
1198:
1199: return mResultSet.getDouble(columnIndex);
1200: }
1201:
1202: public final double getDouble(String columnName)
1203: throws SQLException {
1204: if (mFirstRowSkew) {
1205: throw new RowIndexOutOfBoundsException();
1206: }
1207:
1208: return mResultSet.getDouble(columnName);
1209: }
1210:
1211: public final BigDecimal getBigDecimal(int columnIndex)
1212: throws SQLException {
1213: if (mFirstRowSkew) {
1214: throw new RowIndexOutOfBoundsException();
1215: }
1216:
1217: return mResultSet.getBigDecimal(columnIndex);
1218: }
1219:
1220: public final BigDecimal getBigDecimal(String columnName)
1221: throws SQLException {
1222: if (mFirstRowSkew) {
1223: throw new RowIndexOutOfBoundsException();
1224: }
1225:
1226: return mResultSet.getBigDecimal(columnName);
1227: }
1228:
1229: public final BigDecimal getBigDecimal(int columnIndex, int scale)
1230: throws SQLException {
1231: if (mFirstRowSkew) {
1232: throw new RowIndexOutOfBoundsException();
1233: }
1234:
1235: return mResultSet.getBigDecimal(columnIndex, scale);
1236: }
1237:
1238: public final BigDecimal getBigDecimal(String columnName, int scale)
1239: throws SQLException {
1240: if (mFirstRowSkew) {
1241: throw new RowIndexOutOfBoundsException();
1242: }
1243:
1244: return mResultSet.getBigDecimal(columnName, scale);
1245: }
1246:
1247: public final byte[] getBytes(int columnIndex) throws SQLException {
1248: if (mFirstRowSkew) {
1249: throw new RowIndexOutOfBoundsException();
1250: }
1251:
1252: return mResultSet.getBytes(columnIndex);
1253: }
1254:
1255: public final byte[] getBytes(String columnName) throws SQLException {
1256: if (mFirstRowSkew) {
1257: throw new RowIndexOutOfBoundsException();
1258: }
1259:
1260: return mResultSet.getBytes(columnName);
1261: }
1262:
1263: public final Date getDate(int columnIndex) throws SQLException {
1264: if (mFirstRowSkew) {
1265: throw new RowIndexOutOfBoundsException();
1266: }
1267:
1268: return mResultSet.getDate(columnIndex);
1269: }
1270:
1271: public final Date getDate(String columnName) throws SQLException {
1272: if (mFirstRowSkew) {
1273: throw new RowIndexOutOfBoundsException();
1274: }
1275:
1276: return mResultSet.getDate(columnName);
1277: }
1278:
1279: public final Date getDate(int columnIndex, Calendar cal)
1280: throws SQLException {
1281: if (mFirstRowSkew) {
1282: throw new RowIndexOutOfBoundsException();
1283: }
1284:
1285: return mResultSet.getDate(columnIndex, cal);
1286: }
1287:
1288: public final Date getDate(String columnName, Calendar cal)
1289: throws SQLException {
1290: if (mFirstRowSkew) {
1291: throw new RowIndexOutOfBoundsException();
1292: }
1293:
1294: return mResultSet.getDate(columnName, cal);
1295: }
1296:
1297: public final Time getTime(int columnIndex) throws SQLException {
1298: if (mFirstRowSkew) {
1299: throw new RowIndexOutOfBoundsException();
1300: }
1301:
1302: return mResultSet.getTime(columnIndex);
1303: }
1304:
1305: public final Time getTime(String columnName) throws SQLException {
1306: if (mFirstRowSkew) {
1307: throw new RowIndexOutOfBoundsException();
1308: }
1309:
1310: return mResultSet.getTime(columnName);
1311: }
1312:
1313: public final Time getTime(int columnIndex, Calendar cal)
1314: throws SQLException {
1315: if (mFirstRowSkew) {
1316: throw new RowIndexOutOfBoundsException();
1317: }
1318:
1319: return mResultSet.getTime(columnIndex, cal);
1320: }
1321:
1322: public final Time getTime(String columnName, Calendar cal)
1323: throws SQLException {
1324: if (mFirstRowSkew) {
1325: throw new RowIndexOutOfBoundsException();
1326: }
1327:
1328: return mResultSet.getTime(columnName, cal);
1329: }
1330:
1331: public final Timestamp getTimestamp(int columnIndex)
1332: throws SQLException {
1333: if (mFirstRowSkew) {
1334: throw new RowIndexOutOfBoundsException();
1335: }
1336:
1337: return mResultSet.getTimestamp(columnIndex);
1338: }
1339:
1340: public final Timestamp getTimestamp(String columnName)
1341: throws SQLException {
1342: if (mFirstRowSkew) {
1343: throw new RowIndexOutOfBoundsException();
1344: }
1345:
1346: return mResultSet.getTimestamp(columnName);
1347: }
1348:
1349: public final Timestamp getTimestamp(int columnIndex, Calendar cal)
1350: throws SQLException {
1351: if (mFirstRowSkew) {
1352: throw new RowIndexOutOfBoundsException();
1353: }
1354:
1355: return mResultSet.getTimestamp(columnIndex, cal);
1356: }
1357:
1358: public final Timestamp getTimestamp(String columnName, Calendar cal)
1359: throws SQLException {
1360: if (mFirstRowSkew) {
1361: throw new RowIndexOutOfBoundsException();
1362: }
1363:
1364: return mResultSet.getTimestamp(columnName, cal);
1365: }
1366:
1367: public final InputStream getAsciiStream(int columnIndex)
1368: throws SQLException {
1369: if (mFirstRowSkew) {
1370: throw new RowIndexOutOfBoundsException();
1371: }
1372:
1373: return mResultSet.getAsciiStream(columnIndex);
1374: }
1375:
1376: public final InputStream getAsciiStream(String columnName)
1377: throws SQLException {
1378: if (mFirstRowSkew) {
1379: throw new RowIndexOutOfBoundsException();
1380: }
1381:
1382: return mResultSet.getAsciiStream(columnName);
1383: }
1384:
1385: public final InputStream getUnicodeStream(int columnIndex)
1386: throws SQLException {
1387: if (mFirstRowSkew) {
1388: throw new RowIndexOutOfBoundsException();
1389: }
1390:
1391: return mResultSet.getUnicodeStream(columnIndex);
1392: }
1393:
1394: public final InputStream getUnicodeStream(String columnName)
1395: throws SQLException {
1396: if (mFirstRowSkew) {
1397: throw new RowIndexOutOfBoundsException();
1398: }
1399:
1400: return mResultSet.getUnicodeStream(columnName);
1401: }
1402:
1403: public final Reader getCharacterStream(int columnIndex)
1404: throws SQLException {
1405: if (mFirstRowSkew) {
1406: throw new RowIndexOutOfBoundsException();
1407: }
1408:
1409: return mResultSet.getCharacterStream(columnIndex);
1410: }
1411:
1412: public final Reader getCharacterStream(String columnName)
1413: throws SQLException {
1414: if (mFirstRowSkew) {
1415: throw new RowIndexOutOfBoundsException();
1416: }
1417:
1418: return mResultSet.getCharacterStream(columnName);
1419: }
1420:
1421: public final InputStream getBinaryStream(int columnIndex)
1422: throws SQLException {
1423: if (mFirstRowSkew) {
1424: throw new RowIndexOutOfBoundsException();
1425: }
1426:
1427: return mResultSet.getBinaryStream(columnIndex);
1428: }
1429:
1430: public final InputStream getBinaryStream(String columnName)
1431: throws SQLException {
1432: if (mFirstRowSkew) {
1433: throw new RowIndexOutOfBoundsException();
1434: }
1435:
1436: return mResultSet.getBinaryStream(columnName);
1437: }
1438:
1439: public final Ref getRef(String colName) throws SQLException {
1440: if (mFirstRowSkew) {
1441: throw new RowIndexOutOfBoundsException();
1442: }
1443:
1444: return mResultSet.getRef(colName);
1445: }
1446:
1447: public final Ref getRef(int i) throws SQLException {
1448: if (mFirstRowSkew) {
1449: throw new RowIndexOutOfBoundsException();
1450: }
1451:
1452: return mResultSet.getRef(i);
1453: }
1454:
1455: public final Object getObject(int columnIndex) throws SQLException {
1456: if (mFirstRowSkew) {
1457: throw new RowIndexOutOfBoundsException();
1458: }
1459:
1460: return mResultSet.getObject(columnIndex);
1461: }
1462:
1463: public final Object getObject(String columnName)
1464: throws SQLException {
1465: if (mFirstRowSkew) {
1466: throw new RowIndexOutOfBoundsException();
1467: }
1468:
1469: return mResultSet.getObject(columnName);
1470: }
1471:
1472: public final Object getObject(int i, Map map) throws SQLException {
1473: if (mFirstRowSkew) {
1474: throw new RowIndexOutOfBoundsException();
1475: }
1476:
1477: return mResultSet.getObject(i, map);
1478: }
1479:
1480: public final Object getObject(String colName, Map map)
1481: throws SQLException {
1482: if (mFirstRowSkew) {
1483: throw new RowIndexOutOfBoundsException();
1484: }
1485:
1486: return mResultSet.getObject(colName, map);
1487: }
1488:
1489: public final Blob getBlob(int i) throws SQLException {
1490: if (mFirstRowSkew) {
1491: throw new RowIndexOutOfBoundsException();
1492: }
1493:
1494: return mResultSet.getBlob(i);
1495: }
1496:
1497: public final Blob getBlob(String colName) throws SQLException {
1498: if (mFirstRowSkew) {
1499: throw new RowIndexOutOfBoundsException();
1500: }
1501:
1502: return mResultSet.getBlob(colName);
1503: }
1504:
1505: public final Clob getClob(int i) throws SQLException {
1506: if (mFirstRowSkew) {
1507: throw new RowIndexOutOfBoundsException();
1508: }
1509:
1510: return mResultSet.getClob(i);
1511: }
1512:
1513: public final Clob getClob(String colName) throws SQLException {
1514: if (mFirstRowSkew) {
1515: throw new RowIndexOutOfBoundsException();
1516: }
1517:
1518: return mResultSet.getClob(colName);
1519: }
1520:
1521: public final Array getArray(String colName) throws SQLException {
1522: if (mFirstRowSkew) {
1523: throw new RowIndexOutOfBoundsException();
1524: }
1525:
1526: return mResultSet.getArray(colName);
1527: }
1528:
1529: public final Array getArray(int i) throws SQLException {
1530: if (mFirstRowSkew) {
1531: throw new RowIndexOutOfBoundsException();
1532: }
1533:
1534: return mResultSet.getArray(i);
1535: }
1536:
1537: public final URL getURL(int columnIndex) throws SQLException {
1538: if (mFirstRowSkew) {
1539: throw new RowIndexOutOfBoundsException();
1540: }
1541:
1542: return mResultSet.getURL(columnIndex);
1543: }
1544:
1545: public final URL getURL(String columnName) throws SQLException {
1546: if (mFirstRowSkew) {
1547: throw new RowIndexOutOfBoundsException();
1548: }
1549:
1550: return mResultSet.getURL(columnName);
1551: }
1552:
1553: public final void updateNull(int columnIndex) throws SQLException {
1554: if (mFirstRowSkew) {
1555: throw new RowIndexOutOfBoundsException();
1556: }
1557:
1558: mResultSet.updateNull(columnIndex);
1559: }
1560:
1561: public final void updateNull(String columnName) throws SQLException {
1562: if (mFirstRowSkew) {
1563: throw new RowIndexOutOfBoundsException();
1564: }
1565:
1566: mResultSet.updateNull(columnName);
1567: }
1568:
1569: public final void updateString(int columnIndex, String x)
1570: throws SQLException {
1571: if (mFirstRowSkew) {
1572: throw new RowIndexOutOfBoundsException();
1573: }
1574:
1575: mResultSet.updateString(columnIndex, x);
1576: }
1577:
1578: public final void updateString(String columnName, String x)
1579: throws SQLException {
1580: if (mFirstRowSkew) {
1581: throw new RowIndexOutOfBoundsException();
1582: }
1583:
1584: mResultSet.updateString(columnName, x);
1585: }
1586:
1587: public final void updateBoolean(int columnIndex, boolean x)
1588: throws SQLException {
1589: if (mFirstRowSkew) {
1590: throw new RowIndexOutOfBoundsException();
1591: }
1592:
1593: mResultSet.updateBoolean(columnIndex, x);
1594: }
1595:
1596: public final void updateBoolean(String columnName, boolean x)
1597: throws SQLException {
1598: if (mFirstRowSkew) {
1599: throw new RowIndexOutOfBoundsException();
1600: }
1601:
1602: mResultSet.updateBoolean(columnName, x);
1603: }
1604:
1605: public final void updateByte(int columnIndex, byte x)
1606: throws SQLException {
1607: if (mFirstRowSkew) {
1608: throw new RowIndexOutOfBoundsException();
1609: }
1610:
1611: mResultSet.updateByte(columnIndex, x);
1612: }
1613:
1614: public final void updateByte(String columnName, byte x)
1615: throws SQLException {
1616: if (mFirstRowSkew) {
1617: throw new RowIndexOutOfBoundsException();
1618: }
1619:
1620: mResultSet.updateByte(columnName, x);
1621: }
1622:
1623: public final void updateShort(int columnIndex, short x)
1624: throws SQLException {
1625: if (mFirstRowSkew) {
1626: throw new RowIndexOutOfBoundsException();
1627: }
1628:
1629: mResultSet.updateShort(columnIndex, x);
1630: }
1631:
1632: public final void updateShort(String columnName, short x)
1633: throws SQLException {
1634: if (mFirstRowSkew) {
1635: throw new RowIndexOutOfBoundsException();
1636: }
1637:
1638: mResultSet.updateShort(columnName, x);
1639: }
1640:
1641: public final void updateInt(int columnIndex, int x)
1642: throws SQLException {
1643: if (mFirstRowSkew) {
1644: throw new RowIndexOutOfBoundsException();
1645: }
1646:
1647: mResultSet.updateInt(columnIndex, x);
1648: }
1649:
1650: public final void updateInt(String columnName, int x)
1651: throws SQLException {
1652: if (mFirstRowSkew) {
1653: throw new RowIndexOutOfBoundsException();
1654: }
1655:
1656: mResultSet.updateInt(columnName, x);
1657: }
1658:
1659: public final void updateLong(int columnIndex, long x)
1660: throws SQLException {
1661: if (mFirstRowSkew) {
1662: throw new RowIndexOutOfBoundsException();
1663: }
1664:
1665: mResultSet.updateLong(columnIndex, x);
1666: }
1667:
1668: public final void updateLong(String columnName, long x)
1669: throws SQLException {
1670: if (mFirstRowSkew) {
1671: throw new RowIndexOutOfBoundsException();
1672: }
1673:
1674: mResultSet.updateLong(columnName, x);
1675: }
1676:
1677: public final void updateFloat(int columnIndex, float x)
1678: throws SQLException {
1679: if (mFirstRowSkew) {
1680: throw new RowIndexOutOfBoundsException();
1681: }
1682:
1683: mResultSet.updateFloat(columnIndex, x);
1684: }
1685:
1686: public final void updateFloat(String columnName, float x)
1687: throws SQLException {
1688: if (mFirstRowSkew) {
1689: throw new RowIndexOutOfBoundsException();
1690: }
1691:
1692: mResultSet.updateFloat(columnName, x);
1693: }
1694:
1695: public final void updateDouble(int columnIndex, double x)
1696: throws SQLException {
1697: if (mFirstRowSkew) {
1698: throw new RowIndexOutOfBoundsException();
1699: }
1700:
1701: mResultSet.updateDouble(columnIndex, x);
1702: }
1703:
1704: public final void updateDouble(String columnName, double x)
1705: throws SQLException {
1706: if (mFirstRowSkew) {
1707: throw new RowIndexOutOfBoundsException();
1708: }
1709:
1710: mResultSet.updateDouble(columnName, x);
1711: }
1712:
1713: public final void updateBigDecimal(int columnIndex, BigDecimal x)
1714: throws SQLException {
1715: if (mFirstRowSkew) {
1716: throw new RowIndexOutOfBoundsException();
1717: }
1718:
1719: mResultSet.updateBigDecimal(columnIndex, x);
1720: }
1721:
1722: public final void updateBigDecimal(String columnName, BigDecimal x)
1723: throws SQLException {
1724: if (mFirstRowSkew) {
1725: throw new RowIndexOutOfBoundsException();
1726: }
1727:
1728: mResultSet.updateBigDecimal(columnName, x);
1729: }
1730:
1731: public final void updateBytes(int columnIndex, byte[] x)
1732: throws SQLException {
1733: if (mFirstRowSkew) {
1734: throw new RowIndexOutOfBoundsException();
1735: }
1736:
1737: mResultSet.updateBytes(columnIndex, x);
1738: }
1739:
1740: public final void updateBytes(String columnName, byte[] x)
1741: throws SQLException {
1742: if (mFirstRowSkew) {
1743: throw new RowIndexOutOfBoundsException();
1744: }
1745:
1746: mResultSet.updateBytes(columnName, x);
1747: }
1748:
1749: public final void updateDate(int columnIndex, Date x)
1750: throws SQLException {
1751: if (mFirstRowSkew) {
1752: throw new RowIndexOutOfBoundsException();
1753: }
1754:
1755: mResultSet.updateDate(columnIndex, x);
1756: }
1757:
1758: public final void updateDate(String columnName, Date x)
1759: throws SQLException {
1760: if (mFirstRowSkew) {
1761: throw new RowIndexOutOfBoundsException();
1762: }
1763:
1764: mResultSet.updateDate(columnName, x);
1765: }
1766:
1767: public final void updateTime(int columnIndex, Time x)
1768: throws SQLException {
1769: if (mFirstRowSkew) {
1770: throw new RowIndexOutOfBoundsException();
1771: }
1772:
1773: mResultSet.updateTime(columnIndex, x);
1774: }
1775:
1776: public final void updateTime(String columnName, Time x)
1777: throws SQLException {
1778: if (mFirstRowSkew) {
1779: throw new RowIndexOutOfBoundsException();
1780: }
1781:
1782: mResultSet.updateTime(columnName, x);
1783: }
1784:
1785: public final void updateTimestamp(int columnIndex, Timestamp x)
1786: throws SQLException {
1787: if (mFirstRowSkew) {
1788: throw new RowIndexOutOfBoundsException();
1789: }
1790:
1791: mResultSet.updateTimestamp(columnIndex, x);
1792: }
1793:
1794: public final void updateTimestamp(String columnName, Timestamp x)
1795: throws SQLException {
1796: if (mFirstRowSkew) {
1797: throw new RowIndexOutOfBoundsException();
1798: }
1799:
1800: mResultSet.updateTimestamp(columnName, x);
1801: }
1802:
1803: public final void updateAsciiStream(int columnIndex, InputStream x,
1804: int length) throws SQLException {
1805: if (mFirstRowSkew) {
1806: throw new RowIndexOutOfBoundsException();
1807: }
1808:
1809: mResultSet.updateAsciiStream(columnIndex, x, length);
1810: }
1811:
1812: public final void updateAsciiStream(String columnName,
1813: InputStream x, int length) throws SQLException {
1814: if (mFirstRowSkew) {
1815: throw new RowIndexOutOfBoundsException();
1816: }
1817:
1818: mResultSet.updateAsciiStream(columnName, x, length);
1819: }
1820:
1821: public final void updateCharacterStream(int columnIndex, Reader x,
1822: int length) throws SQLException {
1823: if (mFirstRowSkew) {
1824: throw new RowIndexOutOfBoundsException();
1825: }
1826:
1827: mResultSet.updateCharacterStream(columnIndex, x, length);
1828: }
1829:
1830: public final void updateCharacterStream(String columnName,
1831: Reader reader, int length) throws SQLException {
1832: if (mFirstRowSkew) {
1833: throw new RowIndexOutOfBoundsException();
1834: }
1835:
1836: mResultSet.updateCharacterStream(columnName, reader, length);
1837: }
1838:
1839: public final void updateBinaryStream(int columnIndex,
1840: InputStream x, int length) throws SQLException {
1841: if (mFirstRowSkew) {
1842: throw new RowIndexOutOfBoundsException();
1843: }
1844:
1845: mResultSet.updateBinaryStream(columnIndex, x, length);
1846: }
1847:
1848: public final void updateBinaryStream(String columnName,
1849: InputStream x, int length) throws SQLException {
1850: if (mFirstRowSkew) {
1851: throw new RowIndexOutOfBoundsException();
1852: }
1853:
1854: mResultSet.updateBinaryStream(columnName, x, length);
1855: }
1856:
1857: public final void updateRef(int columnIndex, Ref x)
1858: throws SQLException {
1859: if (mFirstRowSkew) {
1860: throw new RowIndexOutOfBoundsException();
1861: }
1862:
1863: mResultSet.updateRef(columnIndex, x);
1864: }
1865:
1866: public final void updateRef(String columnName, Ref x)
1867: throws SQLException {
1868: if (mFirstRowSkew) {
1869: throw new RowIndexOutOfBoundsException();
1870: }
1871:
1872: mResultSet.updateRef(columnName, x);
1873: }
1874:
1875: public final void updateObject(int columnIndex, Object x)
1876: throws SQLException {
1877: if (mFirstRowSkew) {
1878: throw new RowIndexOutOfBoundsException();
1879: }
1880:
1881: mResultSet.updateObject(columnIndex, x);
1882: }
1883:
1884: public final void updateObject(String columnName, Object x)
1885: throws SQLException {
1886: if (mFirstRowSkew) {
1887: throw new RowIndexOutOfBoundsException();
1888: }
1889:
1890: mResultSet.updateObject(columnName, x);
1891: }
1892:
1893: public final void updateObject(int columnIndex, Object x, int scale)
1894: throws SQLException {
1895: if (mFirstRowSkew) {
1896: throw new RowIndexOutOfBoundsException();
1897: }
1898:
1899: mResultSet.updateObject(columnIndex, x, scale);
1900: }
1901:
1902: public final void updateObject(String columnName, Object x,
1903: int scale) throws SQLException {
1904: if (mFirstRowSkew) {
1905: throw new RowIndexOutOfBoundsException();
1906: }
1907:
1908: mResultSet.updateObject(columnName, x, scale);
1909: }
1910:
1911: public final void updateBlob(int columnIndex, Blob x)
1912: throws SQLException {
1913: if (mFirstRowSkew) {
1914: throw new RowIndexOutOfBoundsException();
1915: }
1916:
1917: mResultSet.updateBlob(columnIndex, x);
1918: }
1919:
1920: public final void updateBlob(String columnName, Blob x)
1921: throws SQLException {
1922: if (mFirstRowSkew) {
1923: throw new RowIndexOutOfBoundsException();
1924: }
1925:
1926: mResultSet.updateBlob(columnName, x);
1927: }
1928:
1929: public final void updateClob(int columnIndex, Clob x)
1930: throws SQLException {
1931: if (mFirstRowSkew) {
1932: throw new RowIndexOutOfBoundsException();
1933: }
1934:
1935: mResultSet.updateClob(columnIndex, x);
1936: }
1937:
1938: public final void updateClob(String columnName, Clob x)
1939: throws SQLException {
1940: if (mFirstRowSkew) {
1941: throw new RowIndexOutOfBoundsException();
1942: }
1943:
1944: mResultSet.updateClob(columnName, x);
1945: }
1946:
1947: public final void updateArray(int columnIndex, Array x)
1948: throws SQLException {
1949: if (mFirstRowSkew) {
1950: throw new RowIndexOutOfBoundsException();
1951: }
1952:
1953: mResultSet.updateArray(columnIndex, x);
1954: }
1955:
1956: public final void updateArray(String columnName, Array x)
1957: throws SQLException {
1958: if (mFirstRowSkew) {
1959: throw new RowIndexOutOfBoundsException();
1960: }
1961:
1962: mResultSet.updateArray(columnName, x);
1963: }
1964:
1965: /**
1966: * Simply clones the instance with the default clone method. This creates a
1967: * shallow copy of all fields and the clone will in fact just be another
1968: * reference to the same underlying data. The independence of each cloned
1969: * instance is consciously not respected since they rely on resources
1970: * that can't be cloned.
1971: *
1972: * @since 1.0
1973: */
1974: public Object clone() {
1975: try {
1976: return super .clone();
1977: } catch (CloneNotSupportedException e) {
1978: // this should never happen
1979: Logger.getLogger("com.uwyn.rife.database").severe(
1980: ExceptionUtils.getExceptionStackTrace(e));
1981: return null;
1982: }
1983: }
1984: }
|