Hello there,
We?ve performances issues and highly CPU consuming, when we use ResultSet.TYPE_SCROLL_SENSITIVE for a query which returns many results (>10000 rows).
Why this behavior?
Is there another way to move through the cursor in JDBC?
Here is an example of coding below.
Any insight ?
TIA
PS : we use the jt400.jar V5R4 provided by IBM directly on the machine.
We?ve performances issues and highly CPU consuming, when we use ResultSet.TYPE_SCROLL_SENSITIVE for a query which returns many results (>10000 rows).
Why this behavior?
Is there another way to move through the cursor in JDBC?
Here is an example of coding below.
Any insight ?
TIA
PS : we use the jt400.jar V5R4 provided by IBM directly on the machine.
PHP Code:
package sql;
import java.sql.*;
public class SlowAndConsumingScrollableStatement {
public static void main(String[] args) {
Statement stmt=null;
ResultSet rs=null;
Connection con=null;
try {
System.out.println("The 1 argument is the machine name");
System.out.println("The 2 is the user");
System.out.println("The 3 is the pwd");
String machine = "s44g5036";
// default user
String user = "dgc022";
String pwd = "d022gc";
if (args != null && args.length == 3) {
machine = args[0];
user = args[1];
pwd = args[2];
}
// load the AS400 driver class in memory
Class.forName("com.ibm.as400.access.AS400JDBCDriver");
// set all the properties for the AS400 connexion
java.util.Properties props = new java.util.Properties();
props.put("naming", "system");
props.put("user", user);
props.put("password", pwd);
props.put("date format", "iso");
props.put("date separator", "-");
// establish a connection with the AS400
con = DriverManager.getConnection("jdbc:as400://" + machine, props);
// set the isolation level : check the Connection Doc to use it
// properly
con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
con.setAutoCommit(false);
String sqlStatement = "select duedate,techcreationdate from wwwtask order by org, duedate";
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sqlStatement);
//simulation of block navigation 1-50-100-...
rs.absolute(150);
int i=1;
while (rs.next() && (i % 50)!=0 ) {
System.out.println(rs.getDate(1)+" "+rs.getDate(2));
i++;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
rs.close();
stmt.close();
con.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Comment