The below code doesn't work. The while loop doesn't display any values. If I change it to 0 and 150
it works fine. Please help me out here. Anything other than 0 doesn't retrieve any value. Using Oracle database. I tried using ORDER BY
but it still doesn't work.
ResultSet rset1 = stmt.executeQuery
(" SELECT * FROM (SELECT * FROM iris ) WHERE rownum BETWEEN 10 and 150");
while(rset1.next())
{
System.out.println(rset1.getString(1));
}
/////////////////////////////////////////////
java.util.Properties props = new java.util.Properties();
props.setProperty("user", "system");
props.setProperty("password", "weblogic");
DriverManager.registerDriver(new OracleDriver());
Connection conn = DriverManager.getConnection(url, props);
Statement stmt = conn.createStatement();
ResultSet rset1 = stmt.executeQuery(" WITH q AS (SELECT * FROM iris )
SELECT *
FROM q
WHERE ROWNUM BETWEEN 10 and 150");
while(rset1.next())
{
System.out.println(rset1.getString(1));
}