java_jdbc_可滚动结果集与分页

	public static void create2(int i) {
Connection conn = null;
Statement st = null;
ResultSet rs = null; try {
conn = JdbcUtils.getConnection();
st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=st.executeQuery("select * from t_user where id<10");
while(rs.next()){
System.out.print(rs.getObject("id")+" ");
System.out.print(rs.getObject("username")+" ");
System.out.print(rs.getObject("password")+" ");
System.out.println();
} System.out.println("----------------------------------");
//定位到哪一条数据开始
rs.absolute(5);
int k=0;
//rs.previous()
while(rs.next()&&k<10){
i++;
System.out.print(rs.getObject("id")+" ");
System.out.print(rs.getObject("username")+" ");
System.out.print(rs.getObject("password")+" ");
System.out.println();
} } catch (SQLException e) {
throw new DaoExcetpion(e.getMessage(), e);
} finally {
JdbcUtils.free(rs, st, conn);
}
}
上一篇:node中的Stream-Readable和Writeable解读


下一篇:微信小程序学习记录(一)