欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

mysql中关于分页查询的输出问题!

程序员文章站 2022-05-08 10:17:58
...
mysql分页sql

String sql = "select * from emp order by empno limit ?,?";
prepareStatement stmt = con.prepareStatement(sql);
stmt.setInt(1, begin);
stmt.setInt(2, end);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
System.out.println(rs.getInt("empno") + ","
+ rs.getString("ename") + ","
+ rs.getDouble("sal") + "," + rs.getDate("hiredate"));}

        一直对rs.getxxx()的用法比较模糊,求介绍下用法        返回的结果集rs是不是既可以按列名rs.getxxx("xxx")也可以按rs.getxxx(1)这样读取啊?        另外上面的代码中输出语句里面我可以不可以写成           while (rs.next()) {        System.out.println(rs.getInt(1) + ","                        + rs.getString(2) + ","                        + rs.getDouble(3) + "," + rs.getDate(4));}
相关标签: mysql 分页 sql