JDBC Learning Note (13): Scrollable result set, paging technology, updatable result set

Source: Internet
Author: User
Tags getdate stmt

In some cases, the results of the query need to be selected, such as the data after 19th is queried.

1  PackageCom.xxyh.jdbc;2 Importjava.sql.Connection;3 ImportJava.sql.ResultSet;4 Importjava.sql.SQLException;5 Importjava.sql.Statement;6  Public classScrolltest {7     8      Public Static voidMain (string[] args)throwsSQLException {9Connection conn =NULL;TenStatement stmt =NULL; OneResultSet rs =NULL; A         Try { -conn =jdbcutils.getconnection (); -             //set the result set to be scrollable thestmt =conn.createstatement (resultset.type_scroll_sensitive, - resultset.concur_read_only); -String sql = "Select Id,name,birthday,money from User"; -rs =stmt.executequery (SQL); +              -              while(Rs.next ()) { +System.out.println (Rs.getint ("id") + "\ T" A+ rs.getstring ("name") + "\ T" at+ rs.getdate ("birthday") + "\ T" -+ rs.getfloat ("Money")); -             } -Rs.absolute (19); -System.out.println ("--------------------I'm a gorgeous split-line----------------------"); -             if(Rs.previous ()) { inSystem.out.println (Rs.getint ("id") + "\ T" -+ rs.getstring ("name") + "\ T" to+ rs.getdate ("birthday") + "\ T" ++ rs.getfloat ("Money")); -             } the}finally { * Jdbcutils.close (RS, stmt, conn); $         }Panax Notoginseng     } -}
"Run Results": 1    zhangs        1985-01-01    360.02     lisi           1986-01-01    520.03     Wangwu      1987-01-01    310.04    qianqi         2015-03-15    500.05    qianqi       2015-03-15     500.06    daoname1   2015-03-17     9000000.07    ps          2015-01-01    500.08     ps          2015-01-01    500.09     PS2          2015-01-01    500.010     PS2        2015-01-01    500.011  &NBSp; ps            2015-01-01    500.012     ps         2015-01-01    500.013     PS1         2015-03-19    100.014    PS3        2015-01-02    400.015    blabla     2015-03-19    1000.016    batch0    2015-03-19     100.017    batch1    2015-03-19     101.018    batch2    2015-03-19     102.019    batch3    2015-03-19    103.020     batch4    2015-03-19    104.0-------------------- I'm a gorgeous split-line----------------------18    batch2    2015-03-19    102.0   

JDBC Learning Note (13): Scrollable result set, paging technology, updatable result set

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.