Java How to apply Cursors

Source: Internet
Author: User

public class Resultsetmovetest {

public static void Main (string[] args) {

Todo automatically generate method stubs

try {

Write one of the most common query statements

String sql = "SELECT * FROM Login-id";

Obtain the connection provided by (3) in section 2.1; Connection con = dbutil.getconn ();

Get types that can be scrolled back and forth

Statement stmt = con.createstatement (resultset.type_scroll_insensitive, resultset.concur_updatable);

Obtaining result sets through statement

ResultSet rs = stmt.executequery (SQL);

int i = 0;

System.out.println ("= = = Start testing all records obtained ===n"); SYSTEM.OUT.PRINTLN ("Cursor down 2/n"); Rs.absolute (2); System.out.println ("Now total in the first:" + rs.getrow () + "line. "); Rs.last (); SYSTEM.OUT.PRINTLN ("There are now:" + rs.getrow () +) record. "); Rs.movetoinsertrow (); SYSTEM.OUT.PRINTLN ("Inserts a record.") "); Rs.insertrow (); SYSTEM.OUT.PRINTLN ("Inserts a record.") "); Rs.insertrow (); Rs.last (); SYSTEM.OUT.PRINTLN ("There are now:" + rs.getrow () +) record. "); Rs.deleterow (); Rs.last (); SYSTEM.OUT.PRINTLN ("There are now:" + rs.getrow () +) record. ");

Rs.deleterow ();

System.out.println ("= = = All records obtained by Test are successful ===n");

catch (Exception e) {

E.printstacktrace ();

}

}

}

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.