Descripción
El interface ResultSet
en Java es una interfaz que nos permite manejar los resultados de una consulta SQL. Esta interfaz nos proporciona métodos para navegar por los resultados, así como para leer y modificar los datos obtenidos. El ResultSet
mantiene un cursor que apunta a la fila actual de datos.
Sintaxis
public interface ResultSet extends Wrapper, AutoCloseable
Campos
- CLOSE_CURSORS_AT_COMMIT
- CONCUR_READ_ONLY
- CONCUR_UPDATABLE
- FETCH_FORWARD
- FETCH_REVERSE
- FETCH_UNKNOWN
- HOLD_CURSORS_OVER_COMMIT
- TYPE_FORWARD_ONLY
- TYPE_SCROLL_INSENSITIVE
- TYPE_SCROLL_SENSITIVE
Métodos
- absolute()
- afterLast()
- beforeFirst()
- cancelRowUpdates()
- clearWarnings()
- close()
- deleteRow()
- findColumn()
- first()
- getArray()
- getAsciiStream()
- getBigDecimal()
- getBinaryStream()
- getBlob()
- getBoolean()
- getByte()
- getBytes()
- getCharacterStream()
- getClob()
- getConcurrency()
- getCursorName()
- getDate()
- getDouble()
- getFetchDirection()
- getFetchSize()
- getFloat()
- getHoldability()
- getInt()
- getLong()
- getMetaData()
- getNCharacterStream()
- getNClob()
- getNString()
- getObject()
- getRef()
- getRow()
- getRowId()
- getShort()
- getSQLXML()
- getStatement()
- getString()
- getTime()
- getTimestamp()
- getType()
- getUnicodeStream()
- getURL()
- getWarnings()
- insertRow()
- isAfterLast()
- isBeforeFirst()
- isClosed()
- isFirst()
- isLast()
- last()
- moveToCurrentRow()
- moveToInsertRow()
- next()
- previous()
- refreshRow()
- relative()
- rowDeleted()
- rowInserted()
- rowUpdated()
- setFetchDirection()
- setFetchSize()
- updateArray()
- updateAsciiStream()
- updateBigDecimal()
- updateBinaryStream()
- updateBlob()
- updateBoolean()
- updateByte()
- updateBytes()
- updateCharacterStream()
- updateClob()
- updateDate()
- updateDouble()
- updateFloat()
- updateInt()
- updateLong()
- updateNCharacterStream()
- updateNClob()
- updateNString()
- updateNull()
- updateObject()
- updateRef()
- updateRow()
- updateRowId()
- updateShort()
- updateSQLXML()
- updateString()
- updateTime()
- updateTimestamp()
- wasNull()
Ejemplo
PreparedStatement stmt = null;
ResultSet rs = null;
stmt = con.prepareStatement("SELECT * FROM personas");
rs = stmt.executeQuery();
while(rs.next()) {
for (int x=1;x<=rs.getMetaData().getColumnCount();x++)
System.out.print(rs.getString(x)+ "\t");
System.out.println("");
}
Artículos
Vídeos Java
Disfruta también de nuestros artículos sobre Java en formato vídeo. Aprovecha y suscribete a nuestro canal.