Understanding the RowSet Interface

RowSet is an interface in JDBC that provides a convenient and flexible way to work with tabular database data. It extends the ResultSet interface and supports both connected and disconnected ways of processing database records. Unlike a traditional ResultSet, some RowSet implementations can operate without keeping a continuous connection to the database. RowSet also follows the JavaBeans component model, making it useful for applications that need to pass, store, and manipulate database data easily.

Methods of RowSet

Method Signature and Short Description

public void setCommand(String cmd)

Sets the SQL command that the RowSet will execute.

public String getCommand()

Returns the SQL command associated with the RowSet.

public void setUrl(String url)

Sets the database URL used by the RowSet.

public String getUrl()

Returns the database URL used by the RowSet.

public void setUsername(String name)

Sets the username used to establish the database connection.

public String getUsername()

Returns the username associated with the RowSet.

public void setPassword(String password)

Sets the password used to establish the database connection.

public void setInt(int parameterIndex, int value)

Sets an integer value for the specified parameter.

public void setString(int parameterIndex, String value)

Sets a String value for the specified parameter.

public void setObject(int parameterIndex, Object value)

Sets an object value for the specified parameter.

public void execute()

Executes the command associated with the RowSet.

public boolean next()

Moves the cursor to the next row in the RowSet.

public boolean previous()

Moves the cursor to the previous row in the RowSet.

public boolean first()

Moves the cursor to the first row in the RowSet.

public boolean last()

Moves the cursor to the last row in the RowSet.

public int getInt(int columnIndex)

Retrieves the value of the specified column as an integer.

public String getString(int columnIndex)

Retrieves the value of the specified column as a String.

public Object getObject(int columnIndex)

Retrieves the value of the specified column as an Object.

public void close()

Releases the resources held by the RowSet.

public boolean isClosed()

Checks whether the RowSet has been closed.

Scroll to Top