Home > Database > Mysql Tutorial > mysql中关于分页查询的输出问题!

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 09:35:17
Original
1111 people have browsed it

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"));}

<code>        一直对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));}</code>
Copy after login
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template