Topic
No replies
SystemAdmin
SystemAdmin
9 Posts
ACCEPTED ANSWER

Pinned topic Performance sql through JDBC using jt400.jar

‏2012-02-23T23:25:46Z |
Hi

i'm problem of performance with this sql; it comes called for every row that i display in my web page and it take about 1,5 seconds for every read. How can optimeze it ? I have felt to speak of reuse connection : how i can you use it ? can some post same example ?

Thanks in advance

here my code

String cod = "";
Connection connection;
try {
String Mycod = " " + sdce.getPreviewText().substring(1, 8);
Class.forName("com.ibm.as400.access.AS400JDBCDriver");
connection = DriverManager.getConnection("jdbc:as400://MYSYS/MYLIB", "USR", "PSW");
String query = "SELECT FLD1 FROM MYLIB.MYFILE WHERE FLD2='" + Mycod +"'" + "FOR READ ONLY OPTIMIZE FOR 1 ROWS WITH NC";
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(query);
rs.next();
cod = rs.getString(1);
connection.close();

} catch(Exception e) {
e.printStackTrace();
}