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