(JDBC)26_可滚动结果集与分页技术
static void scroll(){ Connection con=get_con(); String sql="select * from usertr"; SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); try { Statement st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); ResultSet rs=st.executeQuery(sql); while(rs.next()){ System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+sdf.format(rs.getDate(3))+"\t"+rs.getInt("money")); } System.out.println("-----------------"); while(rs.previous()){ System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+sdf.format(rs.getDate(3))+"\t"+rs.getInt("money")); } System.out.println("-----------------"); rs.absolute(3); System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+sdf.format(rs.getDate(3))+"\t"+rs.getInt("money")); // rs.afterLast(); // rs.beforeFirst(); st.close(); rs.close(); con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }