JDBC handles scrollable processing sets

Source: Internet
Author: User

Statement createstatement(int resultsettype, int resultsetconcurrency, int resultsetholdability) throws SQLException

creates an object Statement that generates an object with the given type, concurrency, and persistence ResultSet . This method is the same as the previous createStatement method, but it allows you to override the default result set type, concurrency, and persistence.

Parameters:
resultSetType - ResultSet One of the following constants: ResultSet.TYPE_FORWARD_ONLY , ResultSet.TYPE_SCROLL_INSENSITIVE or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - ResultSet One of the following constants: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
resultSetHoldability - ResultSet One of the following constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
Return:
a new Statement object that will generate ResultSet objects with the given type, concurrency, and
persistence
Thrown:
SQLException -If a database access error occurs, this method is raised on a closed connection, or the given parameter is not a ResultSet constant of the specified type, concurrency, and
persistence
SQLFeatureNotSupportedException -This method is not supported if the JDBC driver does not support this method, or for the specified result set type, result set persistence, and result set concurrency.
我们的例子用的参数是:
ResultSet.TYPE_SCROLL_INSENSITIVE for scrolling is not sensitive, it is plain that the result set can be casually rolled.
ResultSet.CONCUR_READ_ONLYWhen the result set is accessed concurrently, the content can only be read and cannot be changed.
1  PackageCom.ayang.jdbc;2 3 ImportJava.sql.*;4 5  Public classtestscroll{6      Public Static voidMain (string[] args) {7         8         Try {9Class.forName ("Oracle.jdbc.driver.OracleDriver");TenString url = "JDBC:ORACLE:THIN:@127.0.0.1:1521:ORCL"; OneConnection conn = drivermanager.getconnection (URL, "Scott", "Root"); A              -Statement stmt =Conn.createstatement ( -Resultset.type_scroll_insensitive,//result set scrolling is not sensitive theRESULTSET.CONCUR_READ_ONLY);//read-only when the result set is accessed concurrently.  -              -ResultSet rs = stmt.executequery ("SELECT * from emp order by Sal"); - Rs.next (); +System.out.println (rs.getstring ("ename")); -Rs.last ();//navigate to Last row +System.out.println (rs.getstring (1));//Print the first column ASystem.out.println (Rs.islast ());//is the last line, Boolean atSystem.out.println (Rs.isafterlast ());//Penultimate line -System.out.println (Rs.getrow ());//get is the first few lines.  - rs.previous (); -System.out.println (rs.getstring (1)); -Rs.absolute (6);//Specify to line 6th -System.out.println (rs.getstring (1)); in rs.close (); - stmt.close (); to conn.close (); +              -}Catch(ClassNotFoundException e) { the              * e.printstacktrace (); $}Catch(SQLException e) {Panax Notoginseng              - e.printstacktrace (); the         } +          A     } the}

JDBC handles scrollable processing sets

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.