Created
November 13, 2014 03:31
-
-
Save aidoskz/fad4676e118f2e1b884c to your computer and use it in GitHub Desktop.
Pagination of list table from Oracle SQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public List<T> getList(long first, long last, String selectSql) throws SQLException { | |
| List<T> list = new ArrayList<T>(); | |
| String query = "select * from (select rownum rn,sq1.* from " + | |
| "("+selectSql+") sq1)" + | |
| " sq2 where sq2.rn>=" + first + " and sq2.rn<=" + last; | |
| Statement stmt = this.conn.createStatement(); | |
| ResultSet rs = stmt.executeQuery(query); | |
| while (rs.next()) | |
| list.add(convert(conn, rs)); | |
| rs.close(); | |
| stmt.close(); | |
| return list; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment