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") + "\t"
+ rs.getObject("name") + "\t"
+ rs.getObject("birthday") + "\t"
+ rs.getObject("money"));
}
System.out.println("------------");
rs.absolute(150);
int i = 0;
while (rs.next() && i < 10) {
i++;
System.out.println(rs.getObject("id") + "\t"
+ rs.getObject("name") + "\t"
+ rs.getObject("birthday") + "\t"
+ rs.getObject("money"));
}
// if (rs.previous())
// System.out.println(rs.getObject("id") + "\t"
// + rs.getObject("name") + "\t"
// + rs.getObject("birthday") + "\t"
// + rs.getObject("money"));
} finally {
JdbcUtils.free(rs, st, conn);
}
}
}
最新文章
- unix编程书中的 ourhdr.h代码
- 用外部表的方式查询当天数据库alert日志文件
- php获取前一天后一天,php时间函数操作
- iOS - UICollectionViewController
- h264 流、帧结构
- JS原生方法实现jQuery的ready()
- java1.8的几大新特性(二)
- UFLDL教程(四)之Softmax回归
- linux中tar 打包指定路径文件
- JavaScript--我发现,原来你是这样的JS(引用类型不简单,且听我娓娓道来)
- id 选择器
- Uva - 12504 - Updating a Dictionary
- go实现选择排序
- Linux下DHCP服务安装配置
- java 类字面常量,泛化的Class引用
- easyui---修改删除查询
- [转载] python必碰到的问题---encode与decode,中文乱码
- springboot项目访问不到controller方法。
- Ceres入门笔记
- 微信小程序之特殊效果及功能
热门文章
- 【BZOJ】1996: [Hnoi2010]chorus 合唱队【区间dp】
- bzoj 3172: [Tjoi2013]单词 AC自动机
- acdream 1725 哗啦啦的小彭玉染色问题 离散化并查集
- Vue学习记录-状态管理
- MariaDB Audit Plugin 1.2
- set bin 集合
- 通过 WCF 实现点对点文件共享 z
- hdu-4725-The Shortest Path in Nya Graph-层次网络
- MySQL模糊查询(like)时区分大小写
- iOS:CoreData数据库的使用四(数据库和UITableViewController以及NSFetchedResultsController一起使用)