All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.firebirdsql.jdbc.AbstractResultSet Maven / Gradle / Ivy

There is a newer version: 4.0.10.java8
Show newest version
/*
 * Firebird Open Source JavaEE Connector - JDBC Driver
 *
 * Distributable under LGPL license.
 * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * LGPL License for more details.
 *
 * This file was created by members of the firebird development team.
 * All individual contributions remain the Copyright (C) of those
 * individuals.  Contributors to this file are either listed here or
 * can be obtained from a source control history command.
 *
 * All rights reserved.
 */
package org.firebirdsql.jdbc;

import java.io.*;
import java.math.*;
import java.net.*;
import java.sql.*;
import java.sql.Date;
import java.util.*;

import org.firebirdsql.gds.JaybirdErrorCodes;
import org.firebirdsql.gds.impl.GDSHelper;
import org.firebirdsql.gds.ng.FbExceptionBuilder;
import org.firebirdsql.gds.ng.FbStatement;
import org.firebirdsql.gds.ng.fields.RowDescriptor;
import org.firebirdsql.gds.ng.fields.RowValue;
import org.firebirdsql.jdbc.field.*;
import org.firebirdsql.util.SQLExceptionChainBuilder;

/**
 * Implementation of {@link ResultSet} interface.
 *
 * @author David Jencks
 * @author Roman Rokytskyy
 * @author Mark Rotteveel
 */
public abstract class AbstractResultSet implements ResultSet, FirebirdResultSet, Synchronizable, FBObjectListener.FetcherListener {

    private static final String UNICODE_STREAM_NOT_SUPPORTED = "Unicode stream not supported.";

    private final FBStatement fbStatement;
    private FBFetcher fbFetcher;
    private FirebirdRowUpdater rowUpdater;

    protected final FBConnection connection;
    protected final GDSHelper gdsHelper;

    protected final RowDescriptor rowDescriptor;

    protected RowValue row;

    private boolean wasNull = false;
    private boolean wasNullValid = false;
    // closed is false until the close method is invoked;
    private volatile boolean closed = false;

    //might be a bit of a kludge, or a useful feature.
    // TODO Consider subclassing for metadata resultsets (instead of using metaDataQuery parameter and/or parameter taking xsqlvars and rows)
    private final boolean trimStrings;

    private SQLWarning firstWarning;

    private final FBField[] fields;
    private final Map colNames;

    private final String cursorName;
    private final FBObjectListener.ResultSetListener listener;

    private final int rsType;
    private final int rsConcurrency;
    private final int rsHoldability;
    private int fetchDirection = ResultSet.FETCH_FORWARD;

    @Override
    public void allRowsFetched(FBFetcher fetcher) throws SQLException {
        listener.allRowsFetched(this);
    }

    @Override
    public void fetcherClosed(FBFetcher fetcher) throws SQLException {
        // ignore, there nothing to do here
    }

    @Override
    public void rowChanged(FBFetcher fetcher, RowValue newRow) throws SQLException {
        this.row = newRow;
    }

    /**
     * Creates a new FBResultSet instance.
     */
    public AbstractResultSet(FBConnection connection,
            FBStatement fbStatement,
            FbStatement stmt,
            FBObjectListener.ResultSetListener listener,
            boolean metaDataQuery,
            int rsType,
            int rsConcurrency,
            int rsHoldability,
            boolean cached)
            throws SQLException {
        try {
            this.connection = connection;
            this.gdsHelper = connection != null ? connection.getGDSHelper() : null;
            cursorName = fbStatement.getCursorName();
            this.listener = listener != null ? listener : FBObjectListener.NoActionResultSetListener.instance();
            trimStrings = metaDataQuery;
            rowDescriptor = stmt.getFieldDescriptor();
            fields = new FBField[rowDescriptor.getCount()];
            colNames = new HashMap<>(rowDescriptor.getCount(), 1);
            this.fbStatement = fbStatement;

            if (rsType == ResultSet.TYPE_SCROLL_SENSITIVE) {
                fbStatement.addWarning(FbExceptionBuilder
                        .forWarning(JaybirdErrorCodes.jb_resultSetTypeDowngradeReasonScrollSensitive)
                        .toFlatSQLException(SQLWarning.class));
                rsType = ResultSet.TYPE_SCROLL_INSENSITIVE;
            }

            cached = cached
                    || rsType != ResultSet.TYPE_FORWARD_ONLY
                    || metaDataQuery;
            prepareVars(cached);
            if (cached) {
                fbFetcher = new FBCachedFetcher(gdsHelper, fbStatement.fetchSize, fbStatement.maxRows, stmt, this,
                        rsType == ResultSet.TYPE_FORWARD_ONLY);
            } else if (fbStatement.isUpdatableCursor()) {
                fbFetcher = new FBUpdatableCursorFetcher(gdsHelper, fbStatement, stmt, this, fbStatement.getMaxRows(),
                        fbStatement.getFetchSize());
            } else {
                assert rsType == ResultSet.TYPE_FORWARD_ONLY : "Expected TYPE_FORWARD_ONLY";
                fbFetcher = new FBStatementFetcher(gdsHelper, fbStatement, stmt, this, fbStatement.getMaxRows(),
                        fbStatement.getFetchSize());
            }

            if (rsConcurrency == ResultSet.CONCUR_UPDATABLE) {
                try {
                    rowUpdater = new FBRowUpdater(connection, rowDescriptor, this, cached, listener);
                } catch (FBResultSetNotUpdatableException ex) {
                    fbStatement.addWarning(FbExceptionBuilder
                            .forWarning(JaybirdErrorCodes.jb_concurrencyResetReadOnlyReasonNotUpdatable)
                            .toFlatSQLException(SQLWarning.class));
                    rsConcurrency = ResultSet.CONCUR_READ_ONLY;
                }
            }
            this.rsType = rsType;
            this.rsConcurrency = rsConcurrency;
            this.rsHoldability = rsHoldability;
            this.fetchDirection = fbStatement.getFetchDirection();
        } catch (SQLException e) {
            try {
                // Ensure cursor is closed to avoid problems with statement reuse
                stmt.closeCursor();
            } catch (SQLException e2) {
                e.addSuppressed(e2);
            }
            throw e;
        }
    }

