CreateStatement (ResultSet. TYPE_SCROLL_SENSITIVE, ResultSet. CONCUR_UPDATABLE); Parameter

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.