Home

moveToInsertRow

moveToInsertRow is a method of the JDBC ResultSet interface used with updatable result sets. It moves the cursor to a special row known as the insert row, which is used to construct a new row to be inserted into the database. The method does not move data into the database by itself; it prepares the ResultSet to collect values for a new row.

Usage and requirements

- The ResultSet must be scrollable and updatable, and the underlying database must support updatable result sets.

- The cursor must be positioned on a valid current row before calling moveToInsertRow.

- After moving to the insert row, use updateXXX or updateObject to set the values for the new

- Call insertRow to insert the new row into the database, and then call moveToCurrentRow to return

- If the driver or database does not support updatable result sets, moveToInsertRow may throw SQLException or

Behavior and semantics

- The insert row is a temporary, non-displayed row that provides a place to specify values for a

- Only the columns you set with updateXXX or updateObject are used for insertion; others may be

- The data is committed according to the connection’s auto-commit mode or an explicit transaction.

Example workflow

- Obtain an updatable, scrollable ResultSet.

- rs.moveToInsertRow();

- rs.updateString("name", "Alice");

- rs.updateInt("age", 30);

- rs.insertRow();

- rs.moveToCurrentRow();

See also

- ResultSet

- insertRow

- moveToCurrentRow

- Updatable result sets

---

row’s
columns.
to
the
row
that
was
current
before
the
insert.
be
a
no-op.
new
row.
null
or
default
depending
on
the
table
definition.