When created with the default settings, the resultset is an object that can only be accessed once (one-time-through), only forward-only and read-only. You can only access the data once. If you need the data again, you must query the database again.
However, this is not the only method. By setting parameters on the statement object, you can control the resultset it generates. For example:
...
Class. forname (drivername );
DB = drivermanager. getconnection (connecturl );
Statement statement = dB. createstatement (
Resultset. type_scroll_sensitive,
Resultset. concur_updatable
);
String orderelname = xmlfileel. getelementsbytagname ("order"). Item (0)
. Getfirstchild (). getnodevalue ();
...
This statement will now generate a resultset that can be updated and applied to changes made by other database users. You can also move forward and backward in this resultset.
The first parameter specifies the type of the resultset. The options include:
Type_forward_only: default type. Only one forward access is allowed and is not affected by changes made to the database by other users.
Type_scroll_insensitive: allows moving forward or backward in the list, or even specific positioning, such as moving to the Fourth Record in the list or moving two records backward from the current position. It is not affected by changes made by other users to the database.
TYPE_SCROLL_SENSITIVE: Allows location in records like TYPE_SCROLL_INSENSITIVE. This type is affected by changes made by other users. If you delete a record after executing the query, the record will disappear from the ResultSet. Similarly, changes to data values are also reflected in the ResultSet.
The second parameter sets the concurrency of the ResultSet. This parameter determines whether the ResultSet can be updated. The options include:
CONCUR_READ_ONLY: This is the default value. It specifies that ResultSet cannot be updated.
CONCUR_UPDATABLE: specifies that the ResultSet can be updated.