首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >使用sp_cursoropen和sp_cursorfetch分页

使用sp_cursoropen和sp_cursorfetch分页

作者头像
全栈程序员站长
发布2021-04-28 12:06:36
发布2021-04-28 12:06:36
7460
举报

<code> cstmt = con.prepareCall(“{?=call sp_cursoropen(?, ?, ?, ?, ?)}”,      1004, 1008);    cstmt.registerOutParameter(1, Types.INTEGER);    cstmt.registerOutParameter(2, Types.INTEGER);    log.info(sql);    cstmt.setString(3, sql);    cstmt.setInt(4, 1);    cstmt.registerOutParameter(4, Types.INTEGER);    cstmt.setInt(5, 1);    cstmt.registerOutParameter(5, Types.INTEGER);    cstmt.registerOutParameter(6, Types.INTEGER);    rs = cstmt.executeQuery();

   log.info(rs.getMetaData().getColumnCount());    log.info(rs.next());    log.info(cstmt.getInt(1));    int cursor = cstmt.getInt(2);    log.info(cursor);    log.info(cstmt.getInt(4));    log.info(cstmt.getInt(5));    log.info(cstmt.getInt(6));    countSize = cstmt.getInt(6);    countPage = (int) Math.ceil(1.0 * countSize / pageSize);    cstmt.close();    rs.close();    cstmt = con.prepareCall(“{?=call sp_cursorfetch(?, ?, ?, ?)}”);    cstmt.registerOutParameter(1, Types.INTEGER);    cstmt.setInt(2, cursor);    cstmt.setInt(3, 16);    cstmt.setInt(4, (page-1)*pageSize+1);    log.info(“page:”+page);    cstmt.setInt(5, pageSize);    log.info(“pageSize:”+pageSize);    rs = cstmt.executeQuery(); </code>

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/100631.html原文链接:

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档