关于 JDBC数据分页跨数据库小结
一、 关于数据连接
connection
如何区分数据库类型
// 获取数据生产商名称
String databaseProductName =
conn.getMetaData().getDatabaseProductName();
// 获取数据库版本号
String productVersion =
conn.getMetaData().getDatabaseProductVersion();
测试结果:
Oracle
// databaseProductName :Oracle
// productVersion :Oracle Database 10g Enterprise
Edition Release 10.2.0.1.0 - Production
// With the Partitioning, OLAP and Data Mining options
MySQL
// databaseProductName :MySQL
// productVersion :5.0.84-community-nt
Microsoft SQL Server2000
// databaseProductName :Microsoft SQL Server
// productVersion :8.00.2039
Microsoft SQL Server2005
// databaseProductName :Microsoft SQL Server
// productVersion : 9.00.1399
ACCESS
// databaseProductName :ACCESS
// productVersion :04.00.0000
二、 ORACLE 数据分页方案 采用 ORACLE rownum关键字分页
1. SQL语句:
select * from (select t.*,rownum as rn from (select * from table)
t where rownum<=startrow) where rn> endrow ;