What are the different methods of ResultSet?

We have seen earlier what ResultSet is and how we can change its behavior while setting the constant values. Now we will see what are the different methods of ResultSet and why they are used.

The following are methods of ResultSet Interface in JDBC

  1. boolean absolute(int row): This will move the cursor to the given row number in the ResultSet object.
  2. void afterLast(): This will move the cursor to the end of the ResultSet object, just after the last row.
  3. void beforeFirst(): This will move the cursor to the front of the ResultSet object, just before the first row.
  4. void cancelRowUpdates(): This will cancel the updates made to the current row.
  5. void clearWarnings(): This will clear all warnings reported on the ResultSet object.
  6. void close(): Releases this ResultSet object’s database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.
  7. void deleteRow(): This will delete the current row from the ResultSet object and from the underlying database.
  8. int findColumn(String columnLabel): This will map the given ResultSet column name to its ResultSet column index.
  9. boolean first(): This will move the cursor to the first row in the ResultSet object.
  10. Array getArray(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as an Array object.
  11. Array getArray(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as an Array object.
  12. InputStream getAsciiStream(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a stream of ASCII characters.
  13. InputStream getAsciiStream(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a stream of ASCII characters.
  14. BigDecimal getBigDecimal(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a java.math.BigDecimal with full precision.
  15. BigDecimal getBigDecimal(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a java.math.BigDecimal with full precision. 
  16. InputStream getBinaryStream(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a stream of uninterpreted bytes.
  17. InputStream getBinaryStream(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a stream of uninterpreted bytes.
  18. Blob getBlob(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a Blob object.
  19. Blob getBlob(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a Blob object.
  20. boolean getBoolean(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a boolean.
  21. boolean getBoolean(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a boolean.
  22. byte getByte(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a byte.
  23. byte getByte(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a byte.
  24. byte[] getBytes(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a byte array.
  25. byte[] getBytes(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a byte array.
  26. Reader getCharacterStream(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a java.io.Reader object.
  27. Reader getCharacterStream(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a java.io.Reader object.
  28. Clob getClob(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a Clob object.
  29. Clob getClob(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a Clob object.
  30. int getConcurrency(): To retrieve the concurrency mode of the ResultSet object.
  31. String getCursorName(): To retrieve the name of the SQL cursor used by this ResultSet object.
  32. Date getDate(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a java.sql.Date object.
  33. Date getDate(int columnIndex, Calendar cal): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a java.sql.Date object.
  34. Date getDate(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a java.sql.Date object.
  35. Date getDate(String columnLabel, Calendar cal): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a java.sql.Date object.
  36. double getDouble(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a double.
  37. double getDouble(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a double.
  38. int getFetchDirection(): To retrieve the fetch direction for this ResultSet object.
  39. int getFetchSize(): To retrieve the fetch size for this ResultSet object.
  40. float getFloat(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a float.
  41. float getFloat(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a float.
  42. int getHoldability(): To retrieve the holding ability of the ResultSet object
  43. int getInt(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as an int.
  44. int getInt(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as an int.
  45. long getLong(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a long.
  46. long getLong(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a long.
  47. ResultSetMetaData getMetaData(): To retrieve the number, types, and properties of the ResultSet object’s columns.
  48. Reader getNCharacterStream(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a java.io.Reader object.
  49. Reader getNCharacterStream(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a java.io.Reader object.
  50. NClob getNClob(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as an NClob object.
  51. NClob getNClob(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as an NClob object.
  52. String getNString(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a String.
  53. String getNString(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a String.
  54. Object getObject(int columnIndex): To get the value of the designated column(by index position) in the current row of the ResultSet object as an Object.
  55. <T> T getObject(int columnIndex, Class<T> type): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object and will convert from the SQL type of the column to the requested Java data type, if the conversion is supported.
  56. Object getObject(int columnIndex, Map<String, Class<?>> map): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as an Object.
  57. Object getObject(String columnLabel): To get the value of the designated column(by name) in the current row of the ResultSet object as an Object.
  58. <T> T getObject(String columnLabel, Class<T> type): To retrieve the value of the designated column(by name) in the current row of the ResultSet object and will convert from the SQL type of the column to the requested Java data type, if the conversion is supported.
  59. Object getObject(String columnLabel, Map<String, Class<?>> map): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as an Object.
  60. Ref getRef(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a Ref object.
  61. Ref getRef(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a Ref object.
  62. int getRow(): To retrieve the current row number.
  63. RowId getRowId(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a java.sql.RowId object.
  64. RowId getRowId(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a java.sql.RowId object.
  65. short getShort(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a short.
  66. short getShort(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a short.
  67. SQLXML getSQLXML(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet as a java.sql.SQLXML object.
  68. SQLXML getSQLXML(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet as a java.sql.SQLXML object.
  69. Statement getStatement(): To retrieve the Statement object that produced this ResultSet object.
  70. String getString(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a String.
  71. String getString(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a String.
  72. Time getTime(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a java.sql.Time object.
  73. Time getTime(int columnIndex, Calendar cal): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a java.sql.Time object.
  74. Time getTime(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a java.sql.Time object.
  75. Time getTime(String columnLabel, Calendar cal): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a java.sql.Time object.
  76. Timestamp getTimestamp(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a java.sql.Timestamp object.
  77. Timestamp getTimestamp(int columnIndex, Calendar cal): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a java.sql.Timestamp object.
  78. Timestamp getTimestamp(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a java.sql.Timestamp object.
  79. Timestamp getTimestamp(String columnLabel, Calendar cal): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a java.sql.Timestamp object.
  80. int getType(): To retrieve the type of the ResultSet object.
  81. URL getURL(int columnIndex): To retrieve the value of the designated column(by index position) in the current row of the ResultSet object as a java.net.URL object.
  82. URL getURL(String columnLabel): To retrieve the value of the designated column(by name) in the current row of the ResultSet object as a java.net.URL object.
  83. SQLWarning getWarnings(): To retrieve the first warning reported by calls on this ResultSet object.
  84. void insertRow(): To insert the contents of the insert row into this ResultSet object and into the database.
  85. boolean isAfterLast(): To check whether the cursor is after the last row in this ResultSet object.
  86. boolean isBeforeFirst(): To check whether the cursor is before the first row in this ResultSet object.
  87. boolean isClosed(): To check whether this ResultSet object has been closed.
  88. boolean isFirst(): To check whether the cursor is on the first row of the ResultSet object.
  89. boolean isLast(): To check whether the cursor is on the last row of the ResultSet object.
  90. boolean last(): To move the cursor to the last row in this ResultSet object and returns true/false.
  91. void moveToCurrentRow(): To move the cursor to the remembered cursor position, usually the current row.
  92. void moveToInsertRow(): To move the cursor to the insert row.
  93. boolean next(): To move the cursor forward one row from its current position.
  94. boolean previous(): To move the cursor to the previous row in this ResultSet object.
  95. void refreshRow(): To refresh the current row with its most recent value in the database.
  96. boolean relative(int rows): To move the cursor to a relative number of rows, either positive or negative.
  97. boolean rowDeleted(): To retrieve whether a row has been deleted.
  98. boolean rowInserted(): To retrieve whether the current row has had an insertion.
  99. boolean rowUpdated(): To retrieve whether the current row has been updated.
  100. void setFetchDirection(int direction): To give a hint as to the direction in which the rows in the ResultSet object will be processed.
  101. void setFetchSize(int rows): To give the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed for this ResultSet object.
  102. void updateArray(int columnIndex, Array x): To update the designated column(by index position) with a java.sql.Array value.
  103. void updateArray(String columnLabel, Array x): To update the designated column(by name) with a java.sql.Array value.
  104. void updateAsciiStream(int columnIndex, InputStream x): To update the designated column(by index position) with an ASCII stream value.
  105. void updateAsciiStream(int columnIndex, InputStream x, int length): To update the designated column(by index position) with an ASCII stream value, which will have the specified number of bytes.
  106. void updateAsciiStream(int columnIndex, InputStream x, long length): To update the designated column(by index position) with an ASCII stream value, which will have the specified number of bytes.
  107. void updateAsciiStream(String columnLabel, InputStream x): To update the designated column(by name) with an ASCII stream value.
  108. void updateAsciiStream(String columnLabel, InputStream x, int length): To update the designated column(by name) with an ASCII stream value, which will have the specified number of bytes.
  109. void updateAsciiStream(String columnLabel, InputStream x, long length): To update the designated column(by name) with an ASCII stream value, which will have the specified number of bytes.
  110. void updateBigDecimal(int columnIndex, BigDecimal x): To update the designated column(by index position) with a java.math.BigDecimal value.
  111. void updateBigDecimal(String columnLabel, BigDecimal x): To update the designated column(by name) with a java.sql.BigDecimal value.
  112. void updateBinaryStream(int columnIndex, InputStream x): To update the designated column(by index position) with a binary stream value.
  113. void updateBinaryStream(int columnIndex, InputStream x, int length): To update the designated column(by index position) with a binary stream value, which will have the specified number of bytes.
  114. void updateBinaryStream(int columnIndex, InputStream x, long length): To update the designated column(by index position) with a binary stream value, which will have the specified number of bytes.
  115. void updateBinaryStream(String columnLabel, InputStream x): To update the designated column(by name) with a binary stream value.
  116. void updateBinaryStream(String columnLabel, InputStream x, int length): To update the designated column(by name) with a binary stream value, which will have the specified number of bytes.
  117. void updateBinaryStream(String columnLabel, InputStream x, long length): To update the designated column(by name) with a binary stream value, which will have the specified number of bytes.
  118. void updateBlob(int columnIndex, Blob x): To update the designated column(by index position) with a java.sql.Blob value.
  119. void updateBlob(int columnIndex, InputStream inputStream): To update the designated column(by index position) using the given input stream.
  120. void updateBlob(int columnIndex, InputStream inputStream, long length): To update the designated column(by index position) using the given input stream, which will have the specified number of bytes.
  121. void updateBlob(String columnLabel, Blob x): To update the designated column(by name) with a java.sql.Blob value.
  122. void updateBlob(String columnLabel, InputStream inputStream): To update the designated column(by name) using the given input stream.
  123. void updateBlob(String columnLabel, InputStream inputStream, long length): To update the designated column(by name) using the given input stream, which will have the specified number of bytes.
  124. void updateBoolean(int columnIndex, boolean x): To update the designated column(by index position) with a boolean value.
  125. void updateBoolean(String columnLabel, boolean x): To update the designated column(by name) with a boolean value.
  126. void updateByte(int columnIndex, byte x): To update the designated column(by index position) with a byte value.
  127. void updateByte(String columnLabel, byte x): To update the designated column(by name) with a byte value.
  128. void updateBytes(int columnIndex, byte[] x): To update the designated column(by index position) with a byte array value.
  129. void updateBytes(String columnLabel, byte[] x): To update the designated column(by name) with a byte array value.
  130. void updateCharacterStream(int columnIndex, Reader x): To update the designated column(by index position) with a character stream value.
  131. void updateCharacterStream(int columnIndex, Reader x, int length): To update the designated column(by index position) with a character stream value, which will have the specified number of bytes.
  132. void updateCharacterStream(int columnIndex, Reader x, long length): To update the designated column(by index position) with a character stream value, which will have the specified number of bytes.
  133. void updateCharacterStream(String columnLabel, Reader reader): To update the designated column(by name) with a character stream value.
  134. void updateCharacterStream(String columnLabel, Reader reader, int length): To update the designated column(by name) with a character stream value, which will have the specified number of bytes.
  135. void updateCharacterStream(String columnLabel, Reader reader, long length): To update the designated column(by name) with a character stream value, which will have the specified number of bytes.
  136. void updateClob(int columnIndex, Clob x): To update the designated column(by index position) with a java.sql.Clob value.
  137. void updateClob(int columnIndex, Reader reader): To update the designated column(by index position) using the given Reader object.
  138. void updateClob(int columnIndex, Reader reader, long length): To update the designated column(by index position) using the given Reader object, which is the given number of characters long.
  139. void updateClob(String columnLabel, Clob x): To update the designated column(by name) with a java.sql.Clob value.
  140. void updateClob(String columnLabel, Reader reader): To update the designated column(by name) using the given Reader object.
  141. void updateClob(String columnLabel, Reader reader, long length): To update the designated column(by name) using the given Reader object, which is the given number of characters long.
  142. void updateDate(int columnIndex, Date x): To update the designated column(by index position) with a java.sql.Date value.
  143. void updateDate(String columnLabel, Date x): To update the designated column(by name) with a java.sql.Date value.
  144. void updateDouble(int columnIndex, double x): To update the designated column(by index position) with a double value.
  145. void updateDouble(String columnLabel, double x): To update the designated column(by name) with a double value.
  146. void updateFloat(int columnIndex, float x): To update the designated column(by index position) with a float value.
  147. void updateFloat(String columnLabel, float x): To update the designated column(by name) with a float value.
  148. void updateInt(int columnIndex, int x): To update the designated column(by index position) with an int value.
  149. void updateInt(String columnLabel, int x): To update the designated column(by name) with an int value.
  150. void updateLong(int columnIndex, long x): To update the designated column(by index position) with a long value.
  151. void updateLong(String columnLabel, long x): To update the designated column(by name) with a long value.
  152. void updateNCharacterStream(int columnIndex, Reader x): To update the designated column(by index position) with a character stream value.
  153. void updateNCharacterStream(int columnIndex, Reader x, long length): To update the designated column(by index position) with a character stream value, which will have the specified number of bytes.
  154. void updateNCharacterStream(String columnLabel, Reader reader): To update the designated column(by name) with a character stream value.
  155. void updateNCharacterStream(String columnLabel, Reader reader, long length): To update the designated column(by name) with a character stream value, which will have the specified number of bytes.
  156. void updateNClob(int columnIndex, NClob nClob): To update the designated column(by index position) with a java.sql.NClob value.
  157. void updateNClob(int columnIndex, Reader reader): To update the designated column(by index position) using the given Reader The data will be read from the stream as needed until end-of-stream is reached.
  158. void updateNClob(int columnIndex, Reader reader, long length): To update the designated column(by index position) using the given Reader object, which is the given number of characters long.
  159. void updateNClob(String columnLabel, NClob nClob): To update the designated column(by name) with a java.sql.NClob value.
  160. void updateNClob(String columnLabel, Reader reader): To update the designated column(by name) using the given Reader object.
  161. void updateNClob(String columnLabel, Reader reader, long length): To update the designated column(by name) using the given Reader object, which is the given number of characters long.
  162. void updateNString(int columnIndex, String nString): To update the designated column(by index position) with a String value.
  163. void updateNString(String columnLabel, String nString): To update the designated column(by name) with a String value.
  164. void updateNull(int columnIndex): To update the designated column(by index position) with a null value.
  165. void updateNull(String columnLabel): To update the designated column(by name) with a null value.
  166. void updateObject(int columnIndex, Object x): To update the designated column(by index position) with an Object value.
  167. void updateObject(int columnIndex, Object x, int scaleOrLength): To update the designated column(by index position) with an Object value.
  168. default void updateObject(int columnIndex, Object x, SQLType targetSqlType): To update the designated column(by index position) with an Object value.
  169. default void updateObject(int columnIndex, Object x, SQLType targetSqlType, int scaleOrLength): To update the designated column(by index position) with an Object value.
  170. void updateObject(String columnLabel, Object x): To update the designated column(by name) with an Object value.
  171. void updateObject(String columnLabel, Object x, int scaleOrLength): To update the designated column(by name) with an Object value.
  172. default void updateObject(String columnLabel, Object x, SQLType targetSqlType): To update the designated column(by name) with an Object value.
  173. default void updateObject(String columnLabel, Object x, SQLType targetSqlType, int scaleOrLength): To update the designated column(by name) with an Object value.
  174. void updateRef(int columnIndex, Ref x): To update the designated column(by index position) with a java.sql.Ref value.
  175. void updateRef(String columnLabel, Ref x): To update the designated column(by name) with a java.sql.Ref value.
  176. void updateRow(): To update the underlying database with the new contents of the current row of the ResultSet object.
  177. void updateRowId(int columnIndex, RowId x): To update the designated column(by index position) with a RowId value.
  178. void updateRowId(String columnLabel, RowId x): To update the designated column(by name) with a RowId value.
  179. void updateShort(int columnIndex, short x): To update the designated column(by index position) with a short value.
  180. void updateShort(String columnLabel, short x): To update the designated column(by name) with a short value.
  181. void updateSQLXML(int columnIndex, SQLXML xmlObject): To update the designated column(by index position) with a java.sql.SQLXML value.
  182. void updateSQLXML(String columnLabel, SQLXML xmlObject): To update the designated column(by name) with a java.sql.SQLXML value.
  183. void updateString(int columnIndex, String x): To update the designated column(by index position) with a String value.
  184. void updateString(String columnLabel, String x): To update the designated column(by name) with a String value.
  185. void updateTime(int columnIndex, Time x): To update the designated column(by index position) with a java.sql.Time value.
  186. void updateTime(String columnLabel, Time x): To update the designated column(by name) with a java.sql.Time value.
  187. void updateTimestamp(int columnIndex, Timestamp x): To update the designated column(by index position) with a java.sql.Timestamp value.
  188. void updateTimestamp(String columnLabel, Timestamp x): To update the designated column(by name) with a java.sql.Timestamp value.
  189. boolean wasNull(): To check whether the last column read had a value of SQL NULL.

-A blog by Shwetali Khambe

Related Posts