    /**
     * Creates a FBResultSet with the columns specified by rowDescriptor and the data in rows.
     * 

* This constructor is intended for metadata result sets, but can be used for other purposes as well. *

*

* Current implementation will ensure that strings will be trimmed on retrieval. *

* * @param rowDescriptor Column definition * @param rows Row data * @throws SQLException */ public AbstractResultSet(RowDescriptor rowDescriptor, List rows, FBObjectListener.ResultSetListener listener) throws SQLException { // TODO Evaluate if we need to share more implementation with constructor above connection = null; gdsHelper = null; fbStatement = null; this.listener = listener != null ? listener : FBObjectListener.NoActionResultSetListener.instance(); cursorName = null; fbFetcher = new FBCachedFetcher(rows, this, rowDescriptor, null, false); trimStrings = false; this.rowDescriptor = rowDescriptor; fields = new FBField[rowDescriptor.getCount()]; colNames = new HashMap<>(rowDescriptor.getCount(), 1); prepareVars(true); // TODO Set specific types (see also previous todo) rsType = ResultSet.TYPE_FORWARD_ONLY; rsConcurrency = ResultSet.CONCUR_READ_ONLY; rsHoldability = ResultSet.CLOSE_CURSORS_AT_COMMIT; } /** * Creates a FBResultSet with the columns specified by rowDescriptor and the data in rows. *

* This constructor is intended for metadata result sets, but can be used for other purposes as well. *

*

* Current implementation will ensure that strings will be trimmed on retrieval. *

* * @param rowDescriptor Column definition * @param rows Row data * @throws SQLException */ public AbstractResultSet(RowDescriptor rowDescriptor, List rows) throws SQLException { this(rowDescriptor, null, rows, false); } /** * Creates a FBResultSet with the columns specified by rowDescriptor and the data in rows. *

* This constructor is intended for metadata result sets, but can be used for other purposes as well. *

*

* Current implementation will ensure that strings will be trimmed on retrieval. *

* * @param rowDescriptor Column definition * @param connection Connection (cannot be null when {@code retrieveBlobs} is {@code true} * @param rows Row data * @param retrieveBlobs {@code true} retrieves the blob data * @throws SQLException */ public AbstractResultSet(RowDescriptor rowDescriptor, FBConnection connection, List rows, boolean retrieveBlobs) throws SQLException { this.connection = connection; this.gdsHelper = connection != null ? connection.getGDSHelper() : null; fbStatement = null; listener = FBObjectListener.NoActionResultSetListener.instance(); cursorName = null; fbFetcher = new FBCachedFetcher(rows, this, rowDescriptor, gdsHelper, retrieveBlobs); trimStrings = true; this.rowDescriptor = rowDescriptor; fields = new FBField[rowDescriptor.getCount()]; colNames = new HashMap<>(rowDescriptor.getCount(), 1); prepareVars(true); rsType = ResultSet.TYPE_FORWARD_ONLY; rsConcurrency = ResultSet.CONCUR_READ_ONLY; rsHoldability = ResultSet.CLOSE_CURSORS_AT_COMMIT; } private void prepareVars(boolean cached) throws SQLException { for (int i = 0; i < rowDescriptor.getCount(); i++) { final int fieldPosition = i; // anonymous implementation of the FieldDataProvider interface FieldDataProvider dataProvider = new FieldDataProvider() { public byte[] getFieldData() { return row.getFieldValue(fieldPosition).getFieldData(); } public void setFieldData(byte[] data) { row.getFieldValue(fieldPosition).setFieldData(data); } }; fields[i] = FBField.createField(rowDescriptor.getFieldDescriptor(i), dataProvider, gdsHelper, cached); } } /** * Notify the row updater about the new row that was fetched. This method * must be called after each change in cursor position. */ private void notifyRowUpdater() throws SQLException { if (rowUpdater != null) { rowUpdater.setRow(row); } } /** * Check if statement is open and prepare statement for cursor move. * * @throws SQLException if statement is closed. */ protected void checkCursorMove() throws SQLException { checkOpen(); closeFields(); } /** * Check if ResultSet is open. * * @throws SQLException * if ResultSet is closed. */ protected void checkOpen() throws SQLException { if (isClosed()) { throw new SQLException("The result set is closed", SQLStateConstants.SQL_STATE_NO_RESULT_SET); } } /** * Checks if the result set is scrollable * * @throws SQLException * if ResultSet is not scrollable */ protected void checkScrollable() throws SQLException { if (rsType == ResultSet.TYPE_FORWARD_ONLY) { throw new FbExceptionBuilder().nonTransientException(JaybirdErrorCodes.jb_operationNotAllowedOnForwardOnly) .toFlatSQLException(); } } /** * Close the fields if they were open (applies mainly to the stream fields). * * @throws SQLException if something wrong happened. */ protected void closeFields() throws SQLException { // TODO See if we can apply completion reason logic (eg no need to close blob on commit) wasNullValid = false; SQLExceptionChainBuilder chain = new SQLExceptionChainBuilder<>(); // close current fields, so that resources are freed. for (FBField field : fields) { try { field.close(); } catch (SQLException ex) { chain.append(ex); } } if (chain.hasException()) { throw chain.getException(); } } @Override public final Object getSynchronizationObject() { return fbStatement.getSynchronizationObject(); } /** * Moves the cursor down one row from its current position. * A ResultSet cursor is initially positioned * before the first row; the first call to the method * next makes the first row the current row; the * second call makes the second row the current row, and so on. * *

If an input stream is open for the current row, a call * to the method next will * implicitly close it. A ResultSet object's * warning chain is cleared when a new row is read. * * @return true if the new current row is valid; * false if there are no more rows * @exception SQLException if a database access error occurs */ public boolean next() throws SQLException { checkCursorMove(); boolean result = fbFetcher.next(); if (result) notifyRowUpdater(); return result; } /** * Releases this ResultSet object's database and * JDBC resources immediately instead of waiting for * this to happen when it is automatically closed. * *

Note: A ResultSet object * is automatically closed by the * Statement object that generated it when * that Statement object is closed, * re-executed, or is used to retrieve the next result from a * sequence of multiple results. A ResultSet object * is also automatically closed when it is garbage collected. * * @exception SQLException if a database access error occurs */ public void close() throws SQLException { close(true); } public boolean isClosed() throws SQLException { return closed; } void close(boolean notifyListener) throws SQLException { close(notifyListener, CompletionReason.OTHER); } void close(boolean notifyListener, CompletionReason completionReason) throws SQLException { if (isClosed()) return; closed = true; SQLExceptionChainBuilder chain = new SQLExceptionChainBuilder<>(); try { closeFields(); } catch (SQLException ex) { chain.append(ex); } finally { try { if (fbFetcher != null) { try { fbFetcher.close(completionReason); } catch (SQLException ex) { chain.append(ex); } } if (rowUpdater != null) { try { rowUpdater.close(); } catch (SQLException ex) { chain.append(ex); } } if (notifyListener) { try { listener.resultSetClosed(this); } catch (SQLException ex) { chain.append(ex); } } } finally { fbFetcher = null; rowUpdater = null; } } if (chain.hasException()) { throw chain.getException(); } } /** * Reports whether * the last column read had a value of SQL NULL. * Note that you must first call one of the getXXX methods * on a column to try to read its value and then call * the method wasNull to see if the value read was * SQL NULL. * * @return true if the last column value read was SQL * NULL and false otherwise * @exception SQLException if a database access error occurs */ public boolean wasNull() throws SQLException { if (!wasNullValid) { throw new SQLException("Look at a column before testing null."); } if (row == null) { throw new SQLException("No row available for wasNull."); } return wasNull; } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a stream of ASCII characters. The value can then be * read in chunks from the stream. This method is particularly suitable * for retrieving large LONGVARCHAR values. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return a stream of ascii characters * @throws SQLException if this parameter cannot be retrieved as an ASCII * stream */ @Override public final InputStream getAsciiStream(int columnIndex) throws SQLException { return getBinaryStream(columnIndex); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a BigDecimal object. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The value of the field as a BigDecimal * @throws SQLException if this paramater cannot be retrieved as * a BigDecimal */ public BigDecimal getBigDecimal(int columnIndex) throws SQLException { return getField(columnIndex).getBigDecimal(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a binary InputStream. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The value of the field as a binary input stream * @throws SQLException if this paramater cannot be retrieved as * a binary InputStream */ public InputStream getBinaryStream(int columnIndex) throws SQLException { return getField(columnIndex).getBinaryStream(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a Blob object. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The value of the field as a Blob object * @throws SQLException if this paramater cannot be retrieved as * a Blob */ public Blob getBlob(int columnIndex) throws SQLException { return getField(columnIndex).getBlob(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a boolean value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The boolean value of the field * @throws SQLException if this paramater cannot be retrieved as * a boolean */ public boolean getBoolean(int columnIndex) throws SQLException { return getField(columnIndex).getBoolean(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a byte value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The byte value of the field * @throws SQLException if this paramater cannot be retrieved as * a byte */ public byte getByte(int columnIndex) throws SQLException { return getField(columnIndex).getByte(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a byte array. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The byte array value of the field * @throws SQLException if this paramater cannot be retrieved as * a byte array */ public byte[] getBytes(int columnIndex) throws SQLException { return getField(columnIndex).getBytes(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a Date object. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The Date object of the field * @throws SQLException if this paramater cannot be retrieved as * a Date object */ public Date getDate(int columnIndex) throws SQLException { return getField(columnIndex).getDate(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a double value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The double value of the field * @throws SQLException if this paramater cannot be retrieved as * a double */ public double getDouble(int columnIndex) throws SQLException { return getField(columnIndex).getDouble(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a float value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The float value of the field * @throws SQLException if this paramater cannot be retrieved as * a float */ public float getFloat(int columnIndex) throws SQLException { return getField(columnIndex).getFloat(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as an int value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The int value of the field * @throws SQLException if this paramater cannot be retrieved as * an int */ public int getInt(int columnIndex) throws SQLException { return getField(columnIndex).getInt(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a long value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The long value of the field * @throws SQLException if this paramater cannot be retrieved as * a long */ public long getLong(int columnIndex) throws SQLException { return getField(columnIndex).getLong(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as an Object. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The Object representation of the field * @throws SQLException if this paramater cannot be retrieved as * an Object */ public Object getObject(int columnIndex) throws SQLException { return getField(columnIndex).getObject(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a short value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The short value of the field * @throws SQLException if this paramater cannot be retrieved as * a short */ public short getShort(int columnIndex) throws SQLException { return getField(columnIndex).getShort(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a String object. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The String representation of the field * @throws SQLException if this paramater cannot be retrieved as * a String */ public String getString(int columnIndex) throws SQLException { if (trimStrings) { String result = getField(columnIndex).getString(); return result != null ? result.trim() : null; } else return getField(columnIndex).getString(); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #getString(int)}. *

*/ @Override public String getNString(int columnIndex) throws SQLException { return getString(columnIndex); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a Time object. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The Time representation of the field * @throws SQLException if this paramater cannot be retrieved as * a Time object */ public Time getTime(int columnIndex) throws SQLException { return getField(columnIndex).getTime(); } /** * Retrieve the value of the designated column in the current row of * this ResultSet as a Timestamp object. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return The Timestamp representation of the field * @throws SQLException if this paramater cannot be retrieved as * a Timestamp object */ public Timestamp getTimestamp(int columnIndex) throws SQLException { return getField(columnIndex).getTimestamp(); } /** * Method is no longer supported since Jaybird 3.0. *

* For old behavior use {@link #getBinaryStream(int)}. For JDBC suggested behavior, * use {@link #getCharacterStream(int)}. *

* * @throws SQLFeatureNotSupportedException Always * @deprecated */ @Deprecated public InputStream getUnicodeStream(int columnIndex) throws SQLException { throw new SQLFeatureNotSupportedException(UNICODE_STREAM_NOT_SUPPORTED); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #getCharacterStream(int)}. *

*/ @Override public Reader getNCharacterStream(int columnIndex) throws SQLException { return getCharacterStream(columnIndex); } /** * Get the FBField object at the given column index * * @param columnIndex The index of the parameter, 1 is the first index * @throws SQLException If there is an error accessing the field */ public FBField getField(int columnIndex) throws SQLException { final FBField field = getField(columnIndex, true); wasNullValid = true; wasNull = row == null || row.getFieldValue(columnIndex - 1).getFieldData() == null; return field; } /** * Factory method for the field access objects */ public FBField getField(int columnIndex, boolean checkRowPosition) throws SQLException { checkOpen(); if (checkRowPosition && row == null && rowUpdater == null) { throw new SQLException("The result set is not in a row, use next", SQLStateConstants.SQL_STATE_NO_ROW_AVAIL); } if (columnIndex > rowDescriptor.getCount()) { throw new SQLException("Invalid column index: " + columnIndex, SQLStateConstants.SQL_STATE_INVALID_COLUMN); } if (rowUpdater != null) { return rowUpdater.getField(columnIndex - 1); } else { return fields[columnIndex - 1]; } } /** * Get a FBField by name. * * @param columnName The name of the field to be retrieved * @throws SQLException if the field cannot be retrieved */ public FBField getField(String columnName) throws SQLException { checkOpen(); if (row == null && rowUpdater == null) { throw new SQLException("The result set is not in a row, use next", SQLStateConstants.SQL_STATE_NO_ROW_AVAIL); } if (columnName == null) { throw new SQLException("Column identifier must be not null.", SQLStateConstants.SQL_STATE_INVALID_COLUMN); } Integer fieldNum = colNames.get(columnName); // If it is the first time the columnName is used if (fieldNum == null) { fieldNum = findColumn(columnName); colNames.put(columnName, fieldNum); } final FBField field = rowUpdater != null ? rowUpdater.getField(fieldNum - 1) : fields[fieldNum - 1]; wasNullValid = true; wasNull = row == null || row.getFieldValue(fieldNum - 1).getFieldData() == null; return field; } /** * Gets the value of the designated column in the current row * of this ResultSet object as * a java.math.BigDecimal in the Java programming language. * * @param columnIndex the first column is 1, the second is 2, ... * @param scale the number of digits to the right of the decimal point * @return the column value; if the value is SQL NULL, the * value returned is null * @exception SQLException if a database access error occurs * @deprecated */ @Deprecated public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { return getField(columnIndex).getBigDecimal(scale); } //====================================================================== // Methods for accessing results by column name //====================================================================== /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a String. * * @param columnName The SQL name of the column * @throws SQLException if the given column cannot be retrieved */ public String getString(String columnName) throws SQLException { if (trimStrings) { String result = getField(columnName).getString(); return result != null ? result.trim() : null; } else return getField(columnName).getString(); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #getString(String)}. *

*/ @Override public String getNString(String columnLabel) throws SQLException { return getString(columnLabel); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a boolean value. * * @param columnName The SQL name of the column * @return The String value * @throws SQLException if the given column cannot be retrieved */ public boolean getBoolean(String columnName) throws SQLException { return getField(columnName).getBoolean(); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a byte value. * * @param columnName The SQL name of the column * @return The byte value * @throws SQLException if the given column cannot be retrieved */ public byte getByte(String columnName) throws SQLException { return getField(columnName).getByte(); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a short value. * * @param columnName The SQL name of the column * @return THe short value * @throws SQLException if the given column cannot be retrieved */ public short getShort(String columnName) throws SQLException { return getField(columnName).getShort(); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as an int value. * * @param columnName The SQL name of the column * @return The int value * @throws SQLException if the given column cannot be retrieved */ public int getInt(String columnName) throws SQLException { return getField(columnName).getInt(); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a long value. * * @param columnName The SQL name of the column * @return The long value * @throws SQLException if the given column cannot be retrieved */ public long getLong(String columnName) throws SQLException { return getField(columnName).getLong(); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a float value. * * @param columnName The SQL name of the column * @return The float value * @throws SQLException if the given column cannot be retrieved */ public float getFloat(String columnName) throws SQLException { return getField(columnName).getFloat(); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a double value. * * @param columnName The SQL name of the column * @return The double value * @throws SQLException if the given column cannot be retrieved */ public double getDouble(String columnName) throws SQLException { return getField(columnName).getDouble(); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a BigDecimal. * * @param columnName The SQL name of the column * @return The BigDecimal value * @throws SQLException if the given column cannot be retrieved * @deprecated */ @Deprecated public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException { return getField(columnName).getBigDecimal(scale); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a byte array. * * @param columnName The SQL name of the column * @return The byte array value * @throws SQLException if the given column cannot be retrieved */ public byte[] getBytes(String columnName) throws SQLException { return getField(columnName).getBytes(); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a Date. * * @param columnName The SQL name of the column * @return The Date value * @throws SQLException if the given column cannot be retrieved */ public Date getDate(String columnName) throws SQLException { return getField(columnName).getDate(); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a Time object. * * @param columnName The SQL name of the column * @return The Time value * @throws SQLException if the given column cannot be retrieved */ public Time getTime(String columnName) throws SQLException { return getField(columnName).getTime(); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a Timestamp object. * * @param columnName The SQL name of the column * @return The Timestamp value * @throws SQLException if the given column cannot be retrieved */ public Timestamp getTimestamp(String columnName) throws SQLException { return getField(columnName).getTimestamp(); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as an InputStream. * * @param columnName The SQL name of the column * @return The value as an InputStream * @throws SQLException if the given column cannot be retrieved */ @Override public final InputStream getAsciiStream(String columnName) throws SQLException { return getBinaryStream(columnName); } /** * Method is no longer supported since Jaybird 3.0. *

* For old behavior use {@link #getBinaryStream(String)}. For JDBC suggested behavior, * use {@link #getCharacterStream(String)}. *

* * @throws SQLFeatureNotSupportedException Always * @deprecated */ @Deprecated public InputStream getUnicodeStream(String columnName) throws SQLException { throw new SQLFeatureNotSupportedException(UNICODE_STREAM_NOT_SUPPORTED); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #getCharacterStream(String)}. *

*/ @Override public Reader getNCharacterStream(String columnLabel) throws SQLException { return getCharacterStream(columnLabel); } /** * Retrieves the value of the designated column in the current row of this * ResultSet object as a binary InputStream. * * @param columnName The SQL name of the column * @return The value as a binary InputStream * @throws SQLException if the given column cannot be retrieved */ public InputStream getBinaryStream(String columnName) throws SQLException { return getField(columnName).getBinaryStream(); } //===================================================================== // Advanced features: //===================================================================== /** * Returns the first warning reported by calls on this * ResultSet object. * Subsequent warnings on this ResultSet object * will be chained to the SQLWarning object that * this method returns. * *

The warning chain is automatically cleared each time a new * row is read. * *

Note: This warning chain only covers warnings caused * by ResultSet methods. Any warning caused by * Statement methods * (such as reading OUT parameters) will be chained on the * Statement object. * * @return the first SQLWarning object reported or null * @exception SQLException if a database access error occurs */ public SQLWarning getWarnings() throws SQLException { return firstWarning; } /** * Clears all warnings reported on this ResultSet object. * After this method is called, the method getWarnings * returns null until a new warning is * reported for this ResultSet object. * * @exception SQLException if a database access error occurs */ public void clearWarnings() throws SQLException { firstWarning = null; } /** * Gets the name of the SQL cursor used by this ResultSet * object. * *

In SQL, a result table is retrieved through a cursor that is * named. The current row of a result set can be updated or deleted * using a positioned update/delete statement that references the * cursor name. To insure that the cursor has the proper isolation * level to support update, the cursor's select statement should be * of the form 'select for update'. If the 'for update' clause is * omitted, the positioned updates may fail. * *

The JDBC API supports this SQL feature by providing the name of the * SQL cursor used by a ResultSet object. * The current row of a ResultSet object * is also the current row of this SQL cursor. * *

Note: If positioned update is not supported, a * SQLException is thrown. * * @return the SQL name for this ResultSet object's cursor * @exception SQLException if a database access error occurs */ public String getCursorName() throws SQLException { return cursorName; } public ResultSetMetaData getMetaData() throws SQLException { checkOpen(); return new FBResultSetMetaData(rowDescriptor, connection); } /** *

Gets the value of the designated column in the current row * of this ResultSet object as * an Object in the Java programming language. * *

This method will return the value of the given column as a * Java object. The type of the Java object will be the default * Java object type corresponding to the column's SQL type, * following the mapping for built-in types specified in the JDBC * specification. * *

This method may also be used to read datatabase-specific * abstract data types. * * In the JDBC 2.0 API, the behavior of the method * getObject is extended to materialize * data of SQL user-defined types. When a column contains * a structured or distinct value, the behavior of this method is as * if it were a call to: getObject(columnIndex, * this.getStatement().getConnection().getTypeMap()). * * @param columnName the SQL name of the column * @return a java.lang.Object holding the column value * @exception SQLException if a database access error occurs */ public Object getObject(String columnName) throws SQLException { return getField(columnName).getObject(); } //---------------------------------------------------------------- /** * Maps the given ResultSet column name to its * ResultSet column index. * * @param columnName the name of the column * @return the column index of the given column name * @exception SQLException if a database access error occurs */ // See section 14.2.3 of jdbc-3.0 specification // "Column names supplied to getter methods are case insensitive // If a select list contains the same column more than once, // the first instance of the column will be returned public int findColumn(String columnName) throws SQLException { if (columnName == null || columnName.equals("")) { throw new SQLException("Empty string does not identify column.", SQLStateConstants.SQL_STATE_INVALID_COLUMN); } if (columnName.startsWith("\"") && columnName.endsWith("\"")) { columnName = columnName.substring(1, columnName.length() - 1); // case-sensitively check column aliases for (int i = 0; i < rowDescriptor.getCount(); i++) { if (columnName.equals(rowDescriptor.getFieldDescriptor(i).getFieldName())) { return ++i; } } // case-sensitively check column names for (int i = 0; i < rowDescriptor.getCount(); i++) { if (columnName.equals(rowDescriptor.getFieldDescriptor(i).getOriginalName())) { return ++i; } } } else { for (int i = 0; i < rowDescriptor.getCount(); i++) { if (columnName.equalsIgnoreCase(rowDescriptor.getFieldDescriptor(i).getFieldName())) { return ++i; } } for (int i = 0; i < rowDescriptor.getCount(); i++) { if (columnName.equalsIgnoreCase(rowDescriptor.getFieldDescriptor(i).getOriginalName())) { return ++i; } } } throw new SQLException("Column name " + columnName + " not found in result set.", SQLStateConstants.SQL_STATE_INVALID_COLUMN); } //--------------------------JDBC 2.0----------------------------------- //--------------------------------------------------------------------- // Getters and Setters //--------------------------------------------------------------------- /** * Gets the value of the designated column in the current row * of this ResultSet object as a * java.io.Reader object. * @return a java.io.Reader object that contains the column * value; if the value is SQL NULL, the value returned is * null in the Java programming language. * @param columnIndex the first column is 1, the second is 2, ... * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Reader getCharacterStream(int columnIndex) throws SQLException { return getField(columnIndex).getCharacterStream(); } /** * Gets the value of the designated column in the current row * of this ResultSet object as a * java.io.Reader object. * * @param columnName the name of the column * @return a java.io.Reader object that contains the column * value; if the value is SQL NULL, the value returned is * null in the Java programming language. * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Reader getCharacterStream(String columnName) throws SQLException { return getField(columnName).getCharacterStream(); } /** * Gets the value of the designated column in the current row * of this ResultSet object as a * java.math.BigDecimal with full precision. * * @param columnName the column name * @return the column value (full precision); * if the value is SQL NULL, the value returned is * null in the Java programming language. * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API * */ public BigDecimal getBigDecimal(String columnName) throws SQLException { return getField(columnName).getBigDecimal(); } //--------------------------------------------------------------------- // Traversal/Positioning //--------------------------------------------------------------------- /** * Indicates whether the cursor is before the first row in * this ResultSet object. * * @return true if the cursor is before the first row; * false if the cursor is at any other position or the * result set contains no rows * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public boolean isBeforeFirst() throws SQLException { return fbFetcher.isBeforeFirst(); } /** * Indicates whether the cursor is after the last row in * this ResultSet object. * * @return true if the cursor is after the last row; * false if the cursor is at any other position or the * result set contains no rows * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public boolean isAfterLast() throws SQLException { return fbFetcher.isAfterLast(); } /** * Indicates whether the cursor is on the first row of * this ResultSet object. * * @return true if the cursor is on the first row; * false otherwise * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public boolean isFirst() throws SQLException { return fbFetcher.isFirst(); } /** * Indicates whether the cursor is on the last row of * this ResultSet object. * Note: Calling the method isLast may be expensive * because the JDBC driver * might need to fetch ahead one row in order to determine * whether the current row is the last row in the result set. * * @return true if the cursor is on the last row; * false otherwise * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public boolean isLast() throws SQLException { return fbFetcher.isLast(); } /** * Moves the cursor to the front of * this ResultSet object, just before the * first row. This method has no effect if the result set contains no rows. * * @exception SQLException if a database access error * occurs or the result set type is TYPE_FORWARD_ONLY * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void beforeFirst() throws SQLException { checkCursorMove(); fbFetcher.beforeFirst(); notifyRowUpdater(); } /** * Moves the cursor to the end of * this ResultSet object, just after the * last row. This method has no effect if the result set contains no rows. * @exception SQLException if a database access error * occurs or the result set type is TYPE_FORWARD_ONLY * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void afterLast() throws SQLException { checkCursorMove(); fbFetcher.afterLast(); notifyRowUpdater(); } /** * Moves the cursor to the first row in * this ResultSet object. * * @return true if the cursor is on a valid row; * false if there are no rows in the result set * @exception SQLException if a database access error * occurs or the result set type is TYPE_FORWARD_ONLY * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public boolean first() throws SQLException { checkCursorMove(); boolean result = fbFetcher.first(); if (result) notifyRowUpdater(); return result; } /** * Moves the cursor to the last row in * this ResultSet object. * * @return true if the cursor is on a valid row; * false if there are no rows in the result set * @exception SQLException if a database access error * occurs or the result set type is TYPE_FORWARD_ONLY * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public boolean last() throws SQLException { checkCursorMove(); boolean result = fbFetcher.last(); if (result) notifyRowUpdater(); return result; } /** * Retrieves the current row number. The first row is number 1, the * second number 2, and so on. *

* Note:Support for the getRow method * is optional for ResultSets with a result * set type of TYPE_FORWARD_ONLY * * @return the current row number; 0 if there is no current row * @exception SQLException if a database access error occurs * or this method is called on a closed result set * @exception SQLFeatureNotSupportedException if the JDBC driver does not support * this method * @since 1.2 */ public int getRow() throws SQLException { checkOpen(); return fbFetcher.getRowNum(); } /** * Moves the cursor to the given row number in * this ResultSet object. * *

If the row number is positive, the cursor moves to * the given row number with respect to the * beginning of the result set. The first row is row 1, the second * is row 2, and so on. * *

If the given row number is negative, the cursor moves to * an absolute row position with respect to * the end of the result set. For example, calling the method * absolute(-1) positions the * cursor on the last row; calling the method absolute(-2) * moves the cursor to the next-to-last row, and so on. * *

If the row number specified is zero, the cursor is moved to * before the first row. * *

An attempt to position the cursor beyond the first/last row in * the result set leaves the cursor before the first row or after * the last row. * *

Note: Calling absolute(1) is the same * as calling first(). Calling absolute(-1) * is the same as calling last(). * * @param row the number of the row to which the cursor should move. * A value of zero indicates that the cursor will be positioned * before the first row; a positive number indicates the row number * counting from the beginning of the result set; a negative number * indicates the row number counting from the end of the result set * @return true if the cursor is moved to a position in this * ResultSet object; * false if the cursor is before the first row or after the * last row * @exception SQLException if a database access error * occurs; this method is called on a closed result set * or the result set type is TYPE_FORWARD_ONLY * @exception SQLFeatureNotSupportedException if the JDBC driver does not support * this method * @since 1.2 */ public boolean absolute(int row) throws SQLException { checkCursorMove(); boolean result = fbFetcher.absolute(row); if (result) notifyRowUpdater(); return result; } /** * Moves the cursor a relative number of rows, either positive or negative. * Attempting to move beyond the first/last row in the * result set positions the cursor before/after the * the first/last row. Calling relative(0) is valid, but does * not change the cursor position. * *

Note: Calling the method relative(1) * is different from calling the method next() * because is makes sense to call next() when there * is no current row, * for example, when the cursor is positioned before the first row * or after the last row of the result set. * * @return true if the cursor is on a row; * false otherwise * @exception SQLException if a database access error occurs, * there is no current row, or the result set type is * TYPE_FORWARD_ONLY * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public boolean relative(int rows) throws SQLException { checkCursorMove(); boolean result = fbFetcher.relative(rows); if (result) notifyRowUpdater(); return result; } /** * Moves the cursor to the previous row in this * ResultSet object. * *

Note: Calling the method previous() is not the same as * calling the method relative(-1) because it * makes sense to callprevious() when there is no current row. * * @return true if the cursor is on a valid row; * false if it is off the result set * @exception SQLException if a database access error * occurs or the result set type is TYPE_FORWARD_ONLY * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public boolean previous() throws SQLException { checkCursorMove(); boolean result = fbFetcher.previous(); if (result) notifyRowUpdater(); return result; } //--------------------------------------------------------------------- // Properties //--------------------------------------------------------------------- @Override public void setFetchDirection(int direction) throws SQLException { checkOpen(); switch (direction) { case ResultSet.FETCH_FORWARD: fetchDirection = direction; break; case ResultSet.FETCH_REVERSE: case ResultSet.FETCH_UNKNOWN: checkScrollable(); fetchDirection = direction; break; default: throw FbExceptionBuilder.forException(JaybirdErrorCodes.jb_invalidFetchDirection) .messageParameter(direction) .toFlatSQLException(); } } @Override public int getFetchDirection() throws SQLException { checkOpen(); return fetchDirection; } /** * Gives the JDBC driver a hint as to the number of rows that should * be fetched from the database when more rows are needed for this * ResultSet object. * If the fetch size specified is zero, the JDBC driver * ignores the value and is free to make its own best guess as to what * the fetch size should be. The default value is set by the * Statement object * that created the result set. The fetch size may be changed at any time. * * @param rows the number of rows to fetch * @exception SQLException if a database access error occurs; this method * is called on a closed result set or the * condition rows >= 0 is not satisfied * @since 1.2 * @see #getFetchSize */ public void setFetchSize(int rows) throws SQLException { checkOpen(); if (rows < 0) { throw new SQLException("Can't set negative fetch size.", SQLStateConstants.SQL_STATE_INVALID_ARG_VALUE); } fbFetcher.setFetchSize(rows); } /** * Retrieves the fetch size for this * ResultSet object. * * @return the current fetch size for this ResultSet object * @exception SQLException if a database access error occurs * or this method is called on a closed result set * @since 1.2 * @see #setFetchSize */ public int getFetchSize() throws SQLException { checkOpen(); return fbFetcher.getFetchSize(); } /** * Returns the type of this ResultSet object. * The type is determined by the Statement object * that created the result set. * * @return TYPE_FORWARD_ONLY, * TYPE_SCROLL_INSENSITIVE, * or TYPE_SCROLL_SENSITIVE * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public int getType() throws SQLException { return rsType; } /** * Returns the concurrency mode of this ResultSet object. * The concurrency used is determined by the * Statement object that created the result set. * * @return the concurrency type, either CONCUR_READ_ONLY * or CONCUR_UPDATABLE * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public int getConcurrency() throws SQLException { return rsConcurrency; } /** * Retrieves the holdability of this ResultSet object * * @return either ResultSet.HOLD_CURSORS_OVER_COMMIT or * ResultSet.CLOSE_CURSORS_AT_COMMIT * * @throws SQLException if a database access error occurs * or this method is called on a closed result set * * @since 1.6 */ public int getHoldability() throws SQLException { return rsHoldability; } //--------------------------------------------------------------------- // Updates //--------------------------------------------------------------------- /** * Indicates whether the current row has been updated. The value returned * depends on whether or not the result set can detect updates. * * @return true if the row has been visibly updated * by the owner or another, and updates are detected * @exception SQLException if a database access error occurs * * @see DatabaseMetaData#updatesAreDetected * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public boolean rowUpdated() throws SQLException { checkUpdatable(); return rowUpdater.rowUpdated(); } /** * Indicates whether the current row has had an insertion. * The value returned depends on whether or not this * ResultSet object can detect visible inserts. * * @return true if a row has had an insertion * and insertions are detected; false otherwise * @exception SQLException if a database access error occurs * * @see DatabaseMetaData#insertsAreDetected * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public boolean rowInserted() throws SQLException { checkUpdatable(); return rowUpdater.rowUpdated(); } /** * Indicates whether a row has been deleted. A deleted row may leave * a visible "hole" in a result set. This method can be used to * detect holes in a result set. The value returned depends on whether * or not this ResultSet object can detect deletions. * * @return true if a row was deleted and deletions are detected; * false otherwise * @exception SQLException if a database access error occurs * * @see DatabaseMetaData#deletesAreDetected * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public boolean rowDeleted() throws SQLException { checkUpdatable(); return rowUpdater.rowUpdated(); } /** * Checks if the result set is updatable, throwing {@link FBResultSetNotUpdatableException} otherwise. * * @throws FBResultSetNotUpdatableException When this result set is not updatable */ private void checkUpdatable() throws FBResultSetNotUpdatableException { if (rowUpdater == null) { throw new FBResultSetNotUpdatableException(); } } /** * Gives a nullable column a null value. * * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow * or insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateNull(int columnIndex) throws SQLException { checkUpdatable(); getField(columnIndex).setNull(); } /** * Updates the designated column with a boolean value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateBoolean(int columnIndex, boolean x) throws SQLException { checkUpdatable(); getField(columnIndex).setBoolean(x); } /** * Updates the designated column with a byte value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateByte(int columnIndex, byte x) throws SQLException { checkUpdatable(); getField(columnIndex).setByte(x); } /** * Updates the designated column with a short value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateShort(int columnIndex, short x) throws SQLException { checkUpdatable(); getField(columnIndex).setShort(x); } /** * Updates the designated column with an int value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateInt(int columnIndex, int x) throws SQLException { checkUpdatable(); getField(columnIndex).setInteger(x); } /** * Updates the designated column with a long value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateLong(int columnIndex, long x) throws SQLException { checkUpdatable(); getField(columnIndex).setLong(x); } /** * Updates the designated column with a float value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateFloat(int columnIndex, float x) throws SQLException { checkUpdatable(); getField(columnIndex).setFloat(x); } /** * Updates the designated column with a double value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateDouble(int columnIndex, double x) throws SQLException { checkUpdatable(); getField(columnIndex).setDouble(x); } /** * Updates the designated column with a java.math.BigDecimal * value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { checkUpdatable(); getField(columnIndex).setBigDecimal(x); } /** * Updates the designated column with a String value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateString(int columnIndex, String x) throws SQLException { checkUpdatable(); getField(columnIndex).setString(x); } /** * Updates the designated column with a byte array value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateBytes(int columnIndex, byte x[]) throws SQLException { checkUpdatable(); getField(columnIndex).setBytes(x); } /** * Updates the designated column with a java.sql.Date value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateDate(int columnIndex, Date x) throws SQLException { checkUpdatable(); getField(columnIndex).setDate(x); } /** * Updates the designated column with a java.sql.Time value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateTime(int columnIndex, Time x) throws SQLException { checkUpdatable(); getField(columnIndex).setTime(x); } /** * Updates the designated column with a java.sql.Timestamp * value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { checkUpdatable(); getField(columnIndex).setTimestamp(x); } @Override public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { checkUpdatable(); getField(columnIndex).setBinaryStream(x, length); } @Override public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { checkUpdatable(); getField(columnIndex).setBinaryStream(x, length); } @Override public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { checkUpdatable(); getField(columnIndex).setBinaryStream(x); } @Override public void updateBinaryStream(String columnName, InputStream x, int length) throws SQLException { checkUpdatable(); getField(columnName).setBinaryStream(x, length); } @Override public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { checkUpdatable(); getField(columnLabel).setBinaryStream(x, length); } @Override public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { checkUpdatable(); getField(columnLabel).setBinaryStream(x); } /** * Updates the designated column with an Object value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @param scale for java.sql.Types.DECIMA * or java.sql.Types.NUMERIC types, * this is the number of digits after the decimal point. For all other * types this value will be ignored. * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateObject(int columnIndex, Object x, int scale) throws SQLException { checkUpdatable(); getField(columnIndex).setObject(x); } /** * Updates the designated column with an Object value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnIndex the first column is 1, the second is 2, ... * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateObject(int columnIndex, Object x) throws SQLException { checkUpdatable(); getField(columnIndex).setObject(x); } /** * Updates the designated column with a null value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnName the name of the column * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateNull(String columnName) throws SQLException { checkUpdatable(); getField(columnName).setNull(); } /** * Updates the designated column with a boolean value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateBoolean(String columnName, boolean x) throws SQLException { checkUpdatable(); getField(columnName).setBoolean(x); } /** * Updates the designated column with a byte value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateByte(String columnName, byte x) throws SQLException { checkUpdatable(); getField(columnName).setByte(x); } /** * Updates the designated column with a short value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateShort(String columnName, short x) throws SQLException { checkUpdatable(); getField(columnName).setShort(x); } /** * Updates the designated column with an int value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateInt(String columnName, int x) throws SQLException { checkUpdatable(); getField(columnName).setInteger(x); } /** * Updates the designated column with a long value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateLong(String columnName, long x) throws SQLException { checkUpdatable(); getField(columnName).setLong(x); } /** * Updates the designated column with a float value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateFloat(String columnName, float x) throws SQLException { checkUpdatable(); getField(columnName).setFloat(x); } /** * Updates the designated column with a double value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateDouble(String columnName, double x) throws SQLException { checkUpdatable(); getField(columnName).setDouble(x); } /** * Updates the designated column with a java.sql.BigDecimal * value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException { checkUpdatable(); getField(columnName).setBigDecimal(x); } /** * Updates the designated column with a String value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateString(String columnName, String x) throws SQLException { checkUpdatable(); getField(columnName).setString(x); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #updateString(int, String)}. *

*/ @Override public void updateNString(int columnIndex, String string) throws SQLException { updateString(columnIndex, string); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #updateString(String, String)}. *

*/ @Override public void updateNString(String columnLabel, String string) throws SQLException { updateString(columnLabel, string); } /** * Updates the designated column with a boolean value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * JDBC 2.0 * * Updates a column with a byte array value. * * The updateXXX methods are used to update column values in the * current row, or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or insertRow * methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateBytes(String columnName, byte x[]) throws SQLException { checkUpdatable(); getField(columnName).setBytes(x); } /** * Updates the designated column with a java.sql.Date value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateDate(String columnName, Date x) throws SQLException { checkUpdatable(); getField(columnName).setDate(x); } /** * Updates the designated column with a java.sql.Time value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateTime(String columnName, Time x) throws SQLException { checkUpdatable(); getField(columnName).setTime(x); } /** * Updates the designated column with a java.sql.Timestamp * value. * The updateXXX methods are used to update column values in the * current row or the insert row. The updateXXX methods do not * update the underlying database; instead the updateRow or * insertRow methods are called to update the database. * * @param columnName the name of the column * @param x the new column value * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateTimestamp(String columnName, Timestamp x) throws SQLException { checkUpdatable(); getField(columnName).setTimestamp(x); } @Override public final void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { updateBinaryStream(columnIndex, x, length); } @Override public final void updateAsciiStream(String columnName, InputStream x, int length) throws SQLException { updateBinaryStream(columnName, x, length); } @Override public final void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { updateBinaryStream(columnIndex, x, length); } @Override public final void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { updateBinaryStream(columnIndex, x); } @Override public final void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException { updateBinaryStream(columnLabel, x, length); } @Override public final void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { updateBinaryStream(columnLabel, x); } @Override public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { checkUpdatable(); getField(columnIndex).setCharacterStream(x, length); } @Override public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { checkUpdatable(); getField(columnIndex).setCharacterStream(x, length); } @Override public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { checkUpdatable(); getField(columnIndex).setCharacterStream(x); } @Override public void updateCharacterStream(String columnName, Reader reader, int length) throws SQLException { checkUpdatable(); getField(columnName).setCharacterStream(reader, length); } @Override public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { checkUpdatable(); getField(columnLabel).setCharacterStream(reader, length); } @Override public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { checkUpdatable(); getField(columnLabel).setCharacterStream(reader); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #updateCharacterStream(int, Reader, long)}. *

*/ @Override public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { updateCharacterStream(columnIndex, x, length); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #updateCharacterStream(int, Reader)}. *

*/ @Override public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { updateCharacterStream(columnIndex, x); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #updateClob(String, Reader, long)}. *

*/ @Override public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException { updateCharacterStream(columnLabel, reader, length); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #updateCharacterStream(String, Reader)}. *

*/ @Override public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { updateCharacterStream(columnLabel, reader); } public void updateObject(String columnName, Object x, int scale) throws SQLException { checkUpdatable(); getField(columnName).setObject(x); } public void updateObject(String columnName, Object x) throws SQLException { checkUpdatable(); getField(columnName).setObject(x); } /** * Inserts the contents of the insert row into this * ResultSet objaect and into the database. * The cursor must be on the insert row when this method is called. * * @exception SQLException if a database access error occurs, * if this method is called when the cursor is not on the insert row, * or if not all of non-nullable columns in * the insert row have been given a value * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void insertRow() throws SQLException { checkUpdatable(); rowUpdater.insertRow(); fbFetcher.insertRow(rowUpdater.getInsertRow()); notifyRowUpdater(); } /** * Updates the underlying database with the new contents of the * current row of this ResultSet object. * This method cannot be called when the cursor is on the insert row. * * @exception SQLException if a database access error occurs or * if this method is called when the cursor is on the insert row * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void updateRow() throws SQLException { checkUpdatable(); rowUpdater.updateRow(); fbFetcher.updateRow(rowUpdater.getNewRow()); notifyRowUpdater(); } /** * Deletes the current row from this ResultSet object * and from the underlying database. This method cannot be called when * the cursor is on the insert row. * * @exception SQLException if a database access error occurs * or if this method is called when the cursor is on the insert row * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void deleteRow() throws SQLException { checkUpdatable(); rowUpdater.deleteRow(); fbFetcher.deleteRow(); notifyRowUpdater(); } /** * Refreshes the current row with its most recent value in * the database. This method cannot be called when * the cursor is on the insert row. * *

The refreshRow method provides a way for an * application to * explicitly tell the JDBC driver to refetch a row(s) from the * database. An application may want to call refreshRow when * caching or prefetching is being done by the JDBC driver to * fetch the latest value of a row from the database. The JDBC driver * may actually refresh multiple rows at once if the fetch size is * greater than one. * *

All values are refetched subject to the transaction isolation * level and cursor sensitivity. If refreshRow is called after * calling an updateXXX method, but before calling * the method updateRow, then the * updates made to the row are lost. Calling the method * refreshRow frequently will likely slow performance. * * @exception SQLException if a database access error * occurs or if this method is called when the cursor is on the insert row * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void refreshRow() throws SQLException { checkUpdatable(); rowUpdater.refreshRow(); fbFetcher.updateRow(rowUpdater.getOldRow()); // this is excessive, but we do this to keep the code uniform notifyRowUpdater(); } /** * Cancels the updates made to the current row in this * ResultSet object. * This method may be called after calling an * updateXXX method(s) and before calling * the method updateRow to roll back * the updates made to a row. If no updates have been made or * updateRow has already been called, this method has no * effect. * * @exception SQLException if a database access error * occurs or if this method is called when the cursor is on the insert row * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void cancelRowUpdates() throws SQLException { checkUpdatable(); rowUpdater.cancelRowUpdates(); } /** * Moves the cursor to the insert row. The current cursor position is * remembered while the cursor is positioned on the insert row. * * The insert row is a special row associated with an updatable * result set. It is essentially a buffer where a new row may * be constructed by calling the updateXXX methods prior to * inserting the row into the result set. * * Only the updateXXX, getXXX, * and insertRow methods may be * called when the cursor is on the insert row. All of the columns in * a result set must be given a value each time this method is * called before calling insertRow. * An updateXXX method must be called before a * getXXX method can be called on a column value. * * @exception SQLException if a database access error occurs * or the result set is not updatable * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void moveToInsertRow() throws SQLException { checkUpdatable(); rowUpdater.moveToInsertRow(); } /** * Moves the cursor to the remembered cursor position, usually the * current row. This method has no effect if the cursor is not on * the insert row. * * @exception SQLException if a database access error occurs * or the result set is not updatable * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public void moveToCurrentRow() throws SQLException { checkUpdatable(); rowUpdater.moveToCurrentRow(); } /** * Returns the Statement object that produced this * ResultSet object. * If the result set was generated some other way, such as by a * DatabaseMetaData method, this method returns * null. * * @return the Statement object that produced * this ResultSet object or null * if the result set was produced some other way */ public Statement getStatement() { return fbStatement; } /** * Returns the value of the designated column in the current row * of this ResultSet object as an Object * in the Java programming language. * This method uses the given Map object * for the custom mapping of the * SQL structured or distinct type that is being retrieved. * * @param i the first column is 1, the second is 2, ... * @param map a java.util.Map object that contains the mapping * from SQL type names to classes in the Java programming language * @return an Object in the Java programming language * representing the SQL value * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Object getObject(int i, Map> map) throws SQLException { return getField(i).getObject(map); } /** * Returns the value of the designated column in the current row * of this ResultSet object as a Ref object * in the Java programming language. * * @param i the first column is 1, the second is 2, ... * @return a Ref object representing an SQL REF value * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Ref getRef(int i) throws SQLException { return getField(i).getRef(); } /** * Returns the value of the designated column in the current row * of this ResultSet object as a Clob object * in the Java programming language. * * @param i the first column is 1, the second is 2, ... * @return a Clob object representing the SQL CLOB value in * the specified column * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Clob getClob(int i) throws SQLException { return getField(i).getClob(); } /** * Returns the value of the designated column in the current row * of this ResultSet object as an Array object * in the Java programming language. * * @param i the first column is 1, the second is 2, ... * @return an Array object representing the SQL ARRAY value in * the specified column * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Array getArray(int i) throws SQLException { return getField(i).getArray(); } /** * Returns the value of the designated column in the current row * of this ResultSet object as an Object * in the Java programming language. * This method uses the specified Map object for * custom mapping if appropriate. * * @param columnName the name of the column from which to retrieve the value * @param map a java.util.Map object that contains the mapping * from SQL type names to classes in the Java programming language * @return an Object representing the SQL value in the specified column * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Object getObject(String columnName, Map> map) throws SQLException { return getField(columnName).getObject(map); } /** * Returns the value of the designated column in the current row * of this ResultSet object as a Ref object * in the Java programming language. * * @param columnName the column name * @return a Ref object representing the SQL REF value in * the specified column * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Ref getRef(String columnName) throws SQLException { return getField(columnName).getRef(); } /** * Returns the value of the designated column in the current row * of this ResultSet object as a Blob object * in the Java programming language. * * @param columnName the name of the column from which to retrieve the value * @return a Blob object representing the SQL BLOB value in * the specified column * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Blob getBlob(String columnName) throws SQLException { return getField(columnName).getBlob(); } /** * Returns the value of the designated column in the current row * of this ResultSet object as a Clob object * in the Java programming language. * * @param columnName the name of the column from which to retrieve the value * @return a Clob object representing the SQL CLOB * value in the specified column * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Clob getClob(String columnName) throws SQLException { return getField(columnName).getClob(); } /** * Returns the value of the designated column in the current row * of this ResultSet object as an Array object * in the Java programming language. * * @param columnName the name of the column from which to retrieve the value * @return an Array object representing the SQL ARRAY value in * the specified column * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Array getArray(String columnName) throws SQLException { return getField(columnName).getArray(); } /** * Returns the value of the designated column in the current row * of this ResultSet object as a java.sql.Date object * in the Java programming language. * This method uses the given calendar to construct an appropriate millisecond * value for the date if the underlying database does not store * timezone information. * * @param columnIndex the first column is 1, the second is 2, ... * @param cal the java.util.Calendar object * to use in constructing the date * @return the column value as a java.sql.Date object; * if the value is SQL NULL, * the value returned is null in the Java programming language * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Date getDate(int columnIndex, Calendar cal) throws SQLException { return getField(columnIndex).getDate(cal); } /** * Returns the value of the designated column in the current row * of this ResultSet object as a java.sql.Date object * in the Java programming language. * This method uses the given calendar to construct an appropriate millisecond * value for the date if the underlying database does not store * timezone information. * * @param columnName the SQL name of the column from which to retrieve the value * @param cal the java.util.Calendar object * to use in constructing the date * @return the column value as a java.sql.Date object; * if the value is SQL NULL, * the value returned is null in the Java programming language * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Date getDate(String columnName, Calendar cal) throws SQLException { return getField(columnName).getDate(cal); } /** * Returns the value of the designated column in the current row * of this ResultSet object as a java.sql.Time object * in the Java programming language. * This method uses the given calendar to construct an appropriate millisecond * value for the time if the underlying database does not store * timezone information. * * @param columnIndex the first column is 1, the second is 2, ... * @param cal the java.util.Calendar object * to use in constructing the time * @return the column value as a java.sql.Time object; * if the value is SQL NULL, * the value returned is null in the Java programming language * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Time getTime(int columnIndex, Calendar cal) throws SQLException { return getField(columnIndex).getTime(cal); } /** * Returns the value of the designated column in the current row * of this ResultSet object as a java.sql.Time object * in the Java programming language. * This method uses the given calendar to construct an appropriate millisecond * value for the time if the underlying database does not store * timezone information. * * @param columnName the SQL name of the column * @param cal the java.util.Calendar object * to use in constructing the time * @return the column value as a java.sql.Time object; * if the value is SQL NULL, * the value returned is null in the Java programming language * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Time getTime(String columnName, Calendar cal) throws SQLException { return getField(columnName).getTime(cal); } /** * Returns the value of the designated column in the current row * of this ResultSet object as a java.sql.Timestamp object * in the Java programming language. * This method uses the given calendar to construct an appropriate millisecond * value for the timestamp if the underlying database does not store * timezone information. * * @param columnIndex the first column is 1, the second is 2, ... * @param cal the java.util.Calendar object * to use in constructing the timestamp * @return the column value as a java.sql.Timestamp object; * if the value is SQL NULL, * the value returned is null in the Java programming language * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { return getField(columnIndex).getTimestamp(cal); } /** * Returns the value of the designated column in the current row * of this ResultSet object as a java.sql.Timestamp object * in the Java programming language. * This method uses the given calendar to construct an appropriate millisecond * value for the timestamp if the underlying database does not store * timezone information. * * @param columnName the SQL name of the column * @param cal the java.util.Calendar object * to use in constructing the date * @return the column value as a java.sql.Timestamp object; * if the value is SQL NULL, * the value returned is null in the Java programming language * @exception SQLException if a database access error occurs * @since 1.2 * @see What Is in the JDBC * 2.0 API */ public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException { return getField(columnName).getTimestamp(cal); } public URL getURL(int param1) throws SQLException { throw new FBDriverNotCapableException("Type URL not supported"); } public URL getURL(String param1) throws SQLException { throw new FBDriverNotCapableException("Type URL not supported"); } @Override public T getObject(int columnIndex, Class type) throws SQLException { return getField(columnIndex).getObject(type); } @Override public T getObject(String columnLabel, Class type) throws SQLException { return getField(columnLabel).getObject(type); } public void updateRef(int param1, Ref param2) throws SQLException { throw new FBDriverNotCapableException("Type REF not supported"); } public void updateRef(String param1, Ref param2) throws SQLException { throw new FBDriverNotCapableException("Type REF not supported"); } @Override public void updateBlob(int columnIndex, Blob blob) throws SQLException { checkUpdatable(); getField(columnIndex).setBlob(asFBBlob(blob)); } private FBBlob asFBBlob(Blob blob) throws SQLException { // if the passed BLOB is not instance of our class, copy its content into the our BLOB if (blob == null) { return null; } if (blob instanceof FBBlob) { return (FBBlob) blob; } FBBlob fbb = new FBBlob(gdsHelper); fbb.copyStream(blob.getBinaryStream()); return fbb; } @Override public void updateBlob(String columnLabel, Blob blob) throws SQLException { checkUpdatable(); getField(columnLabel).setBlob(asFBBlob(blob)); } @Override public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { checkUpdatable(); getField(columnIndex).setBinaryStream(inputStream, length); } @Override public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { checkUpdatable(); getField(columnIndex).setBinaryStream(inputStream); } @Override public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { checkUpdatable(); getField(columnLabel).setBinaryStream(inputStream, length); } @Override public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { checkUpdatable(); getField(columnLabel).setBinaryStream(inputStream); } @Override public void updateClob(int columnIndex, java.sql.Clob clob) throws SQLException { checkUpdatable(); getField(columnIndex).setClob(asFBClob(clob)); } private FBClob asFBClob(Clob clob) throws SQLException { // if the passed BLOB is not instance of our class, copy its content into the our BLOB if (clob == null) { return null; } if (clob instanceof FBClob) { return (FBClob) clob; } FBClob fbc = new FBClob(new FBBlob(gdsHelper)); fbc.copyCharacterStream(clob.getCharacterStream()); return fbc; } @Override public void updateClob(String columnLabel, Clob clob) throws SQLException { checkUpdatable(); getField(columnLabel).setClob(asFBClob(clob)); } @Override public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { checkUpdatable(); getField(columnIndex).setCharacterStream(reader, length); } @Override public void updateClob(int columnIndex, Reader reader) throws SQLException { checkUpdatable(); getField(columnIndex).setCharacterStream(reader); } @Override public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { checkUpdatable(); getField(columnLabel).setCharacterStream(reader, length); } @Override public void updateClob(String columnLabel, Reader reader) throws SQLException { checkUpdatable(); getField(columnLabel).setCharacterStream(reader); } public void updateArray(int param1, Array param2) throws SQLException { throw new FBDriverNotCapableException("Type ARRAY not yet supported"); } public void updateArray(String param1, Array param2) throws SQLException { throw new FBDriverNotCapableException("Type ARRAY not yet supported"); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #getClob(int)}. *

*/ @Override public NClob getNClob(int columnIndex) throws SQLException { return (NClob) getClob(columnIndex); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #getClob(String)}. *

*/ @Override public NClob getNClob(String columnLabel) throws SQLException { return (NClob) getClob(columnLabel); } public RowId getRowId(int columnIndex) throws SQLException { throw new FBDriverNotCapableException("Type ROWID not yet supported"); } public RowId getRowId(String columnLabel) throws SQLException { throw new FBDriverNotCapableException("Type ROWID not yet supported"); } public SQLXML getSQLXML(int columnIndex) throws SQLException { throw new FBDriverNotCapableException("Type SQLXML not supported"); } public SQLXML getSQLXML(String columnLabel) throws SQLException { throw new FBDriverNotCapableException("Type SQLXML not supported"); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #updateClob(int, Clob)}. *

*/ @Override public void updateNClob(int columnIndex, NClob clob) throws SQLException { updateClob(columnIndex, clob); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #updateClob(int, Reader, long)}. *

*/ @Override public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { updateClob(columnIndex, reader, length); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #updateClob(int, Reader)}. *

*/ @Override public void updateNClob(int columnIndex, Reader reader) throws SQLException { updateClob(columnIndex, reader); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #updateClob(String, Clob)}. *

*/ @Override public void updateNClob(String columnLabel, NClob clob) throws SQLException { updateClob(columnLabel, clob); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #updateClob(int, Reader, long)}. *

*/ @Override public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { updateClob(columnLabel, reader, length); } /** * {@inheritDoc} *

* Implementation note: This method behaves exactly the same as {@link #updateClob(String, Reader)}. *

*/ @Override public void updateNClob(String columnLabel, Reader reader) throws SQLException { updateClob(columnLabel, reader); } public void updateRowId(int columnIndex, RowId x) throws SQLException { throw new FBDriverNotCapableException("Type ROWID not yet supported"); } public void updateRowId(String columnLabel, RowId x) throws SQLException { throw new FBDriverNotCapableException("Type ROWID not yet supported"); } public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { throw new FBDriverNotCapableException("Type SQLXML not supported"); } public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { throw new FBDriverNotCapableException("Type SQLXML not supported"); } public String getExecutionPlan() throws SQLException { checkCursorMove(); if (fbStatement == null) return ""; return fbStatement.getExecutionPlan(); } // java.sql.Wrapper interface public boolean isWrapperFor(Class iface) throws SQLException { return iface != null && iface.isAssignableFrom(this.getClass()); } public T unwrap(Class iface) throws SQLException { if (!isWrapperFor(iface)) throw new SQLException("Unable to unwrap to class " + iface.getName()); return iface.cast(this); } //-------------------------------------------------------------------- protected void addWarning(SQLWarning warning) { if (firstWarning == null) { firstWarning = warning; } else { firstWarning.setNextWarning(warning); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy