Total number of data records read and queried by java

Source: Internet
Author: User
The code is as follows: Copy code
Statement stmt = conn. createStatement (ResultSet. TYPE_SCROLL_INSENSITIVE, ResultSet. CONCUR_READ_ONLY );
ResultSet rs = stmt.exe cuteQuery (SQL );
Rs. last ();
Int length = rs. getRow ();

The value of length is the number of rows. If you want to continue using the current dataset rs after obtaining the number of rows, run rs. beforeFirst () to return the cursor to the initial position.
The common format created by Statement is:

The code is as follows: Copy code
Statement stmt = con. createStatement (int type, int concurrency );

Parameter description:
Int type
The cursor of the ResultSet. TYPE_FORWORD_ONLY result set can only scroll down.
The cursor of the ResultSet. TYPE_SCROLL_INSENSITIVE result set can be moved up or down. When the database changes, the current result set remains unchanged.
ResultSet. TYPE_SCROLL_SENSITIVE returns a scrollable result set. When the database changes, the current result set changes synchronously.
Int concurrency
ResultSet. CONCUR_READ_ONLY cannot use the result set to update tables in the database.
ResultSet. CONCUR_UPDATETABLE can use the result set to update tables in the database.
After you use ResultSet re=stmt.exe cuteQuery (SQL statement) to query, you can use the following methods to obtain information:

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.