org.firebirdsql.jdbc.AbstractResultSet Maven / Gradle / Ivy
Show all versions of jaybird-jdk18 Show documentation
/* * 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
previous() when there is no current row. * * @returncolNames; 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 byrowDescriptor
and the data inrows
. ** 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, Listrows, 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 inrows
. ** 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, Listrows) throws SQLException { this(rowDescriptor, null, rows, false); } /** * Creates a FBResultSet with the columns specified by rowDescriptor
and the data inrows
. ** 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, Listrows, 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. AResultSet
object's * warning chain is cleared when a new row is read. * * @returntrue
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 thisResultSet
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 * thatStatement
object is closed, * re-executed, or is used to retrieve the next result from a * sequence of multiple results. AResultSet
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; SQLExceptionChainBuilderchain = 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 thegetXXX
methods * on a column to try to read its value and then call * the methodwasNull
to see if the value read was * SQLNULL
. * * @returntrue
if the last column value read was SQL *NULL
andfalse
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 aboolean
value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return Theboolean
value of the field * @throws SQLException if this paramater cannot be retrieved as * aboolean
*/ 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 abyte
value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return Thebyte
value of the field * @throws SQLException if this paramater cannot be retrieved as * abyte
*/ 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 abyte
array. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return Thebyte
array value of the field * @throws SQLException if this paramater cannot be retrieved as * abyte
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 aDate
object. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return TheDate
object of the field * @throws SQLException if this paramater cannot be retrieved as * aDate
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 adouble
value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return Thedouble
value of the field * @throws SQLException if this paramater cannot be retrieved as * adouble
*/ 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 afloat
value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return Thefloat
value of the field * @throws SQLException if this paramater cannot be retrieved as * afloat
*/ 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 anint
value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return Theint
value of the field * @throws SQLException if this paramater cannot be retrieved as * anint
*/ 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 along
value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return Thelong
value of the field * @throws SQLException if this paramater cannot be retrieved as * along
*/ 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 anObject
. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return TheObject
representation of the field * @throws SQLException if this paramater cannot be retrieved as * anObject
*/ 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 ashort
value. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return Theshort
value of the field * @throws SQLException if this paramater cannot be retrieved as * ashort
*/ 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 aString
object. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return TheString
representation of the field * @throws SQLException if this paramater cannot be retrieved as * aString
*/ 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 aTime
object. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return TheTime
representation of the field * @throws SQLException if this paramater cannot be retrieved as * aTime
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 aTimestamp
object. * * @param columnIndex The index of the parameter to retrieve, first * parameter is 1, second is 2, ... * @return TheTimestamp
representation of the field * @throws SQLException if this paramater cannot be retrieved as * aTimestamp
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 theFBField
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 aFBField
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 thisResultSet
object as * ajava.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 SQLNULL
, the * value returned isnull
* @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 aString
. * * @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 aboolean
value. * * @param columnName The SQL name of the column * @return TheString
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 abyte
value. * * @param columnName The SQL name of the column * @return Thebyte
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 ashort
value. * * @param columnName The SQL name of the column * @return THeshort
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 anint
value. * * @param columnName The SQL name of the column * @return Theint
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 along
value. * * @param columnName The SQL name of the column * @return Thelong
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 afloat
value. * * @param columnName The SQL name of the column * @return Thefloat
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 adouble
value. * * @param columnName The SQL name of the column * @return Thedouble
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 aBigDecimal
. * * @param columnName The SQL name of the column * @return TheBigDecimal
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 abyte
array. * * @param columnName The SQL name of the column * @return Thebyte
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 aDate
. * * @param columnName The SQL name of the column * @return TheDate
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 aTime
object. * * @param columnName The SQL name of the column * @return TheTime
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 aTimestamp
object. * * @param columnName The SQL name of the column * @return TheTimestamp
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 anInputStream
. * * @param columnName The SQL name of the column * @return The value as anInputStream
* @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 binaryInputStream
. * * @param columnName The SQL name of the column * @return The value as a binaryInputStream
* @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 thisResultSet
object * will be chained to theSQLWarning
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 firstSQLWarning
object reported ornull
* @exception SQLException if a database access error occurs */ public SQLWarning getWarnings() throws SQLException { return firstWarning; } /** * Clears all warnings reported on thisResultSet
object. * After this method is called, the methodgetWarnings
* returnsnull
until a new warning is * reported for thisResultSet
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 thisResultSet
* 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 aResultSet
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 thisResultSet
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 * anObject
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 ajava.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 givenResultSet
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 thisResultSet
object as a *java.io.Reader
object. * @return ajava.io.Reader
object that contains the column * value; if the value is SQLNULL
, 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 thisResultSet
object as a *java.io.Reader
object. * * @param columnName the name of the column * @return ajava.io.Reader
object that contains the column * value; if the value is SQLNULL
, 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 thisResultSet
object as a *java.math.BigDecimal
with full precision. * * @param columnName the column name * @return the column value (full precision); * if the value is SQLNULL
, 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 * thisResultSet
object. * * @returntrue
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 * thisResultSet
object. * * @returntrue
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 * thisResultSet
object. * * @returntrue
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 * thisResultSet
object. * Note: Calling the methodisLast
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. * * @returntrue
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 * thisResultSet
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 isTYPE_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 * thisResultSet
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 isTYPE_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 * thisResultSet
object. * * @returntrue
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 isTYPE_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 * thisResultSet
object. * * @returntrue
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 isTYPE_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 forResultSet
s with a result * set type ofTYPE_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 * thisResultSet
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 methodabsolute(-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 callingfirst()
. Callingabsolute(-1)
* is the same as callinglast()
. * * @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 * @returntrue
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 isTYPE_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. Callingrelative(0)
is valid, but does * not change the cursor position. * *Note: Calling the method
relative(1)
* is different from calling the methodnext()
* because is makes sense to callnext()
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. * * @returntrue
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 methodrelative(-1)
because it * makes sense to calltrue
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 isTYPE_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 * conditionrows >= 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 thisResultSet
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 thisResultSet
object. * The type is determined by theStatement
object * that created the result set. * * @returnTYPE_FORWARD_ONLY
, *TYPE_SCROLL_INSENSITIVE
, * orTYPE_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 thisResultSet
object. * The concurrency used is determined by the *Statement
object that created the result set. * * @return the concurrency type, eitherCONCUR_READ_ONLY
* orCONCUR_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 thisResultSet
object * * @return eitherResultSet.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. * * @returntrue
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. * * @returntrue
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 thisResultSet
object can detect deletions. * * @returntrue
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. * * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
* orinsertRow
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 aboolean
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 abyte
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 ashort
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 anint
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 along
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 afloat
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 adouble
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 ajava.math.BigDecimal
* value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 aString
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 abyte
array value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 ajava.sql.Date
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 ajava.sql.Time
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 ajava.sql.Timestamp
* value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 anObject
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 forjava.sql.Types.DECIMA
* orjava.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 anObject
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 anull
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 aboolean
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 abyte
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 ashort
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 anint
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 along
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 afloat
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 adouble
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 ajava.sql.BigDecimal
* value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 aString
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 aboolean
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
or *insertRow
methods are called to update the database. * * JDBC 2.0 * * Updates a column with a byte array value. * * TheupdateXXX
methods are used to update column values in the * current row, or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
orinsertRow
* 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 ajava.sql.Date
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 ajava.sql.Time
value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 ajava.sql.Timestamp
* value. * TheupdateXXX
methods are used to update column values in the * current row or the insert row. TheupdateXXX
methods do not * update the underlying database; instead theupdateRow
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 thisResultSet
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 thisResultSet
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 callrefreshRow
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 anupdateXXX
method, but before calling * the methodupdateRow
, 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 methodupdateRow
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 theupdateXXX
methods prior to * inserting the row into the result set. * * Only theupdateXXX
,getXXX
, * andinsertRow
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 callinginsertRow
. * AnupdateXXX
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 theStatement
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 theStatement
object that produced * thisResultSet
object ornull
* 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 thisResultSet
object as anObject
* in the Java programming language. * This method uses the givenMap
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 ajava.util.Map
object that contains the mapping * from SQL type names to classes in the Java programming language * @return anObject
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 aRef
object * in the Java programming language. * * @param i the first column is 1, the second is 2, ... * @return aRef
object representing an SQLREF
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 thisResultSet
object as aClob
object * in the Java programming language. * * @param i the first column is 1, the second is 2, ... * @return aClob
object representing the SQLCLOB
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 thisResultSet
object as anArray
object * in the Java programming language. * * @param i the first column is 1, the second is 2, ... * @return anArray
object representing the SQLARRAY
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 thisResultSet
object as anObject
* in the Java programming language. * This method uses the specifiedMap
object for * custom mapping if appropriate. * * @param columnName the name of the column from which to retrieve the value * @param map ajava.util.Map
object that contains the mapping * from SQL type names to classes in the Java programming language * @return anObject
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 aRef
object * in the Java programming language. * * @param columnName the column name * @return aRef
object representing the SQLREF
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 thisResultSet
object as aBlob
object * in the Java programming language. * * @param columnName the name of the column from which to retrieve the value * @return aBlob
object representing the SQLBLOB
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 thisResultSet
object as aClob
object * in the Java programming language. * * @param columnName the name of the column from which to retrieve the value * @return aClob
object representing the SQLCLOB
* 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 thisResultSet
object as anArray
object * in the Java programming language. * * @param columnName the name of the column from which to retrieve the value * @return anArray
object representing the SQLARRAY
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 thisResultSet
object as ajava.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 thejava.util.Calendar
object * to use in constructing the date * @return the column value as ajava.sql.Date
object; * if the value is SQLNULL
, * the value returned isnull
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 thisResultSet
object as ajava.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 thejava.util.Calendar
object * to use in constructing the date * @return the column value as ajava.sql.Date
object; * if the value is SQLNULL
, * the value returned isnull
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 thisResultSet
object as ajava.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 thejava.util.Calendar
object * to use in constructing the time * @return the column value as ajava.sql.Time
object; * if the value is SQLNULL
, * the value returned isnull
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 thisResultSet
object as ajava.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 thejava.util.Calendar
object * to use in constructing the time * @return the column value as ajava.sql.Time
object; * if the value is SQLNULL
, * the value returned isnull
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 thisResultSet
object as ajava.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 thejava.util.Calendar
object * to use in constructing the timestamp * @return the column value as ajava.sql.Timestamp
object; * if the value is SQLNULL
, * the value returned isnull
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 thisResultSet
object as ajava.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 thejava.util.Calendar
object * to use in constructing the date * @return the column value as ajava.sql.Timestamp
object; * if the value is SQLNULL
, * the value returned isnull
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 publicT 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()); } publicT 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); } } }