zoukankan      html  css  js  c++  java
  • JDBC 滚动和分页

    public class ScrollTest {

        /**
         * @param args
         * @throws SQLException
         */
        public static void main(String[] args) throws SQLException {
            scroll();
        }

        static void scroll() throws SQLException {
            Connection conn = null;
            Statement st = null;
            ResultSet rs = null;
            try {
                // 2.建立连接
                conn = JdbcUtils.getConnection();
                st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                        ResultSet.CONCUR_READ_ONLY);
                rs = st
                        .executeQuery("select id, name, money, birthday  from user limit 150, 10");
                while (rs.next()) {
                    System.out.println(rs.getObject("id") + " "
                            + rs.getObject("name") + " "
                            + rs.getObject("birthday") + " "
                            + rs.getObject("money"));
                }

                System.out.println("------------");
                rs.absolute(150);
                int i = 0;
                while (rs.next() && i < 10) {
                    i++;
                    System.out.println(rs.getObject("id") + " "
                            + rs.getObject("name") + " "
                            + rs.getObject("birthday") + " "
                            + rs.getObject("money"));
                }

                // if (rs.previous())
                // System.out.println(rs.getObject("id") + " "
                // + rs.getObject("name") + " "
                // + rs.getObject("birthday") + " "
                // + rs.getObject("money"));

            } finally {
                JdbcUtils.free(rs, st, conn);
            }
        }
    }

  • 相关阅读:
    004 Optional
    003 Preconditons
    002 splitter
    003 主键问题
    ReportViewer Win32Exception (0x80004005): 创建窗口句柄时出错
    sqlserver删除所有表、视图、存储过程
    win10文件夹 无法显示当前所有者 管理员都不行
    Cannot resolve collation conflict between "Chinese_Taiwan_Stroke_CI_AS" and "Chinese_PRC_CI_AS" in UNION ALL operator occurring in SELECT statement column 1.
    分析器错误消息: Reference.svcmap:未能加载文件
    跨AppDomain通信
  • 原文地址:https://www.cnblogs.com/flying607/p/3462339.html
Copyright © 2011-2022 走看看