JDBC ResultSet Quiz
89 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the initial position of the cursor in a ResultSet object?

  • In the middle of the data set
  • At the first row of data
  • Before the first row of data (correct)
  • At the last row of data
  • Which method is used to move the cursor to the next row in a ResultSet?

  • goForward()
  • moveToNext()
  • advance()
  • next() (correct)
  • What type of ResultSet allows for scrolling backward and forward?

  • TYPE_FORWARD_ONLY
  • TYPE_SCROLL_SENSITIVE
  • TYPE_READ_ONLY
  • TYPE_SCROLL_INSENSITIVE (correct)
  • How does a JDBC driver handle data retrieval using the getter methods?

    <p>It converts the underlying data to the Java type specified in the getter method</p> Signup and view all the answers

    What is the recommended order for reading columns within each row of a ResultSet?

    <p>Left-to-right order for maximum portability</p> Signup and view all the answers

    What does the getClob() method retrieve from the ResultSet object?

    <p>A Clob object from the designated column</p> Signup and view all the answers

    Which method is used to obtain a stream of uninterpreted bytes from the ResultSet?

    <p>getBinaryStream(String columnLabel)</p> Signup and view all the answers

    What is the primary purpose of the getBigDecimal() method with full precision?

    <p>To retrieve a BigDecimal value from the designated column</p> Signup and view all the answers

    Which method would be deprecated for retrieving a BigDecimal with a specified scale?

    <p>getBigDecimal(String columnLabel, int scale)</p> Signup and view all the answers

    What does the getDate() method return from the ResultSet object?

    <p>A java.sql.Date object from the designated column</p> Signup and view all the answers

    What happens when a getter method is invoked with a column name that is duplicated in a ResultSet?

    <p>The value of the first matching column is returned.</p> Signup and view all the answers

    Which method call would correctly update a column value in the fifth row of a ResultSet?

    <p>rs.absolute(5); rs.updateString('NAME', 'AINSWORTH');</p> Signup and view all the answers

    What is the purpose of the SQL AS clause when using column names in SQL queries?

    <p>To ensure that column names uniquely identify columns in the ResultSet.</p> Signup and view all the answers

    What occurs to open ResultSet objects when the associated Statement object is closed?

    <p>They are automatically closed immediately.</p> Signup and view all the answers

    Which ResultSet type allows for scrolling in both directions and is sensitive to changes in the underlying data?

    <p>TYPE_SCROLL_SENSITIVE</p> Signup and view all the answers

    What is the return value of the next method when the cursor is positioned after the last row in a ResultSet?

    <p>false</p> Signup and view all the answers

    When a ResultSet is closed, which of the following remains accessible?

    <p>ResultSetMetaData instances created by getMetaData</p> Signup and view all the answers

    Which statement is true about the wasNull method?

    <p>It returns true if the last read was a valid SQL NULL.</p> Signup and view all the answers

    What happens if you call the close method on a ResultSet that is already closed?

    <p>It performs no operation.</p> Signup and view all the answers

    Which of the following describes the behavior of a ResultSet when the CLOSE_CURSORS_AT_COMMIT constant is used?

    <p>ResultSet is closed automatically at transaction commit.</p> Signup and view all the answers

    What will be returned when calling getInt() with a SQL NULL value in the designated column?

    <p>0 as the integer representation of the null value</p> Signup and view all the answers

    Which of the following statements about the getBytes() method is accurate?

    <p>It returns null if the SQL NULL is encountered in the column.</p> Signup and view all the answers

    What potential exception is thrown if an invalid column index is used with getLong()?

    <p>SQLException</p> Signup and view all the answers

    What is a major change regarding the getBigDecimal() method with a specific scale?

    <p>It has been deprecated in favor of retrieving BigDecimal without scale.</p> Signup and view all the answers

    Which exception might occur if the method getDate() is called on a closed ResultSet?

    <p>SQLException</p> Signup and view all the answers

    Which statement is true about the getAsciiStream method in a ResultSet?

    <p>It throws SQLException if the columnIndex is not valid.</p> Signup and view all the answers

    What is the behavior of the getBinaryStream method when the column value is SQL NULL?

    <p>It returns null.</p> Signup and view all the answers

    Which of the following must be considered when calling the getString method?

    <p>The columnLabel must correspond to a valid column name or alias.</p> Signup and view all the answers

    What exception is thrown by the getUnicodeStream method under certain conditions?

    <p>SQLFeatureNotSupportedException</p> Signup and view all the answers

    When using getBoolean, how does it interpret a column value of '0'?

    <p>It returns false if the datatype is CHAR or VARCHAR.</p> Signup and view all the answers

    What does the constant FETCH_UNKNOWN indicate about the ResultSet's row processing order?

    <p>The order of processing rows is undefined.</p> Signup and view all the answers

    Which constant indicates a ResultSet that allows movement only forward without scrolling?

    <p>TYPE_FORWARD_ONLY</p> Signup and view all the answers

    Which concurrency mode constant allows for updates on a ResultSet object?

    <p>CONCUR_UPDATABLE</p> Signup and view all the answers

    What does the constant TYPE_SCROLL_INSENSITIVE imply about the ResultSet's sensitivity to data changes?

    <p>It is not affected by changes to the underlying data.</p> Signup and view all the answers

    What is the primary characteristic of FETCH_REVERSE constant in relation to ResultSet processing?

    <p>Rows are processed in a last-to-first direction.</p> Signup and view all the answers

    What is the return value when the designated column in the ResultSet is SQL NULL when using the getFloat method?

    <p>The value returned is 0</p> Signup and view all the answers

    Which of the following exceptions can be thrown by the getter methods of a ResultSet?

    <p>SQLException</p> Signup and view all the answers

    What happens if the getBigDecimal method is called with a deprecated scale parameter?

    <p>It retrieves the value as a decimal without scaling</p> Signup and view all the answers

    Which statement is true regarding the getBytes method in a ResultSet?

    <p>It returns a byte array or null if SQL NULL is encountered</p> Signup and view all the answers

    What happens if updateBytes is called with an invalid columnIndex?

    <p>An SQLException is thrown.</p> Signup and view all the answers

    Which of the following is true regarding the updater methods like updateDate?

    <p>They require a corresponding updateRow method to finalize changes to the database.</p> Signup and view all the answers

    Which exception might occur if updateTime is called on a closed ResultSet?

    <p>SQLException</p> Signup and view all the answers

    What parameter does the updateDate method require first when updating a column value?

    <p>int columnIndex</p> Signup and view all the answers

    If the JDBC driver does not support the updateBytes method, what exception will be thrown?

    <p>SQLFeatureNotSupportedException</p> Signup and view all the answers

    What must be done to actually update the database after using updater methods in a ResultSet?

    <p>Call updateRow or insertRow methods</p> Signup and view all the answers

    Which exception is NOT thrown by the updater methods when an invalid column index is specified?

    <p>IllegalArgumentException</p> Signup and view all the answers

    What parameter is used in the updateShort method to specify the new value for the designated column?

    <p>x</p> Signup and view all the answers

    What occurs if the updateNull method is called on a columnLabel that is not valid?

    <p>A SQLException is thrown</p> Signup and view all the answers

    In which case will the SQLFeatureNotSupportedException be thrown when using an updater method?

    <p>If the JDBC driver does not support the method</p> Signup and view all the answers

    What is the purpose of calling the updateRow method after using an updater method like updateFloat?

    <p>It applies the updates to the underlying database.</p> Signup and view all the answers

    If a columnLabel provided to an updater method is invalid, which exception is guaranteed to be thrown?

    <p>SQLException</p> Signup and view all the answers

    How should the columnLabel be related to the SQL AS clause when updating a column using methods like updateDouble?

    <p>It should be the original name of the column if the SQL AS clause was omitted.</p> Signup and view all the answers

    Which JDBC driver limitation would result in throwing a SQLFeatureNotSupportedException when using an updater method?

    <p>A lack of necessary features in the JDBC driver for that updater method.</p> Signup and view all the answers

    What must be done before an updater method like updateBytes is called to ensure that the changes are accurately applied?

    <p>Verify that the result set is not CONCUR_READ_ONLY.</p> Signup and view all the answers

    What is the function of the updateObject method when an instance of InputStream is provided as the second argument?

    <p>It updates the designated column with the stream's data only if its length equals the specified scaleOrLength.</p> Signup and view all the answers

    Which exception is thrown when attempting to update a column in a closed result set?

    <p>SQLException</p> Signup and view all the answers

    When using the updateTimestamp method, what does it indicate if an SQLFeatureNotSupportedException is thrown?

    <p>The JDBC driver does not support the use of timestamps.</p> Signup and view all the answers

    What is a consequence of calling the updateRow method after using any of the updater methods?

    <p>It commits the changes made to the underlying database for the current row.</p> Signup and view all the answers

    In which case would the updateAsciiStream method fail with a SQLException?

    <p>If the designated column index exceeds the current row range.</p> Signup and view all the answers

    What must be executed after using an updater method to update column values in a ResultSet?

    <p>The updateRow or insertRow method must be called to persist changes.</p> Signup and view all the answers

    What type of exception is thrown if an invalid columnLabel is provided while using the updater methods?

    <p>SQLException</p> Signup and view all the answers

    In which scenario would a SQLFeatureNotSupportedException be raised when using an updater method?

    <p>If the JDBC driver does not support the specified updater method.</p> Signup and view all the answers

    What will happen if an updater method is called on a ResultSet with concurrency set to CONCUR_READ_ONLY?

    <p>A JDBCException will be thrown.</p> Signup and view all the answers

    What does the length parameter specify in the updateAsciiStream and updateBinaryStream methods?

    <p>The number of bytes to read from the InputStream.</p> Signup and view all the answers

    Match the following methods with their corresponding parameter types:

    <p>updateBytes = byte[] x updateDate = Date x updateTime = Time x updateShort = short x</p> Signup and view all the answers

    Match the following exceptions with their conditions:

    <p>SQLException = Invalid column index or access error SQLFeatureNotSupportedException = JDBC driver does not support the method IllegalArgumentException = Invalid parameter type provided ConcurrentModificationException = Database record altered while accessing</p> Signup and view all the answers

    Match the following updater methods to their respective update behavior:

    <p>updateBytes = Updates value without immediate database change updateDate = Used for updating date columns updateTime = Utilizes java.sql.Time for column update updateRow = Commits changes to the underlying database</p> Signup and view all the answers

    Match the following method calls with the exception they throw:

    <p>updateBytes with invalid columnIndex = SQLException updateDate on closed result set = SQLException updateTime with unsupported driver = SQLFeatureNotSupportedException updateRow without prior update = No exception thrown</p> Signup and view all the answers

    Match the following JDBC version with their introduction:

    <p>updateBytes = 1.2 updateDate = 1.2 updateTime = 1.2 updateRow = 1.1</p> Signup and view all the answers

    Match the following updater methods with their respective parameter types:

    <p>updateFloat = float updateDouble = double updateBigDecimal = BigDecimal updateString = String</p> Signup and view all the answers

    Match the following exceptions with the scenarios they relate to:

    <p>SQLException = Result set concurrency is CONCUR_READ_ONLY SQLFeatureNotSupportedException = JDBC driver does not support the method</p> Signup and view all the answers

    Match the following updater methods with their intended use:

    <p>updateBytes = Update designated column with byte array updateDate = Update designated column with Date value updateString = Update designated column with String value updateFloat = Update designated column with float value</p> Signup and view all the answers

    Match the following updater methods with their respective parameter types:

    <p>updateTime = java.sql.Time updateTimestamp = java.sql.Timestamp updateAsciiStream = InputStream updateBinaryStream = InputStream</p> Signup and view all the answers

    Match the following method signatures with their descriptions:

    <p>updateFloat(String columnLabel, float x) = Updates a float value to a column updateDouble(String columnLabel, double x) = Updates a double value to a column updateBigDecimal(String columnLabel, BigDecimal x) = Updates a BigDecimal value to a column updateString(String columnLabel, String x) = Updates a String value to a column</p> Signup and view all the answers

    Match the following updater methods with their description:

    <p>updateCharacterStream = Updates the designated column with a character stream value updateObject = Updates the designated column with an Object value updateTimestamp = Updates the designated column with a timestamp value updateNull = Sets the designated column to SQL NULL</p> Signup and view all the answers

    Match the following exceptions with their potential triggers in the updater methods:

    <p>SQLException = Invalid columnLabel or database access error SQLFeatureNotSupportedException = JDBC driver does not support the method IllegalArgumentException = Method called on a closed result set NullPointerException = Null passed as updater method parameter</p> Signup and view all the answers

    Match the following parameters with their roles in updater methods:

    <p>columnLabel = The label for the column specified with the SQL AS clause x = The new column value result set = Current row or insert row context database = Updated via updateRow or insertRow methods</p> Signup and view all the answers

    Match the following updater methods with their specified length parameters:

    <p>updateAsciiStream = Length of the stream in bytes updateBinaryStream = Length of the stream in bytes updateCharacterStream = Length of the stream in bytes updateObject = Scale or length for the designated column</p> Signup and view all the answers

    Match the updater methods with the type of database update they do:

    <p>updateTime = Current row or insert row update updateTimestamp = Current row or insert row update updateAsciiStream = Current row or insert row update updateNull = Sets column value to SQL NULL in memory</p> Signup and view all the answers

    Match the following updater methods with their respective value types:

    <p>updateNull = null value updateBoolean = boolean value updateByte = byte value updateShort = short value</p> Signup and view all the answers

    Match the updater methods with the exceptions they may throw:

    <p>updateInt = SQLException updateLong = SQLFeatureNotSupportedException updateByte = SQLException updateShort = SQLFeatureNotSupportedException</p> Signup and view all the answers

    Match the updater methods with their respective parameter descriptions:

    <p>updateNull = Label for the designated column updateBoolean = Designation of boolean column updateByte = Designation of byte column updateShort = Designation of short column</p> Signup and view all the answers

    Match the updater methods with their intended uses:

    <p>updateInt = Update integer column values updateLong = Update long column values updateNull = Update designated column to null updateBoolean = Update designated column to boolean value</p> Signup and view all the answers

    Match the following parameters of updater methods with their descriptions:

    <p>columnLabel = Name or label of the column specified with SQL AS x = New value for the column columnIndex = Index of the column starting from 1 SQLException = Exception thrown for database access errors</p> Signup and view all the answers

    Match the JDBC updater methods with their corresponding descriptions:

    <p>updateTimestamp = Updates a column with a java.sql.Timestamp value updateAsciiStream = Updates a column with an ascii stream value updateBinaryStream = Updates a column with a binary stream value updateCharacterStream = Updates a column with a character stream value</p> Signup and view all the answers

    Match the JDBC updater methods with their parameters:

    <p>updateObject(int columnIndex, Object x, int scaleOrLength) = Updates column and requires scale or length for InputStream and Reader updateTimestamp(int columnIndex, Timestamp x) = Updates designated column with java.sql.Timestamp value updateAsciiStream(int columnIndex, InputStream x, int length) = Updates column with specified length of ascii stream updateBinaryStream(int columnIndex, InputStream x, int length) = Updates column with specified length of binary stream</p> Signup and view all the answers

    Match the exceptions with their descriptions when calling updater methods:

    <p>SQLException = Thrown for invalid columnIndex or database access error SQLFeatureNotSupportedException = Thrown if the JDBC driver does not support the method IllegalArgumentException = Not specifically mentioned; relates to invalid argument handling NullPointerException = Not specifically covered in the content; relates to null arguments</p> Signup and view all the answers

    Match the JDBC updater methods with their functionalities:

    <p>updateObject(int columnIndex, Object x) = Updates a column with an Object value only updateTimestamp(int columnIndex, Timestamp x) = Updates the current row with a Timestamp updateBinaryStream(int columnIndex, InputStream x, int length) = Updates a column with a binary input stream updateCharacterStream(int columnIndex, Reader x, int length) = Updates a column with a character input stream</p> Signup and view all the answers

    Match the parameters used in JDBC updater methods:

    <p>columnIndex = Indicates the index of the column to update x = The new value to set in the column length = Specifies the length of the stream for ascii or binary scaleOrLength = Specifies the scale for BigDecimal or length for streams</p> Signup and view all the answers

    Study Notes

    ResultSet Interface

    • An interface representing a database result set, typically generated by executing a query.
    • Maintains a cursor that points to the current row of data.
    • Initially, the cursor is positioned before the first row.
    • The next() method moves the cursor to the next row and returns false when no more rows exist.
    • A default ResultSet object is read-only and its cursor moves forward only.
    • Supports iteration through the result set from the first row to the last row only once.
    • Can create scrollable and/or updatable ResultSet objects.
    • Provides getter methods to retrieve column values from the current row using either column index or name.
    • Column numbers start from 1.
    • For maximum portability, it's recommended to read columns from left to right and only once.
    • JDBC drivers try to convert underlying data to the specified Java type.
    • Column names are case-insensitive. If multiple columns have the same name, the value of the first matching column is returned.
    • Offers updater methods to update column values in the current row and insert values into a staging row for insertion.
    • The insertRow() method inserts the staging row into the ResultSet and the data source table.
    • Automatically closed when the Statement object that generated it is closed, re-executed, or used for the next result in a sequence of results.
    • ResultSetMetaData object, retrieved via getMetaData(), provides information about the ResultSet object's columns.

    ResultSet Interface Fields

    • CLOSE_CURSORS_AT_COMMIT: Indicates that open ResultSets with this holdability will be closed when the current transaction commits.
    • CONCUR_READ_ONLY: Indicates that the ResultSet object is not updatable.
    • CONCUR_UPDATABLE: Indicates that the ResultSet object is updatable.
    • FETCH_FORWARD: Indicates that the rows in a result set will be processed in a forward-only direction (first-to-last).
    • FETCH_REVERSE: Indicates that the rows in a result set will be processed in reverse direction (last-to-first).
    • FETCH_UNKNOWN: Indicates that the order in which rows in a result set will be processed is unknown.
    • HOLD_CURSORS_OVER_COMMIT: Indicates that open ResultSets with this holdability will remain open when the current transaction is committed.
    • TYPE_FORWARD_ONLY: Indicates a ResultSet object whose cursor can only move forward.
    • TYPE_SCROLL_INSENSITIVE: Indicates a scrollable ResultSet object that is usually not sensitive to changes in the underlying data.
    • TYPE_SCROLL_SENSITIVE: Indicates a scrollable ResultSet object that is sensitive to changes in the underlying data.

    ResultSet Interface Methods

    • absolute(int): Moves the cursor to the specified row number.
    • afterLast(): Moves the cursor to the end of the ResultSet object, just after the last row.
    • beforeFirst(): Moves the cursor to the front of the ResultSet object, just before the first row.
    • cancelRowUpdates(): Cancels updates made to the current row.
    • clearWarnings(): Clears all warnings reported on the ResultSet object.
    • close(): Releases the ResultSet object's resources immediately.
    • deleteRow(): Deletes the current row from the ResultSet object and the underlying database.
    • findColumn(String): Maps a given column label to its index in the ResultSet object.
    • first(): Moves the cursor to the first row.
    • getArray(int): Retrieves the value of the designated column as an Array object.
    • getArray(String): Retrieves the value of the designated column as an Array object using the column label.
    • getAsciiStream(int): Retrieves the column value as a stream of ASCII characters.
    • getAsciiStream(String): Retrieves the column value as a stream of ASCII characters using the column label.
    • getBigDecimal(int): Retrieves the column value as a BigDecimal with full precision.
    • getBigDecimal(int, int): Retrieves the column value as a BigDecimal with specified scale (deprecated).
    • getBigDecimal(String): Retrieves the column value as a BigDecimal with full precision using the column label.
    • getBigDecimal(String, int): Retrieves the column value as a BigDecimal with specified scale (deprecated).
    • getBinaryStream(int): Retrieves the column value as a stream of uninterpreted bytes.
    • getBinaryStream(String): Retrieves the column value as a stream of uninterpreted bytes using the column label.
    • getBlob(int): Retrieves the column value as a Blob object.
    • getBlob(String): Retrieves the column value as a Blob object using the column label.
    • getBoolean(int): Retrieves the column value as a boolean.
    • getBoolean(String): Retrieves the column value as a boolean using the column label.
    • getByte(int): Retrieves the column value as a byte.
    • getByte(String): Retrieves the column value as a byte using the column label.
    • getBytes(int): Retrieves the column value as a byte array.
    • getBytes(String): Retrieves the column value as a byte array using the column label.
    • getCharacterStream(int): Retrieves the column value as a Reader object.
    • getCharacterStream(String): Retrieves the column value as a Reader object using the column label.
    • getClob(int): Retrieves the column value as a Clob object.
    • getClob(String): Retrieves the column value as a Clob object using the column label.
    • getConcurrency(): Retrieves the concurrency mode of the ResultSet object.
    • getCursorName(): Retrieves the name of the SQL cursor used by the ResultSet object.
    • getDate(int): Retrieves the column value as a java.sql.Date object.
    • getDate(int, Calendar): Retrieves the column value as a java.sql.Date object with a specified calendar.
    • getDate(String): Retrieves the column value as a java.sql.Date object using the column label.
    • getDate(String, Calendar): Retrieves the column value as a java.sql.Date object with a specified calendar using the column label.
    • getDouble(int): Retrieves the column value as a double.
    • getDouble(String): Retrieves the column value as a double using the column label.
    • getFetchDirection(): Retrieves the fetch direction of the ResultSet object.
    • getFetchSize(): Retrieves the fetch size of the ResultSet object.
    • getFloat(int): Retrieves the column value as a float.
    • getFloat(String): Retrieves the column value as a float using the column label.
    • getHoldability(): Retrieves the holdability of the ResultSet object.
    • getInt(int): Retrieves the column value as an int.
    • getInt(String): Retrieves the column value as an int using the column label.
    • getLong(int): Retrieves the column value as a long.
    • getLong(String): Retrieves the column value as a long using the column label.
    • getMetaData(): Retrieves the ResultSetMetaData object containing information about columns.
    • getNCharacterStream(int): Retrieves the column value as a Reader object.
    • getNCharacterStream(String): Retrieves the column value as a Reader object using the column label.
    • getNClob(int): Retrieves the column value as an NClob object.
    • getNClob(String): Retrieves the column value as an NClob object using the column label.
    • getNString(int): Retrieves the column value as a String.
    • getNString(String): Retrieves the column value as a String using the column label.
    • getObject(int): Retrieves the column value as an Object.
    • getObject(int, Class): Retrieves the column value as an Object with a specified type.
    • getObject(int, Map): Retrieves the column value as an Object with a type map.
    • getRef(int): Retrieves the column value as a Ref object.
    • getRef(String): Retrieves the column value as a Ref object using the column label.
    • getRow(): Retrieves the current row number.
    • getRowId(int): Retrieves the column value as a java.sql.RowId object.
    • getRowId(String): Retrieves the column value as a java.sql.RowId object using the column label.
    • getShort(int): Retrieves the column value as a short.
    • getShort(String): Retrieves the column value as a short using the column label.
    • getSQLXML(int): Retrieves the column value as a java.sql.SQLXML object.
    • getSQLXML(String): Retrieves the column value as a java.sql.SQLXML object using the column label.
    • getStatement(): Retrieves the Statement object that generated this ResultSet object.
    • getString(int): Retrieves the column value as a String.
    • getString(String): Retrieves the column value as a String using the column label.
    • getTime(int): Retrieves the column value as a java.sql.Time object.
    • getTime(int, Calendar): Retrieves the column value as a java.sql.Time object with a specified calendar.
    • getTime(String): Retrieves the column value as a java.sql.Time object using the column label.
    • getTime(String, Calendar): Retrieves the column value as a java.sql.Time object with a specified calendar using the column label.
    • getTimestamp(int): Retrieves the column value as a java.sql.Timestamp object.
    • getTimestamp(int, Calendar): Retrieves the column value as a java.sql.Timestamp object with a specified calendar.
    • getTimestamp(String): Retrieves the column value as a java.sql.Timestamp object using the column label.
    • getTimestamp(String, Calendar): Retrieves the column value as a java.sql.Timestamp object with a specified calendar using the column label.
    • getType(): Retrieves the type of the ResultSet object.
    • insertRow(): Inserts the row being built in the staging area into ResultSet and data source table.
    • last(): Moves the cursor to the last row.
    • moveToCurrentRow(): Moves the cursor back to the current row.
    • moveToInsertRow(): Moves the cursor to the staging area row for building a new row to be inserted.
    • next(): Moves the cursor to the next row, returning false when there are no more rows.
    • previous(): Moves the cursor to the previous row.
    • relative(int): Moves the cursor to the position relative to the current row.
    • rowDeleted(): Indicates whether the current row has been deleted.
    • rowInserted(): Indicates whether the current row has been inserted.
    • rowUpdated(): Indicates whether the current row has been updated.
    • updateArray(int, Array): Updates the value of the designated column with an Array object.
    • updateArray(String, Array): Updates the value of the designated column with an Array object using the column label.
    • updateAsciiStream(int, InputStream): Updates the designated column with a stream of ASCII characters.
    • updateAsciiStream(int, InputStream, int): Updates the designated column with a stream of ASCII characters with a specified length.
    • updateAsciiStream(String, InputStream): Updates the designated column with a stream of ASCII characters using the column label.
    • updateAsciiStream(String, InputStream, int): Updates the designated column with a stream of ASCII characters with a specified length using the column label.
    • updateBigDecimal(int, BigDecimal): Updates the designated column with a BigDecimal value.
    • updateBigDecimal(String, BigDecimal): Updates the designated column with a BigDecimal value using the column label.
    • updateBinaryStream(int, InputStream): Updates the designated column with a stream of uninterpreted bytes.
    • updateBinaryStream(int, InputStream, int): Updates the designated column with a stream of uninterpreted bytes with a specified length.
    • updateBinaryStream(String, InputStream): Updates the designated column with a stream of uninterpreted bytes using the column label.
    • updateBinaryStream(String, InputStream, int): Updates the designated column with a stream of uninterpreted bytes with a specified length using the column label.
    • updateBlob(int, Blob): Updates the designated column with a Blob object.
    • updateBlob(int, InputStream): Updates the designated column with a stream of uninterpreted bytes from an InputStream.
    • updateBlob(int, InputStream, long): Updates the designated column with a stream of uninterpreted bytes from an InputStream with a specified length.
    • updateBlob(String, Blob): Updates the designated column with a Blob object using the column label.
    • updateBlob(String, InputStream): Updates the designated column with a stream of uninterpreted bytes from an InputStream using the column label.
    • updateBlob(String, InputStream, long): Updates the designated column with a stream of uninterpreted bytes from an InputStream with a specified length using the column label.
    • updateBoolean(int, boolean): Updates the designated column with a boolean value.
    • updateBoolean(String, boolean): Updates the designated column with a boolean value using the column label.
    • updateByte(int, byte): Updates the designated column with a byte value.
    • updateByte(String, byte): Updates the designated column with a byte value using the column label.
    • updateBytes(int, byte[]): Updates the designated column with a byte array.
    • updateBytes(String, byte[]): Updates the designated column with a byte array using the column label.
    • updateCharacterStream(int, Reader): Updates the designated column with a stream of characters from a Reader object.
    • updateCharacterStream(int, Reader, int): Updates the designated column with a stream of characters from a Reader object with a specified length.
    • updateCharacterStream(String, Reader): Updates the designated column with a stream of characters from a Reader object using the column label.
    • updateCharacterStream(String, Reader, int): Updates the designated column with a stream of characters from a Reader object with a specified length using the column label.
    • updateClob(int, Clob): Updates the designated column with a Clob object.
    • updateClob(int, Reader): Updates the designated column with a stream of characters from a Reader object.
    • updateClob(int, Reader, long): Updates the designated column with a stream of characters from a Reader object with a specified length.
    • updateClob(String, Clob): Updates the designated column with a Clob object using the column label.
    • updateClob(String, Reader): Updates the designated column with a stream of characters from a Reader object using the column label.
    • updateClob(String, Reader, long): Updates the designated column with a stream of characters from a Reader object with a specified length using the column label.
    • updateDate(int, Date): Updates the designated column with a java.sql.Date object.
    • updateDate(String, Date): Updates the designated column with a java.sql.Date object using the column label.
    • updateDouble(int, double): Updates the designated column with a double value.
    • updateDouble(String, double): Updates the designated column with a double value using the column label.
    • updateFloat(int, float): Updates the designated column with a float value.
    • updateFloat(String, float): Updates the designated column with a float value using the column label.
    • updateInt(int, int): Updates the designated column with an int value.
    • updateInt(String, int): Updates the designated column with an int value using the column label.
    • updateLong(int, long): Updates the designated column with a long value.
    • updateLong(String, long): Updates the designated column with a long value using the column label.
    • updateNCharacterStream(int, Reader): Updates the designated column with a stream of characters from a Reader object.
    • updateNCharacterStream(int, Reader, long): Updates the designated column with a stream of characters from a Reader object with a specified length.
    • updateNCharacterStream(String, Reader): Updates the designated column with a stream of characters from a Reader object using the column label.
    • updateNCharacterStream(String, Reader, long): Updates the designated column with a stream of characters from a Reader object with a specified length using the column label.
    • updateNClob(int, NClob): Updates the designated column with an NClob object.
    • updateNClob(int, Reader): Updates the designated column with a stream of characters from a Reader object.
    • updateNClob(int, Reader, long): Updates the designated column with a stream of characters from a Reader object with a specified length.
    • updateNClob(String, NClob): Updates the designated column with an NClob object using the column label.
    • updateNClob(String, Reader): Updates the designated column with a stream of characters from a Reader object using the column label.
    • updateNClob(String, Reader, long): Updates the designated column with a stream of characters from a Reader object with a specified length using the column label.
    • updateNString(int, String): Updates the designated column with a String value.
    • updateNString(String, String): Updates the designated column with a String value using the column label.
    • updateObject(int, Object): Updates the designated column with an object value.
    • updateObject(int, Object, int): Updates the designated column with a Object value with a specified SQL type.
    • updateObject(int, Object, int, int): Updates the designated column with a Object value with a specified SQL type and scale.
    • updateObject(String, Object): Updates the designated column with an object value using the column label.
    • updateObject(String, Object, int): Updates the designated column with a Object value with a specified SQL type using the column label.
    • updateObject(String, Object, int, int): Updates the designated column with a Object value with a specified SQL type and scale using the column label.
    • updateRef(int, Ref): Updates the designated column with a Ref object.
    • updateRef(String, Ref): Updates the designated column with a Ref object using the column label.
    • updateRow(): Updates the underlying data source table with the updates made to the current row.
    • updateRowId(int, RowId): Updates the designated column with a java.sql.RowId object.
    • updateRowId(String, RowId): Updates the designated column with a java.sql.RowId object using the column label.
    • updateShort(int, short): Updates the designated column with a short value.
    • updateShort(String, short): Updates the designated column with a short value using the column label.
    • updateSQLXML(int, SQLXML): Updates the designated column with an SQLXML object.
    • updateSQLXML(String, SQLXML): Updates the designated column with an SQLXML object using the column label.
    • updateString(int, String): Updates the designated column with a String value.
    • updateString(String, String): Updates the designated column with a String value using the column label.
    • updateTime(int, Time): Updates the designated column with a java.sql.Time object.
    • updateTime(String, Time): Updates the designated column with a java.sql.Time object using the column label.
    • updateTimestamp(int, Timestamp): Updates the designated column with a java.sql.Timestamp object.
    • updateTimestamp(String, Timestamp): Updates the designated column with a java.sql.Timestamp object using the column label.
    • wasNull(): Indicates whether the last column read had a value of SQL NULL.

    ResultSet Methods

    • getUnicodeStream(int columnIndex) and getUnicodeStream(String columnLabel) are deprecated, use getCharacterStream instead
    • getURL(int columnIndex) and getURL(String columnLabel) retrieve the value of the specified column in the current row as a java.net.URL object
    • getWarnings() retrieves the first warning reported by calls on the ResultSet object
    • insertRow() inserts the contents of the insert row into the ResultSet object and the database
    • isAfterLast() determines if the cursor is after the last row in the ResultSet object
    • isBeforeFirst() determines if the cursor is before the first row in the ResultSet object
    • isClosed() determines if the ResultSet object has been closed
    • isFirst() determines if the cursor is on the first row of the ResultSet object
    • isLast() determines if the cursor is on the last row of the ResultSet object
    • last() moves the cursor to the last row in the ResultSet object
    • moveToCurrentRow() moves the cursor to the remembered cursor position, usually the current row
    • moveToInsertRow() moves the cursor to the insert row
    • next() moves the cursor forward one row from its current position. It returns true if a new current row is available, otherwise false.
    • previous() moves the cursor to the previous row in the ResultSet object
    • refreshRow() refreshes the current row with its most recent value in the database
    • relative(int rows) moves the cursor a relative number of rows, either positive or negative.
    • rowDeleted() determines if a row has been deleted
    • rowInserted() determines if the current row has had an insertion
    • rowUpdated() determines if the current row has been updated
    • setFetchDirection(int direction) gives a hint to the driver about the direction in which rows in the ResultSet object will be processed. Possible values are:
      • FETCH_FORWARD
      • FETCH_REVERSE
      • FETCH_UNKNOWN
    • setFetchSize(int rows) gives a hint to the driver about the number of rows to fetch from the database when more rows are needed.
    • updateArray(int columnIndex, Array x) and updateArray(String columnLabel, Array x) update the designated column with a java.sql.Array value
    • updateAsciiStream(int columnIndex, InputStream x) and its variations update the designated column with an ascii stream value.
    • updateBigDecimal(int columnIndex, BigDecimal x) and updateBigDecimal(String columnLabel, BigDecimal x) update the designated column with a java.math.BigDecimal value
    • updateBinaryStream(int columnIndex, InputStream x) and its variations update the designated column with a binary stream value
    • updateBlob(int columnIndex, Blob x) and its variations update the designated column with a java.sql.Blob value
    • updateBoolean(int columnIndex, boolean x) and updateBoolean(String columnLabel, boolean x) update the designated column with a boolean value
    • updateByte(int columnIndex, byte x) and updateByte(String columnLabel, byte x) update the designated column with a byte value
    • updateBytes(int columnIndex, byte[] x) and updateBytes(String columnLabel, byte[] x) update the designated column with a byte array value
    • updateCharacterStream(int columnIndex, Reader x) and its variations update the designated column with a character stream value
    • updateClob(int columnIndex, Clob x) and its variations update the designated column with a java.sql.Clob value
    • updateDate(int columnIndex, Date x) and updateDate(String columnLabel, Date x) update the designated column with a java.sql.Date value
    • updateDouble(int columnIndex, double x) and updateDouble(String columnLabel, double x) update the designated column with a double value
    • updateFloat(int columnIndex, float x) and updateFloat(String columnLabel, float x) update the designated column with a float value
    • updateInt(int columnIndex, int x) and updateInt(String columnLabel, int x) update the designated column with an int value
    • updateLong(int columnIndex, long x) and updateLong(String columnLabel, long x) update the designated column with a long value
    • updateNCharacterStream(int columnIndex, Reader x) and its variations update the designated column with a character stream value
    • updateNClob(int columnIndex, NClob nClob) and its variations update the designated column with a java.sql.NClob value
    • updateNString(int columnIndex, String nString) and updateNString(String columnLabel, String nString) update the designated column with a String value
    • updateNull(int columnIndex) and updateNull(String columnLabel) update the designated column with a null value
    • updateObject(int columnIndex, Object x) and its variations update the designated column with an Object value
    • updateRef(int columnIndex, Ref x) and updateRef(String columnLabel, Ref x) update the designated column with a java.sql.Ref value
    • updateRow() updates the underlying database with the new contents of the current row of the ResultSet object
    • updateRowId(int columnIndex, RowId x) and updateRowId(String columnLabel, RowId x) update the designated column with a RowId value
    • updateShort(int columnIndex, short x) and updateShort(String columnLabel, short x) update the designated column with a short value
    • updateSQLXML(int columnIndex, SQLXML xmlObject) and updateSQLXML(String columnLabel, SQLXML xmlObject) update the designated column with a java.sql.SQLXML value
    • updateString(int columnIndex, String x) and updateString(String columnLabel, String x) update the designated column with a String value
    • updateTime(int columnIndex, Time x) and updateTime(String columnLabel, Time x) update the designated column with a java.sql.Time value
    • updateTimestamp(int columnIndex, Timestamp x) and updateTimestamp(String columnLabel, Timestamp x) update the designated column with a java.sql.Timestamp value
    • wasNull() reports whether the last column read had a value of SQL NULL.

    ResultSet Fields

    • FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN: constants indicating the direction in which rows will be processed in the result set
    • TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE: constants indicating the type of ResultSet object based on its cursor movement abilities and sensitivity to underlying data changes
    • CONCUR_READ_ONLY, CONCUR_UPDATABLE: constants indicating the concurrency mode of a ResultSet object (whether it is updatable or not)
    • HOLD_CURSORS_OVER_COMMIT, CLOSE_CURSORS_AT_COMMIT: constants indicating how ResultSet objects with this holdability will be handled when the current transaction is committed (whether they remain open or are closed)

    ResultSet Object

    • ResultSet objects are automatically closed by the Statement object that generated it when that Statement object is closed, re-executed, or is used to retrieve the next result from a sequence of multiple results.
    • Calling close() on a ResultSet object that is already closed is a no-op, which means it will have no effect.
    • Blob, Clob, and NClob objects created by the ResultSet remain valid for at least the duration of the transaction in which they are created, unless their free() method is invoked.
    • ResultSetMetaData instances created by calling the getMetaData() method remain accessible after the ResultSet is closed.

    ResultSet Getter Methods

    • wasNull() returns true if the last column value read was SQL NULL, otherwise false.
    • wasNull() throws an SQLException if a database access error occurs or the method is called on a closed result set.
    • The getString(int columnIndex) method retrieves the value of the designated column in the current row of the ResultSet object as a String.
    • getString() accepts an integer representing the column index (1 for the first column, 2 for the second, etc.)
    • getString() returns null if the value is SQL NULL.
    • getString() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getBoolean(int columnIndex) retrieves the value of the designated column as a boolean in the Java programming language.
    • getBoolean() returns false if the column has a datatype of CHAR or VARCHAR and contains "0", or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT and contains 0.
    • getBoolean() returns true if the column has a datatype of CHAR or VARCHAR and contains "1" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT and contains 1.
    • getBoolean() accepts an integer representing the column index.
    • getBoolean() returns false if the value is SQL NULL.
    • getBoolean() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getByte(int columnIndex) retrieves the value of the designated column as a byte in Java.
    • getByte() accepts an integer representing the column index.
    • getByte() returns 0 if the value is SQL NULL.
    • getByte() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getShort(int columnIndex) retrieves the value of the designated column as a short in Java.
    • getShort() accepts an integer representing the column index.
    • getShort() returns 0 if the value is SQL NULL.
    • getShort() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getInt(int columnIndex) retrieves the value of the designated column as an int in Java.
    • getInt() accepts an integer representing the column index.
    • getInt() returns 0 if the value is SQL NULL.
    • getInt() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getLong(int columnIndex) retrieves the value of the designated column as a long in Java.
    • getLong() accepts an integer representing the column index.
    • getLong() returns 0 if the value is SQL NULL.
    • getLong() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getFloat(int columnIndex) retrieves the value of the designated column as a float in Java.
    • getFloat() accepts an integer representing the column index.
    • getFloat() returns 0 if the value is SQL NULL.
    • getFloat() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getDouble(int columnIndex) retrieves the value of the designated column as a double in Java.
    • getDouble() accepts an integer representing the column index.
    • getDouble() returns 0 if the value is SQL NULL.
    • getDouble() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getBigDecimal(int columnIndex, int scale) retrieves the value of the designated column as a java.sql.BigDecimal in Java.
    • The getBigDecimal(int columnIndex, int scale) method is deprecated. Use getBigDecimal(int columnIndex) or getBigDecimal(String columnLabel) instead.
    • getBigDecimal() accepts an integer representing the column index and a scale value.
    • getBigDecimal() returns null if the value is SQL NULL.
    • getBigDecimal() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getBigDecimal() throws an SQLFeatureNotSupportedException if the JDBC driver does not support this method.
    • getBytes(int columnIndex) retrieves the value of the designated column as a byte[] array.
    • getBytes() accepts an integer representing the column index.
    • getBytes() returns null if the value is SQL NULL.
    • getBytes() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getDate(int columnIndex) retrieves the value of the designated column as a java.sql.Date object.
    • getDate() accepts an integer representing the column index.
    • getDate() returns null if the value is SQL NULL.
    • getDate() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getTime(int columnIndex) retrieves the value of the designated column as a java.sql.Time object.
    • getTime() accepts an integer representing the column index.
    • getTime() returns null if the value is SQL NULL.
    • getTime() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getTimestamp(int columnIndex) retrieves the value of the designated column as a java.sql.Timestamp object.
    • getTimestamp() accepts an integer representing the column index.
    • getTimestamp() returns null if the value is SQL NULL.
    • getTimestamp() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getAsciiStream(int columnIndex) retrieves the value of the designated column as a stream of ASCII characters.
    • getAsciiStream() accepts an integer representing the column index.
    • getAsciiStream() returns null if the value is SQL NULL.
    • getAsciiStream() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getUnicodeStream(int columnIndex) retrieves the value of the designated column as a stream of two-byte Unicode characters. This method is deprecated. Use getCharacterStream instead.
    • getUnicodeStream() accepts an integer representing the column index.
    • getUnicodeStream() returns null if the value is SQL NULL.
    • getUnicodeStream() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.
    • getUnicodeStream() throws an SQLFeatureNotSupportedException if the JDBC driver does not support this method.
    • getBinaryStream(int columnIndex) retrieves the value of the designated column as a stream of uninterpreted bytes.
    • getBinaryStream() accepts an integer representing the column index.
    • getBinaryStream() returns null if the value is SQL NULL.
    • getBinaryStream() throws an SQLException if an invalid columnIndex is provided, if a database access error occurs or this method is called on a closed result set.

    ResultSet Getter Methods with Column Labels

    • The getString(String columnLabel) method retrieves the value of the designated column in the current row of the ResultSet object as a String.
    • getString() accepts a String representing the column label specified with the SQL AS clause. If the AS clause was not specified, then the label is the name of the column.
    • getString() returns null if the value is SQL NULL.
    • getString() throws an SQLException if an invalid columnLabel is provided, if a database access error occurs or this method is called on a closed result set.
    • getBoolean(String columnLabel) retrieves the value of the designated column as a boolean in the Java programming language.
    • getBoolean() returns false if the column has a datatype of CHAR or VARCHAR and contains "0", or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT and contains 0.
    • getBoolean() returns true if the column has a datatype of CHAR or VARCHAR and contains "1" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT and contains 1.
    • getBoolean() accepts a String representing the column label.
    • getBoolean() returns false if the value is SQL NULL.
    • getBoolean() throws an SQLException if an invalid columnLabel is provided, if a database access error occurs or this method is called on a closed result set.
    • getByte(String columnLabel) retrieves the value of the designated column as a byte in Java.
    • getByte() accepts a String representing the column label.
    • getByte() returns 0 if the value is SQL NULL.
    • getByte() throws an SQLException if an invalid columnLabel is provided, if a database access error occurs or this method is called on a closed result set.
    • getShort(String columnLabel) retrieves the value of the designated column as a short in Java.
    • getShort() accepts a String representing the column label.
    • getShort() returns 0 if the value is SQL NULL.
    • getShort() throws an SQLException if an invalid columnLabel is provided, if a database access error occurs or this method is called on a closed result set.
    • getInt(String columnLabel) retrieves the value of the designated column as an int in Java.
    • getInt() accepts a String representing the column label.
    • getInt() returns 0 if the value is SQL NULL.
    • getInt() throws an SQLException if an invalid columnLabel is provided, if a database access error occurs or this method is called on a closed result set.
    • getLong(String columnLabel) retrieves the value of the designated column as a long in Java.
    • getLong() accepts a String representing the column label.
    • getLong() returns 0 if the value is SQL NULL.
    • getLong() throws an SQLException if an invalid columnLabel is provided, if a database access error occurs or this method is called on a closed result set.
    • getFloat(String columnLabel) retrieves the value of the designated column as a float in Java.
    • getFloat() accepts a String representing the column label.
    • getFloat() returns 0 if the value is SQL NULL.
    • getFloat() throws an SQLException if an invalid columnLabel is provided, if a database access error occurs or this method is called on a closed result set.
    • getDouble(String columnLabel) retrieves the value of the designated column as a double in Java.
    • getDouble() accepts a String representing the column label.
    • getDouble() returns 0 if the value is SQL NULL.
    • getDouble() throws an SQLException if an invalid columnLabel is provided, if a database access error occurs or this method is called on a closed result set.
    • getBigDecimal(String columnLabel, int scale) retrieves the value of the designated column as a java.math.BigDecimal in Java.
    • The getBigDecimal(String columnLabel, int scale) method is deprecated. Use getBigDecimal(int columnIndex) or getBigDecimal(String columnLabel) instead.
    • getBigDecimal() accepts a String representing the column label and a scale value.
    • getBigDecimal() returns null if the value is SQL NULL.
    • getBigDecimal() throws an SQLException if an invalid columnLabel is provided, if a database access error occurs or this method is called on a closed result set.
    • getBigDecimal() throws an SQLFeatureNotSupportedException if the JDBC driver does not support this method.

    ResultSet Methods

    • getAsciiStream retrieves the value of the designated column as a stream of ASCII characters.
    • getBinaryStream retrieves the value of the designated column as a stream of uninterpreted bytes.
    • getBigDecimal retrieves the value of the designated column as a java.math.BigDecimal with full precision.
    • getCharacterStream retrieves the value of the designated column as a java.io.Reader object.
    • getBytes retrieves the value of the designated column as a byte array in the Java programming language.
    • getDate retrieves the value of the designated column as a java.sql.Date object.
    • getMetaData retrieves the number, types, and properties of the ResultSet object's columns.
    • getObject retrieves the value of the designated column as an Object in the Java programming language.
    • getTime retrieves the value of the designated column as a java.sql.Time object.
    • getTimestamp retrieves the value of the designated column as a java.sql.Timestamp object.
    • getUnicodeStream is deprecated; use getCharacterStream instead.
    • getWarnings retrieves the first warning reported by calls on the ResultSet object.
    • clearWarnings clears all warnings reported on the ResultSet object.
    • findColumn maps the given ResultSet column label to its ResultSet column index.
    • getCursorName retrieves the name of the SQL cursor used by the ResultSet object.
    • isAfterLast retrieves whether the cursor is after the last row in the ResultSet object.
    • isBeforeFirst retrieves whether the cursor is before the first row in the ResultSet object.
    • isFirst retrieves whether the cursor is on the first row of the ResultSet object.
    • isLast retrieves whether the cursor is on the last row of the ResultSet object.
    • getString retrieves the value of the designated column as a String in the Java programming language.

    Methods Parameters

    • columnLabel is the label for the column specified with the SQL AS clause.
    • If the SQL AS clause was not specified, then the label is the name of the column.
    • columnIndex is the column index, starting from 1.

    Method Errors

    • SQLException is thrown if the columnLabel or columnIndex is invalid, a database access error occurs, or the method is called on a closed result set.
    • SQLFeatureNotSupportedException is thrown if the JDBC driver does not support the method.

    ResultSet Methods

    • beforeFirst(): Moves the cursor to the first position in the ResultSet. No effect if the ResultSet is empty.
    • afterLast() : Moves the cursor to the last position in the ResultSet. No effect if the ResultSet is empty.
    • first(): Moves the cursor to the first row of the ResultSet. Returns true if the cursor is on a valid row, false if the ResultSet is empty.
    • last(): Moves the cursor to the last row of the ResultSet. Returns true if the cursor is on a valid row, false if the ResultSet is empty.
    • getRow(): Retrieves the current row number. The first row is number 1.
    • absolute(int row): Moves the cursor to a specified row number. Positive row values count from the beginning, negative values count from the end, and 0 positions the cursor before the first row.
    • relative(int rows): Moves the cursor a relative number of rows, either positive or negative.
    • previous(): Moves the cursor to the previous row in the ResultSet. Returns true if the cursor is now on a valid row, false if the cursor is positioned before the first row.
    • setFetchDirection(int direction): Provides a hint to the JDBC driver about how rows should be processed. The fetch direction may be changed at any time.
    • getFetchDirection(): Retrieves the current fetch direction of the ResultSet.
    • setFetchSize(int rows): Hints to the JDBC driver how many rows should be fetched when more rows are needed.
    • getFetchSize(): Retrieves the current fetch size of the ResultSet.
    • getType(): Retrieves the type of the ResultSet. This is determined by the Statement object that creates the ResultSet.
    • getConcurrency(): Retrieves the concurrency mode of the ResultSet. This is determined by the Statement object that creates the ResultSet.
    • rowUpdated(): Retrieves whether the current row has been updated. This method is optional with a ResultSet concurrency of CONCUR_READ_ONLY.
    • rowInserted(): Retrieves whether the current row has been inserted. This method is optional with a ResultSet concurrency of CONCUR_READ_ONLY.
    • rowDeleted(): Retrieves whether the current row has been deleted. This method is optional with a ResultSet concurrency of CONCUR_READ_ONLY.
    • updateNull(int columnIndex): Updates the designated column with a null value. The update methods do not update the underlying database until updateRow or insertRow is called.
    • updateBoolean(int columnIndex, boolean x): Updates the designated column with a boolean value. The update methods do not update the underlying database until updateRow or insertRow is called.
    • updateByte(int columnIndex, byte x): Updates the designated column with a byte value. The update methods do not update the underlying database until updateRow or insertRow is called.

    Exception Handling

    • SQLException: Thrown when a database access error occurs, or if a method is called on a closed ResultSet.
    • SQLFeatureNotSupportedException: Thrown if the JDBC driver does not support the method.

    Additional Information

    • ResultSet.TYPE_FORWARD_ONLY: The ResultSet can only be navigated forward. Some methods related to navigation or row updates may be unsupported or behave differently with this type.
    • ResultSet.FETCH_FORWARD: Indicates that the rows in the ResultSet should be processed in forward order.
    • ResultSet.CONCUR_READ_ONLY: The ResultSet is read-only.
    • ResultSet.CONCUR_UPDATABLE: The ResultSet can be updated.
    • Statement.setFetchDirection(int direction): Allows setting the fetch direction for the Statement.
    • DatabaseMetaData.updatesAreDetected(int) : Reports whether visible updates are detected by the database.
    • DatabaseMetaData.insertsAreDetected(int) : Reports whether visible inserts are detected by the database.
    • DatabaseMetaData.deletesAreDetected(int) : Reports whether visible deletes are detected by the database.
    • insertRow(): Inserts the current row into the database.
    • updateRow(): Updates the row at the current position of the cursor.

    ResultSet Object

    • FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN: Used for setting the direction of processing rows in a result set.
    • TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE: Used for setting the type, determining cursor movement and sensitivity to data changes.
    • CONCUR_READ_ONLY, CONCUR_UPDATABLE: Used for setting the concurrency mode, which determines if data can be updated.
    • HOLD_CURSORS_OVER_COMMIT, CLOSE_CURSORS_AT_COMMIT: Used for setting the holdability, determining if open ResultSet objects remain open after commit.

    ResultSet.next() method

    • Moves cursor forward one row.
    • First call to next() makes the first row the current row, and so on.
    • When next() returns false, the cursor is after the last row.
    • SQLException is thrown if a current row is required but the cursor is not on a row.
    • For TYPE_FORWARD_ONLY result sets, whether next() returns false or throws an SQLException is vendor-specific.
    • An open input stream for the current row is implicitly closed.
    • The warning chain of ResultSet object is cleared when a new row is read.

    ResultSet.close() method

    • Releases resources associated with the ResultSet.
    • Blobs, Clobs, or NClobs created by the ResultSet stay open until the transaction in which they were created ends, unless their free method is invoked.
    • ResultSetMetaData instances created by getMetaData remain accessible.
    • Automatically called when the Statement that created it is closed, re-executed, or retrieves the next result from a sequence of multiple results.

    ResultSet.wasNull() method

    • Determines whether the last column accessed was SQL NULL.
    • Requires calling a getter method first followed by wasNull().

    Column Retrieval Methods

    • All getter methods for different data types (getString(), getInt(), etc.,) return null if the value is SQL NULL.
    • These methods take either a columnIndex (first column is 1) or a columnLabel (specified with SQL AS clause or the column name).
    • getBigDecimal() is deprecated in favor of using either getBigDecimal(int columnIndex) or getBigDecimal(String columnLabel).

    Stream Retrieval Methods

    • Provide access to data in a stream format.

    • Useful for retrieving large values like LONGVARCHAR or LONGVARBINARY.

    • The stream must be fully read before accessing any further data.

    • getCharacterStream() should be used instead of getUnicodeStream(), which is deprecated.

    • All stream methods implicitly close the stream upon calling another getter method.### ResultSet Methods for Data Retrieval

    • getByte(String columnLabel): Retrieves the designated column's value as a byte and returns it as a short. Returns 0 if the value is null.

    • getShort(String columnLabel): Retrieves the designated column's value as a short. Returns 0 if the value is null.

    • getInt(String columnLabel): Retrieves the designated column's value as an integer. Returns 0 if the value is null.

    • getLong(String columnLabel): Retrieves the designated column's value as a long. Returns 0 if the value is null.

    • getFloat(String columnLabel): Retrieves the designated column's value as a float. Returns 0 if the value is null.

    • getDouble(String columnLabel): Retrieves the designated column's value as a double. Returns 0 if the value is null.

    • getBigDecimal(String columnLabel, int scale): Retrieves the designated column's value as a BigDecimal with the specified scale. Returns null if the value is null.

    • getBytes(String columnLabel): Retrieves the designated column's value as a byte array. Returns null if the value is null.

    • getDate(String columnLabel): Retrieves the designated column's value as a java.sql.Date object. Returns null if the value is null.

    • getTime(String columnLabel): Retrieves the designated column's value as a java.sql.Time object. Returns null if the value is null.

    • getTimestamp(String columnLabel): Retrieves the designated column's value as a java.sql.Timestamp object. Returns null if the value is null.

    • getAsciiStream(String columnLabel): Retrieves the designated column's value as a stream of ASCII characters. Returns null if the value is null.

    • getUnicodeStream(String columnLabel): Retrieves the designated column's value as a stream of two-byte Unicode characters. Returns null if the value is null.

    • getBinaryStream(String columnLabel): Retrieves the designated column's value as a stream of uninterpreted bytes. Returns null if the value is null.

    • getObject(int columnIndex): Retrieves the designated column's value as an Object in Java, using the default Java object type based on the column's SQL type.

    • getObject(String columnLabel): Retrieves the designated column's value as an Object in Java, using the default Java object type based on the column's SQL type.

    • findColumn(String columnLabel): Maps the given column label to its corresponding index.

    • getCharacterStream(int columnIndex): Retrieves the designated column's value as a java.io.Reader object.

    • getCharacterStream(String columnLabel): Retrieves the designated column's value as a java.io.Reader object.

    • getBigDecimal(int columnIndex): Retrieves the designated column's value as a java.math.BigDecimal with full precision.

    Handling Errors

    • These methods throw an SQLException if the column label is invalid, a database access error occurs, or the method is called on a closed ResultSet.
    • The getBigDecimal(String columnLabel, int scale) method throws a SQLFeatureNotSupportedException if the JDBC driver does not support this method.

    ResultSet Properties

    • getWarnings(): Retrieves the first logged warning associated with the ResultSet.
    • clearWarnings(): Clears all warnings reported for the ResultSet.
    • getCursorName(): Retrieves the name of the SQL cursor used by the ResultSet object.
    • getMetaData(): Retrieves information about each column of the ResultSet, such as its name, type, and properties.

    Additional Notes

    • The columnLabel parameter refers to the column's name, which can be either the actual column name or an alias assigned using the SQL AS clause.
    • Most of these methods can be called with either a column index (starting from 1) or a column label.
    • When reading data from a stream, it is crucial to read all data before accessing other columns or methods. The next getter method call implicitly closes the stream.
    • These methods support reading both standard SQL data types and database-specific abstract data types.

    ResultSet Methods

    • Methods are used to interact with result sets from database queries, representing the data retrieved.
    • getBigDecimal method retrieves a value as a BigDecimal with full precision and returns null if the corresponding database value is NULL.
    • isBeforeFirst method checks if the cursor is before the first row - the method is optional for TYPE_FORWARD_ONLY result sets.
    • isAfterLast method checks if the cursor is after the last row - the method is optional for TYPE_FORWARD_ONLY result sets.
    • isFirst method checks if the cursor is on the first row - the method is optional for TYPE_FORWARD_ONLY result sets.
    • isLast method checks if the cursor is on the last row - the method might be expensive because it may need to fetch ahead one row to check.
    • beforeFirst method moves the cursor to the position before the first row, having no effect if the result set is empty - the method is optional for TYPE_FORWARD_ONLY result sets.
    • afterLast method moves the cursor to the position after the last row, having no effect if the result set is empty - the method is optional for TYPE_FORWARD_ONLY result sets.
    • first method moves the cursor to the first row and returns true if successful, or false if the result set is empty.
    • last method moves the cursor to the last row and returns true if successful, or false if the result set is empty.
    • getRow method retrieves the current row number.
    • absolute method moves the cursor to a specific row number, accepting positive or negative values relative to the beginning or end of the result set respectively - the method is optional for TYPE_FORWARD_ONLY result sets.
    • relative method moves the cursor a relative number of rows forward or backward, accepting a number of rows as parameter - the method is optional for TYPE_FORWARD_ONLY result sets.
    • previous method moves the cursor to the previous row and returns true if successful, or false if the cursor is already before the first row.
    • setFetchDirection method provides a hint to the database driver about the expected direction of row processing - the method is optional for TYPE_FORWARD_ONLY result sets.
    • getFetchDirection method retrieves the current fetch direction set for the result set.
    • setFetchSize method provides a hint to the database driver about the number of rows to fetch in batches - the method is optional for TYPE_FORWARD_ONLY result sets.
    • getFetchSize method retrieves the current fetch size set for the result set.
    • getType method retrieves the type of the result set, which is determined by the statement that generated it - the method can return TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE or TYPE_SCROLL_SENSITIVE.
    • getConcurrency method retrieves the concurrency mode of the result set.
    • rowUpdated method checks if the current row has been updated - the method is optional for CONCUR_READ_ONLY result sets.
    • rowInserted method checks if the current row has been newly inserted into the database - the method is optional for CONCUR_READ_ONLY result sets.
    • rowDeleted method checks if the current row has been deleted from the database - the method is optional for CONCUR_READ_ONLY result sets.
    • updateNull method updates the designated column of the current row to NULL.
    • updateBoolean method updates the designated column of the current row to a boolean value.
    • updateByte method updates the designated column of the current row to a byte value.
    • updateShort method updates the designated column of the current row to a short value.

    Updater methods

    • Updater methods are used to update column values in the current row or the insert row.

    • Updater methods do not update the underlying database; they are used to set new values to be used in the updateRow or insertRow methods.

    • The first column is 1, the second is 2, and so on.

    • These methods are called with a columnIndex (int) and a new x (value) as parameters.

    • Each method allows for updating the current row with a specific data type:

      • updateBoolean (boolean)
      • updateByte (byte)
      • updateShort (short)
      • updateInt (int)
      • updateLong (long )
      • updateFloat (float)
      • updateDouble (double)
      • updateBigDecimal (BigDecimal)
      • updateString (String)
      • updateBytes (byte[])
      • updateDate (Date)
      • updateTime (Time)
      • updateTimestamp (Timestamp)
      • updateAsciiStream (InputStream, int length)
      • updateBinaryStream (InputStream, int length)
      • updateCharacterStream (Reader, int length)
      • updateObject (Object, int scaleOrLength)
      • updateObject (Object)
      • updateNull (String columnLabel)
    • All methods throw an exception if:

      • The columnIndex is not valid.
      • A database access error occurs.
      • The result set concurrency is CONCUR_READ_ONLY.
      • The method is called on a closed result set.
      • The JDBC driver does not support the method (SQLFeatureNotSupportedException).
    • All methods were added in Java 1.2.### ResultSet Updater Methods

    • These methods update column values in the current row or insert row.

    • They do not update the underlying database; you must call updateRow or insertRow to update the database.

    • These methods throw a SQLException if the columnLabel is invalid, a database access error occurs, the result set concurrency is CONCUR_READ_ONLY, or the method is called on a closed result set.

    • They can also throw a SQLFeatureNotSupportedException if the JDBC driver does not support the method.

    updateFloat Method

    • Sets the designated column with a float value.

    updateDouble Method

    • Sets the designated column with a double value.

    updateBigDecimal Method

    • Sets the designated column with a java.sql.BigDecimal value.

    updateString Method

    • Sets the designated column with a String value.

    updateBytes Method

    • Sets the designated column with a byte[] value.

    updateDate Method

    • Sets the designated column with a java.sql. Date value.

    updateTime Method

    • Sets the designated column with a java.sql.Time value.

    updateTimestamp Method

    • Sets the designated column with a java.sql.Timestamp value.

    updateAsciiStream Method

    • Sets the designated column with an ascii stream value with specified number of bytes.

    updateBinaryStream Method

    • Sets the designated column with a binary stream value with specified number of bytes.

    updateCharacterStream Method

    • Sets the designated column with a character stream value with specified number of bytes.

    updateObject Method

    • Sets the designated column with an Object value.
    • If the second argument is an InputStream, the stream must contain the number of bytes specified by scaleOrLength.
    • If the second argument is a Reader, the reader must contain the number of characters specified by scaleOrLength.
    • If these conditions are not true, the driver will generate a SQLException when the statement is executed.

    insertRow Method

    • Inserts the contents of the insert row into the ResultSet object and into the database.
    • The cursor must be on the insert row when this method is called.

    updateRow Method

    • Updates the underlying database with the new contents of the current row of the ResultSet.
    • This method cannot be called when the cursor is on the insert row.

    deleteRow Method

    • Deletes the current row from the ResultSet object and from the underlying database.
    • This method cannot be called when the cursor is on the insert row.

    refreshRow Method

    • 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.
    • It provides a way for an application to explicitly tell the JDBC driver to refetch a row(s) from the database.
    • The JDBC driver may actually refresh multiple rows at once if the fetch size is greater than one.
    • All values are refetched subject to the transaction isolation level and cursor sensitivity.
    • If refreshRow is called after calling an updater method, but before calling the updateRow method, then the updates made to the row are lost.
    • Calling the refreshRow method frequently will likely slow performance.

    ResultSet Updater Methods

    • Methods are used to update values in the current row or insert row
    • Do not update underlying database - instead, updateRow or insertRow methods must be called to update database
    • Methods throw an exception if you call them on a closed result set, the result set concurrency is CONCUR_READ_ONLY, or the columnIndex is not valid
    • Methods throw an exception if there is a database access error or the driver does not support the method

    updateBytes

    • Takes columnIndex and byte[] as arguments
    • Updates designated column with a byte array value

    updateDate

    • Takes columnIndex and Date as arguments
    • Updates designated column with a java.sql.Date value

    updateTime

    • Takes columnIndex and Time as arguments
    • Updates designated column with a java.sql.Time value

    updateTimestamp

    • Takes columnIndex and Timestamp as arguments
    • Updates designated column with a java.sql.Timestamp value

    updateAsciiStream

    • Takes columnIndex, InputStream, and length as arguments
    • Updates designated column with an ascii stream value of specified length

    updateBinaryStream

    • Takes columnIndex, InputStream, and length as arguments
    • Updates designated column with a binary stream value of specified length

    updateCharacterStream

    • Takes columnIndex, Reader, and length as arguments
    • Updates designated column with a character stream value of specified length

    updateObject

    • Takes columnIndex, Object, and scaleOrLength as arguments
    • Updates designated column with an Object value - if the Object is an InputStream or Reader then the stream or reader must contain the number of bytes or characters specified in the scaleOrLength parameters
    • Takes columnIndex and Object as arguments
    • Updates designated column with an Object value

    updateNull

    • Takes columnLabel as arguments
    • Updates the designated column with a null value

    updateBoolean

    • Takes columnLabel and boolean as arguments
    • Updates the designated column with a boolean value

    updateByte

    • Takes columnLabel and byte as arguments
    • Updates designated column with a byte value

    updateShort

    • Takes columnLabel and short as arguments
    • Updates designated column with a short value

    updateInt

    • Takes columnLabel and int as arguments
    • Updates designated column with an int value

    updateLong

    • Takes columnLabel and long as arguments
    • Updates designated column with a long value

    updateFloat

    • Takes columnLabel and float as arguments
    • Updates designated column with a float value

    updateDouble

    • Takes columnLabel and double as arguments
    • Updates designated column with a double value

    updateBigDecimal

    • Takes columnLabel and BigDecimal as arguments
    • Updates designated column with a java.sql.BigDecimal value

    updateString

    • Takes columnLabel and String as arguments
    • Updates designated column with a String value

    ResultSet Interface Methods

    • The ResultSet interface represents a database result set, allowing you to retrieve and manipulate data.
    • The ResultSet object is created by executing a Statement object, which can be used to execute SQL queries.
    • The ResultSet object provides methods to move through the result set, access data using labels or column indices, and update database content.
    • updateXXX methods are used to change data in the current row, which is then updated using the updateRow method.
    • Data is updated within the result set and does not automatically update the underlying database.
    • The updateXXX methods do not directly modify the database; instead, they modify the content within the ResultSet object.
    • The insertRow method inserts the contents of the insert row into the ResultSet object and the database.
    • The deleteRow method removes the current row from the ResultSet object and the database.
    • The refreshRow method refetches the latest data for the current row from the database, as if it had been newly retrieved.
    • The cancelRowUpdates method discards any changes made to the current row since it was last read from the database.
    • The moveToInsertRow method places the cursor on a special "insert row", allowing for data to be prepared to be inserted into the database.
    • The moveToCurrentRow method moves the cursor back to the original position after working with the insert row.
    • The getStatement method retrieves the Statement object that produced this ResultSet object. If the result set was generated some other way, such as by a DatabaseMetaData method, then this method can potentially return null.
    • The getObject method retrieves the value of the designated column as an Object in the Java programming language.
    • The getRef, getBlob, getClob, and getArray methods retrieve data from the current row and return it as a Ref, Blob, Clob, or Array object, respectively.
    • The getDate method retrieves the value of the designated column as a java.sql.Date object in the Java programming language. This method uses the given calendar to construct an appropriate millisecond value for the date if the underlying database does not store timezone information.

    ResultSet Methods

    • getByte(int columnIndex): Retrieves the value of the designated column in the current row as a Java byte.
    • getByte(String columnLabel): Retrieves the value of the designated column in the current row as a Java byte.
    • getShort(int columnIndex): Retrieves the value of the designated column in the current row as a Java short.
    • getShort(String columnLabel): Retrieves the value of the designated column in the current row as a Java short.
    • getInt(int columnIndex): Retrieves the value of the designated column in the current row as a Java integer.
    • getInt(String columnLabel): Retrieves the value of the designated column in the current row as a Java integer.
    • getLong(int columnIndex): Retrieves the value of the designated column in the current row as a Java long.
    • getLong(String columnLabel): Retrieves the value of the designated column in the current row as a Java long.
    • getFloat(int columnIndex): Retrieves the value of the designated column in the current row as a Java float.
    • getFloat(String columnLabel): Retrieves the value of the designated column in the current row as a Java float.
    • getDouble(int columnIndex): Retrieves the value of the designated column in the current row as a Java double.
    • getDouble(String columnLabel): Retrieves the value of the designated column in the current row as a Java double.
    • getBigDecimal(int columnIndex): Retrieves the value of the designated column in the current row as a Java BigDecimal.
    • getBigDecimal(String columnLabel): Retrieves the value of the designated column in the current row as a Java BigDecimal.
    • getString(int columnIndex): Retrieves the value of the designated column in the current row as a Java String.
    • getString(String columnLabel): Retrieves the value of the designated column in the current row as a Java String.
    • getBytes(int columnIndex): Retrieves the value of the designated column in the current row as a Java array of bytes.
    • getBytes(String columnLabel): Retrieves the value of the designated column in the current row as a Java array of bytes.
    • getDate(int columnIndex): Retrieves the value of the designated column in the current row as a java.sql.Date object.
    • getDate(int columnIndex, Calendar cal): Retrieves the value of the designated column in the current row as a java.sql.Date object. Uses a Calendar object to construct an appropriate millisecond value for the date if the underlying database does not store timezone information.
    • getDate(String columnLabel): Retrieves the value of the designated column in the current row as a java.sql.Date object.
    • getDate(String columnLabel, Calendar cal): Retrieves the value of the designated column in the current row as a java.sql.Date object. Uses a Calendar object to construct an appropriate millisecond value for the date if the underlying database does not store timezone information.
    • getTime(int columnIndex): Retrieves the value of the designated column in the current row as a java.sql.Time object.
    • getTime(int columnIndex, Calendar cal): Retrieves the value of the designated column in the current row as a java.sql.Time object. Uses a Calendar object to construct an appropriate millisecond value for the time if the underlying database does not store timezone information.
    • getTime(String columnLabel): Retrieves the value of the designated column in the current row as a java.sql.Time object.
    • getTime(String columnLabel, Calendar cal): Retrieves the value of the designated column in the current row as a java.sql.Time object. Uses a Calendar object to construct an appropriate millisecond value for the time if the underlying database does not store timezone information.
    • getTimestamp(int columnIndex): Retrieves the value of the designated column in the current row as a java.sql.Timestamp object.
    • getTimestamp(int columnIndex, Calendar cal): Retrieves the value of the designated column in the current row as a java.sql.Timestamp object. Uses a Calendar object to construct an appropriate millisecond value for the timestamp if the underlying database does not store timezone information.
    • getTimestamp(String columnLabel): Retrieves the value of the designated column in the current row as a java.sql.Timestamp object.
    • getTimestamp(String columnLabel, Calendar cal): Retrieves the value of the designated column in the current row as a java.sql.Timestamp object. Uses a Calendar object to construct an appropriate millisecond value for the timestamp if the underlying database does not store timezone information.
    • getURL(int columnIndex): Retrieves the value of the designated column in the current row as a java.net.URL object.
    • getURL(String columnLabel): Retrieves the value of the designated column in the current row as a java.net.URL object.
    • updateRef(int columnIndex, Ref x): Updates the designated column with a java.sql.Ref value.
    • updateRef(String columnLabel, Ref x): Updates the designated column with a java.sql.Ref value.
    • updateBlob(int columnIndex, Blob x): Updates the designated column with a java.sql.Blob value.
    • updateBlob(String columnLabel, Blob x): Updates the designated column with a java.sql.Blob value.
    • updateClob(int columnIndex, Clob x): Updates the designated column with a java.sql.Clob value.
    • updateClob(String columnLabel, Clob x): Updates the designated column with a java.sql.Clob value.
    • updateArray(int columnIndex, Array x): Updates the designated column with a java.sql.Array value.
    • updateArray(String columnLabel, Array x): Updates the designated column with a java.sql.Array value.
    • getRowId(int columnIndex): Retrieves the value of the designated column in the current row as a java.sql.RowId object.
    • getRowId(String columnLabel): Retrieves the value of the designated column in the current row as a java.sql.RowId object.
    • updateRowId(int columnIndex, RowId x): Updates the designated column with a RowId value.
    • updateRowId(String columnLabel, RowId x): Updates the designated column with a RowId value.
    • getHoldability(): Retrieves the holdability of this ResultSet object.
    • isClosed(): Retrieves whether this ResultSet object has been closed.
    • updateNString(int columnIndex, String nString): Updates the designated column with a String value.
    • updateNString(String columnLabel, String nString): Updates the designated column with a String value.
    • updateNClob(int columnIndex, NClob nClob): Updates the designated column with a java.sql.NClob value.
    • updateNClob(String columnLabel, NClob nClob): Updates the designated column with a java.sql.NClob value.

    Notes about ResultSet

    • The label of the column is used when referencing columns by name using the SQL AS clause, if not specified it defaults to the name of the column.

    • The result set concurrency is CONCUR_READ_ONLY if the result set is read-only.

    • The updateRow method commits the changes to the database.

    • The insertRow method inserts a new row into the database.

    • The updateRow and insertRow methods are used to update the database.

    • The updateRow and insertRow methods are called to update the database.

    • The getHoldability() method returns either ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT.

    • The isClosed() method returns true if the ResultSet object is closed and false if it is still open.

    • The updateNString() and updateNClob() methods are intended for use when updating NCHAR, NVARCHAR, and LONGNVARCHAR columns.### ResultSet Updates

    • Updating a ResultSet is a multi-step process:

      • Update methods modify the data within the ResultSet, not the database itself.
      • updateRow or insertRow methods are used to apply the modifications to the underlying database.
    • updateNClob(String columnLabel, NClob nClob)

      • Updates a column with a java.sql.NClob value.
      • The columnLabel argument can be the column name itself or the label defined by the SQL AS clause.
      • Throws an SQLException if the columnLabel is invalid, the driver doesn't support national character sets, a data conversion error is detected, the result set is closed, or a database access error occurs.
      • Additionally throws SQLFeatureNotSupportedException if the JDBC driver doesn't support the method.
    • updateSQLXML(int columnIndex, SQLXML xmlObject)

      • Updates a column with a java.sql.SQLXML value.
      • The columnIndex argument starts at 1 for the first column, 2 for the second, and so on.
      • Throws SQLException for invalid column index, database access errors, errors processing the XML value, or if the result set is closed.
      • Also throws SQLFeatureNotSupportedException if the driver doesn't support the method.
    • updateNCharacterStream(String columnLabel, Reader reader, long length)

      • Updates a column with a character stream value.
      • The length argument specifies the number of bytes in the stream.
      • It's used for updating NCHAR, NVARCHAR, and LONGNVARCHAR columns.
      • Throws SQLException for invalid column label, database access errors, or if the result set is closed.
      • Also throws SQLFeatureNotSupportedException if the driver doesn't support the method.
    • updateAsciiStream(int columnIndex, InputStream x, long length)

      • Updates a column with an ascii stream value.
      • The length argument defines the number of bytes in the stream.
      • Throws SQLException for invalid column index, database access errors, or if the result set is closed.
      • Also throws SQLFeatureNotSupportedException if the driver doesn't support the method.
    • updateBinaryStream(String columnLabel, InputStream x, long length)

      • Updates a column with a binary stream value.
      • The length argument specifies the number of bytes in the stream.
      • Throws SQLException for invalid column label, database access errors, or if the result set is closed.
      • Also throws SQLFeatureNotSupportedException if the driver doesn't support the method.
    • updateCharacterStream(String columnLabel, Reader reader, long length)

      • Updates a column with a character stream value.
      • The length argument defines the number of bytes in the stream.
      • Throws SQLException for invalid columnLabel, database access errors, or if the result set is closed.
      • Also throws SQLFeatureNotSupportedException if the driver doesn't support the method.
    • updateBlob(int columnIndex, InputStream inputStream, long length)

      • Updates a column using a given input stream.
      • The length argument specifies the number of bytes in the stream.
      • Throws SQLException for invalid column index, database access errors, or if the result set is closed.
      • Also throws SQLFeatureNotSupportedException if the driver doesn't support the method.

    ResultSet Retrieving Data

    • getNClob(String columnLabel)
      • Retrieves a value from the current row as a java.sql.NClob object.
      • The columnLabel argument can be the column name or the label defined in the SQL AS clause.
      • Throws SQLException for invalid columnLabel, database access errors, or if the result set is closed.
      • Also throws SQLFeatureNotSupportedException if the driver doesn't support the method.
    • getSQLXML(int columnIndex)
      • Retrieves a value from the current row as a java.sql.SQLXML object.
      • The columnIndex argument starts from 1, with 2 for the second column, and so on.
      • Throws SQLException for invalid column index, database access errors, or if the result set is closed.
      • Also throws SQLFeatureNotSupportedException if the driver doesn't support the method.
    • getNString(String columnLabel)
      • Retrieves a value from the current row as a java.lang.String object.
      • The columnLabel argument can be the column name or the label defined in the SQL AS clause.
      • Used for retrieving data from NCHAR, NVARCHAR, and LONGNVARCHAR columns.
      • Throws SQLException for invalid columnLabel, database access errors, or if the result set is closed.
      • Also throws SQLFeatureNotSupportedException if the driver doesn't support the method.
    • getNCharacterStream(int columnIndex)
      • Retrieves a value from the current row as a java.io.Reader object.
      • The columnIndex argument starts from 1, with 2 for the second column, and so on.
      • Used for retrieving data from NCHAR, NVARCHAR, and LONGNVARCHAR columns.
      • Throws SQLException for invalid column index, database access errors, or if the result set is closed.
      • Also throws SQLFeatureNotSupportedException if the driver doesn't support the method.

    Updating ResultSet Data

    • ResultSet objects can be used to update data in a database in a row-by-row manner

    • Update methods are available for various data types including:

      • updateBlob() - for updating BLOB columns using an InputStream object
      • updateClob() - for updating CLOB columns using a Reader object
      • updateNClob() - for updating NCLOB columns using a Reader object
      • updateNCharacterStream() - for updating NCHAR, NVARCHAR and LONGNVARCHAR columns using a Reader object
      • updateAsciiStream() - for updating columns using an InputStream object
      • updateBinaryStream() - for updating columns using an InputStream object
      • updateCharacterStream() - for updating columns using a Reader object
    • updateRow() or insertRow() methods are then used to apply the updates to the actual database

    • All updater methods are not available for ResultSet objects that have CONCUR_READ_ONLY concurrency

    Updating with Input/Reader Objects

    • updateBlob() methods take an InputStream object as input, which contains the complete data for the corresponding column

    • updateClob() and updateNClob() methods take a Reader object as input, which contains the character data for the corresponding column

    • Each updateXyz() method provides two versions:

      • One version uses the column index, starting from 1
      • The other version uses the column label, which can be specified in the SQL query using the AS clause
    • In all update() methods, length (number of bytes/characters) can be specified as a parameter, making it more efficient for handling large data

    • If no length is specified, the entire contents of the InputStream or Reader object will be read

    Handling Large Data

    • When dealing with large amounts of data, particularly BLOB and CLOB values, using InputStream and Reader objects is more efficient than storing the data directly in memory
    • The JDBC driver handles reading the data from the stream as needed, reducing memory usage

    Updating Columns with Streams

    • When updating columns using streams, the entire contents of the stream are read until the end-of-stream is reached
    • If the driver supports it, there might be more efficient versions of updateXyz() methods that take a length parameter

    Example Code - Updating a Blob Column

    // Update a Blob column using InputStream
    ResultSet resultSet = ... ; 
    InputStream inputStream = ... ;
    int columnIndex = 3;
    
    // Set the Blob data
    resultSet.updateBlob(columnIndex, inputStream);
    
    // Apply the update to the database
    resultSet.updateRow();
    

    ResultSet Updater Methods

    • These methods are used to update column values in the current row or the insert row.
    • They do not update the underlying database; instead, updateRow or insertRow methods are called to update the database.
    • The methods take a columnIndex or columnLabel as input, indicating the column to be updated.
    • The methods throw SQLException if the provided columnIndex or columnLabel is invalid, or if a database access error occurs.
    • They also throw SQLException if the result set concurrency is CONCUR_READ_ONLY or the method is called on a closed result set.
    • If the JDBC driver does not support the method, it throws a SQLFeatureNotSupportedException.

    Updater Methods for Different Data Types

    • The updateBytes method updates a column with a byte array value.
    • The updateDate method updates a column with a java.sql.Date value.
    • The updateTime method updates a column with a java.sql.Time value.
    • The updateTimestamp method updates a column with a java.sql.Timestamp value.
    • The updateAsciiStream method updates a column with an ASCII stream value, taking a stream and its specified length.
    • The updateBinaryStream method updates a column with a binary stream value, taking a stream and its specified length.
    • The updateCharacterStream method updates a column with a character stream value, taking a reader and its specified length.
    • The updateObject method updates a column with an object value, taking the object, and an optional scaleOrLength parameter depending on the object type (e.g., BigDecimal, InputStream, Reader).
    • The updateNull method updates a column with a null value, taking the columnLabel as input.
    • The updateBoolean method updates a column with a boolean value, taking the columnLabel and the boolean value.
    • The updateByte, updateShort, updateInt, updateLong, updateFloat, updateDouble, updateBigDecimal, and updateString methods update a column with corresponding data type values, taking a columnLabel and the value as input.
    • All these methods have versions that take a columnIndex and the value as input, similar to the ones described above.
    • These methods are generally used to update individual column values, but can also be applied to insert rows.

    ResultSet Updaters

    • Update methods are used to change values for the current or insert rows, but do not update the database itself.
    • updateRow() updates the database with the changes made in the current row.
    • insertRow() inserts the values from the insert row into the database.
    • moveToInsertRow() moves the cursor to the insert row allowing for a new row to be constructed.
    • moveToCurrentRow() returns the cursor back to the remembered position usually the current row.
    • cancelRowUpdates() rolls back updates made to the current row.

    Getters

    • Getters allow you to access values from within the ResultSet at a specific column.
    • When calling the SQL AS clause, the label is the name of the column.
    • getStatement() returns the Statement that produced the ResultSet, or null if produced in another way.
    • getObject() returns an Object representing the SQL value in the specified column.
    • getRef() returns a Ref object representing the SQL REF value.
    • getBlob() returns a Blob object representing the SQL BLOB value.
    • getClob() returns a Clob object representing the SQL CLOB value.
    • getArray() returns an Array object representing the SQL ARRAY value.
    • getDate() returns a Date object representing the SQL Date value.

    Exceptions

    • SQLException will be thrown if:
      • The columnLabel is invalid.
      • A database access error occurs.
      • The result set concurrency is CONCUR_READ_ONLY.
      • The method is called on a closed result set.
    • SQLFeatureNotSupportedException will be thrown if the JDBC driver does not support the called method.

    ResultSet Methods

    • getDate() retrieves the value of a designated column as a java.sql.Date object.
      • Accepts a columnIndex or a columnLabel as parameters.
      • If no SQL AS clause was defined, the column label is the name of the column.
      • Returns null if the value is SQL NULL.
      • Throws an SQLException if the column is not valid, a database error occurs, or the method is called on a closed ResultSet.
    • getTime() retrieves the value of a designated column as a java.sql.Time object.
      • Accepts a columnIndex, a columnLabel, and a Calendar object.
      • Uses the given Calendar object to construct an appropriate millisecond value if the underlying database doesn't store timezone information.
      • Returns null if the value is SQL NULL.
      • Throws an SQLException if the column is not valid, a database error occurs, or the method is called on a closed ResultSet.
    • getTimestamp() retrieves the value of a designated column as a java.sql.Timestamp object.
      • Accepts a columnIndex, a columnLabel, and a Calendar object.
      • Uses the given Calendar object to construct an appropriate millisecond value if the underlying database doesn't store timezone information.
      • Returns null if the value is SQL NULL.
      • Throws an SQLException if the column is not valid, a database error occurs, or the method is called on a closed ResultSet.
    • getURL() retrieves the value of a designated column as a java.net.URL object.
      • Accepts a columnIndex or a columnLabel.
      • Returns null if the value is SQL NULL.
      • Throws an SQLException if the column is not valid, a database error occurs, the ResultSet is closed, or the URL is malformed.
      • Throws an SQLFeatureNotSupportedException if the JDBC driver doesn't support this method.
    • updateRef() updates the designated column with a java.sql.Ref value.
      • Accepts a columnIndex or a columnLabel and a Ref object.
      • Doesn't update the database directly; updateRow or insertRow methods are used for that purpose.
      • Throws an SQLException if the column is not valid, a database error occurs, the ResultSet concurrency is CONCUR_READ_ONLY, or the method is called on a closed ResultSet.
      • Throws an SQLFeatureNotSupportedException if the JDBC driver doesn't support this method.
    • updateBlob() updates the designated column with a java.sql.Blob value.
      • Accepts a columnIndex or a columnLabel and a Blob object.
      • Doesn't update the database directly; updateRow or insertRow methods are used for that purpose.
      • Throws an SQLException if the column is not valid, a database error occurs, the ResultSet concurrency is CONCUR_READ_ONLY, or the method is called on a closed ResultSet.
      • Throws an SQLFeatureNotSupportedException if the JDBC driver doesn't support this method.
    • updateClob() updates the designated column with a java.sql.Clob value.
      • Accepts a columnIndex or a columnLabel and a Clob object.
      • Doesn't update the database directly; updateRow or insertRow methods are used for that purpose.
      • Throws an SQLException if the column is not valid, a database error occurs, the ResultSet concurrency is CONCUR_READ_ONLY, or the method is called on a closed ResultSet.
      • Throws an SQLFeatureNotSupportedException if the JDBC driver doesn't support this method.
    • updateArray() updates the designated column with a java.sql.Array value.
      • Accepts a columnIndex or a columnLabel and an Array object.
      • Doesn't update the database directly; updateRow or insertRow methods are used for that purpose.
      • Throws an SQLException if the column is not valid, a database error occurs, the ResultSet concurrency is CONCUR_READ_ONLY, or the method is called on a closed ResultSet.
      • Throws an SQLFeatureNotSupportedException if the JDBC driver doesn't support this method.
    • getRowId() retrieves the value of a designated column as a java.sql.RowId object.
      • Accepts a columnIndex or a columnLabel.
      • Returns null if the value is SQL NULL.
      • Throws an SQLException if the column is not valid, a database error occurs, or the method is called on a closed ResultSet.
      • Throws an SQLFeatureNotSupportedException if the JDBC driver doesn't support this method.
    • updateRowId() updates the designated column with a RowId value.
      • Accepts a columnIndex or a columnLabel and a RowId object.
      • Doesn't update the database directly; updateRow or insertRow methods are used for that purpose.
      • Throws an SQLException if the column is not valid, a database error occurs, the ResultSet concurrency is CONCUR_READ_ONLY, or the method is called on a closed ResultSet.
      • Throws an SQLFeatureNotSupportedException if the JDBC driver doesn't support this method.
    • getHoldability() retrieves the holdability of a ResultSet.
      • Returns ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT.
      • Throws an SQLException if a database error occurs, or the method is called on a closed ResultSet.
    • isClosed() checks if a ResultSet has been closed.
      • Returns true if the ResultSet is closed, otherwise returns false.
      • Throws an SQLException if a database error occurs.
    • updateNString() updates the designated column with a String value, mainly for updating NCHAR, NVARCHAR, and LONGNVARCHAR columns.
      • Accepts a columnIndex or a columnLabel and a String object.
      • Doesn't update the database directly; updateRow or insertRow methods are used for that purpose.
      • Throws an SQLException if the column is not valid, the driver doesn't support national character sets, the driver detects a potential data conversion error, the method is called on a closed ResultSet, the ResultSet concurrency is CONCUR_READ_ONLY, or a database error occurs.
      • Throws an SQLFeatureNotSupportedException if the JDBC driver doesn't support this method.
    • updateNClob() updates the designated column with a java.sql.NClob value.
      • Accepts a columnIndex or a columnLabel, and a NClob object.
      • Doesn't update the database directly; updateRow or insertRow methods are used for that purpose.
      • Throws an SQLException if the column is not valid, a database error occurs, the ResultSet concurrency is CONCUR_READ_ONLY, or the method is called on a closed ResultSet.
      • Throws an SQLFeatureNotSupportedException if the JDBC driver doesn't support this method.

    ResultSet Methods

    • updateNClob(String columnLabel, NClob nClob): Updates a column in the current row or insert row with a java.sql.NClob value.
    • getNClob(int columnIndex): Retrieves the value of the designated column in the current row as a NClob object.
    • getNClob(String columnLabel): Retrieves the value of a column using its label as a NClob object.
    • getSQLXML(int columnIndex): Retrieves the value of a column by its index as a java.sql.SQLXML object.
    • getSQLXML(String columnLabel): Retrieves the value of a column by its label as a java.sql.SQLXML object.
    • updateSQLXML(int columnIndex, SQLXML xmlObject): Updates the value of a column with a java.sql.SQLXML object.
    • updateSQLXML(String columnLabel, SQLXML xmlObject): Updates the value of a column with a java.sql.SQLXML object using its label.
    • getNString(int columnIndex): Retrieves the value of a column, intended for use with NCHAR, NVARCHAR, and LONGNVARCHAR columns, as a String object.
    • getNString(String columnLabel): Retrieves the value of a column, intended for use with NCHAR, NVARCHAR, and LONGNVARCHAR columns, as a String object using its label.
    • getNCharacterStream(int columnIndex): Retrieves the value of a column as a java.io.Reader object, intended for use with NCHAR, NVARCHAR, and LONGNVARCHAR columns.
    • getNCharacterStream(String columnLabel): Retrieves the value of a column as a java.io.Reader object using its label, intended for use with NCHAR, NVARCHAR, and LONGNVARCHAR columns.
    • updateNCharacterStream(int columnIndex, Reader x, long length): Updates the value of a column using a Reader object, intended for use with NCHAR, NVARCHAR, and LONGNVARCHAR columns.
    • updateNCharacterStream(String columnLabel, Reader reader, long length): Updates the value of a column using a Reader object and its label, intended for use with NCHAR, NVARCHAR, and LONGNVARCHAR columns.

    Updating Columns

    • updateAsciiStream(int columnIndex, InputStream x, long length), updateAsciiStream(String columnLabel, InputStream x, long length): Updates a column with an ASCII stream using an InputStream object.
    • updateBinaryStream(int columnIndex, InputStream x, long length), updateBinaryStream(String columnLabel, InputStream x, long length): Updates a column with a binary stream using an InputStream object.
    • updateCharacterStream(int columnIndex, Reader x, long length), updateCharacterStream(String columnLabel, Reader reader, long length): Updates a column with a character stream using a Reader object.
    • updateBlob(int columnIndex, InputStream inputStream, long length): Updates a column with a BLOB value using an InputStream object.

    Exceptions

    • SQLException: Thrown for errors related to invalid column indices, unsupported features, data conversion errors, closed result sets, database access errors, or read-only result set concurrencies.
    • SQLFeatureNotSupportedException: Thrown if the JDBC driver does not support the specific method.

    Notes

    • The update methods update column values on the current row or insert row.
    • They don't update the database directly; you need to call updateRow or insertRow to apply changes.
    • The get methods retrieve values from the current row.
    • Java character format is converted to the database's national character set by the driver.
    • The length parameter in update methods specifies the length of the stream.

    JDBC Updater Methods

    • updateBlob(): Updates a designated column using an input stream. This method is used to update column values in the current row or the insert row.

      • Parameters:
        • columnIndex: The column index, starting from 1.
        • columnLabel: The label for the column, specified with the SQL AS clause. If not specified, the label is the column name.
        • inputStream: An object that contains the data to set the parameter value to.
        • length: The number of bytes in the parameter data. This parameter is optional and can be omitted.
      • Throws:
        • SQLException: If the columnIndex or columnLabel is invalid, a database access error occurs, the result set concurrency is CONCUR_READ_ONLY, or the method is called on a closed result set.
        • SQLFeatureNotSupportedException: If the JDBC driver does not support this method.
    • updateClob(): Updates a designated column using a Reader object. This method is used for updating columns with large UNICODE values.

      • Parameters:
        • columnIndex: The column index, starting from 1.
        • columnLabel: The label for the column, specified with the SQL AS clause. If not specified, the label is the column name.
        • reader: An object that contains the data to set the parameter value to.
        • length: The number of characters in the parameter data. This parameter is optional and can be omitted.
      • Throws:
        • SQLException: If the columnIndex or columnLabel is invalid, a database access error occurs, the result set concurrency is CONCUR_READ_ONLY, or the method is called on a closed result set.
        • SQLFeatureNotSupportedException: If the JDBC driver does not support this method.
    • updateNClob(): Updates a designated column using a Reader object with national character support.

      • Parameters:
        • columnIndex: The column index, starting from 1.
        • columnLabel: The label for the column, specified with the SQL AS clause. If not specified, the label is the column name.
        • reader: An object that contains the data to set the parameter value to.
        • length: The number of characters in the parameter data. This parameter is optional and can be omitted.
        • Throws:
          • SQLException: If the columnIndex or columnLabel is invalid, the driver does not support national character sets, a data conversion error could occur, the method is called on a closed result set, or a database access error occurs.
          • SQLFeatureNotSupportedException: If the JDBC driver does not support this method.
    • updateNCharacterStream(): Updates a designated column with a character stream value.

      • Parameters:
        • columnIndex: The column index, starting from 1.
        • columnLabel: The label for the column, specified with the SQL AS clause. If not specified, the label is the column name.
        • x: The new column value.
      • Throws:
        • SQLException: If the columnIndex or columnLabel is invalid, a database access error occurs, the result set concurrency is CONCUR_READ_ONLY, or the method is called on a closed result set.
        • SQLFeatureNotSupportedException: If the JDBC driver does not support this method.
    • updateAsciiStream(): Updates a designated column with an ASCII stream value.

      • Parameters:
        • columnIndex: The column index, starting from 1.
        • columnLabel: The label for the column, specified with the SQL AS clause. If not specified, the label is the column name.
        • x: The new column value.
      • Throws:
        • SQLException: If the columnIndex or columnLabel is invalid, a database access error occurs, the result set concurrency is CONCUR_READ_ONLY, or the method is called on a closed result set.
        • SQLFeatureNotSupportedException: If the JDBC driver does not support this method.
    • updateBinaryStream(): Updates a designated column with a binary stream value.

      • Parameters:
        • columnIndex: The column index, starting from 1.
        • columnLabel: The label for the column, specified with the SQL AS clause. If not specified, the label is the column name.
        • x: The new column value.
      • Throws:
        • SQLException: If the columnIndex or columnLabel is invalid, a database access error occurs, the result set concurrency is CONCUR_READ_ONLY, or the method is called on a closed result set.
        • SQLFeatureNotSupportedException: If the JDBC driver does not support this method.
    • updateCharacterStream(): Updates a designated column with a character stream value.

      • Parameters:
        • columnIndex: The column index, starting from 1.
        • columnLabel: The label for the column, specified with the SQL AS clause. If not specified, the label is the column name.
        • x: The new column value.
      • Throws:
        • SQLException: If the columnIndex or columnLabel is invalid, a database access error occurs, the result set concurrency is CONCUR_READ_ONLY, or the method is called on a closed result set.
        • SQLFeatureNotSupportedException: If the JDBC driver does not support this method.
    • Key Points:

      • The updater methods do not directly update the database. The updateRow() or insertRow() methods are required for database updates.
      • Each updater method has a version that takes both the columnIndex and the columnLabel as parameters.
      • Most updater methods have a version that takes a length parameter for efficiency.
      • These methods offer flexibility to update columns with various data types and large data volumes.

    Update Methods

    • updateRow(): Applies the changes made to the current row of the ResultSet to the database.

      • Throws:
        • SQLException: If the result set concurrency is CONCUR_READ_ONLY, the method is called on a closed result set, or a database access error occurs.
    • insertRow(): Inserts the data in the insert row of the ResultSet into the database.

      • Throws:
        • SQLException: If the result set concurrency is CONCUR_READ_ONLY, the method is called on a closed result set, or a database access error occurs.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Test your knowledge of JDBC ResultSet concepts! This quiz covers the initial cursor position, methods for navigating rows, types of ResultSet, and best practices for data retrieval using getter methods. Perfect for students and professionals looking to enhance their understanding of JDBC.

    More Like This

    JDBC Drivers Quiz
    10 questions

    JDBC Drivers Quiz

    ArticulateVibrance avatar
    ArticulateVibrance
    ResultSet Interface Quiz
    40 questions

    ResultSet Interface Quiz

    CommendableLightYear avatar
    CommendableLightYear
    Use Quizgecko on...
    Browser
    Browser