This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes taking more time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark " taking more time" Watch " taking more time" New topic
Author taking more time

murugesan govindan

Joined: Jan 02, 2008
Posts: 2

While analyzing the performance for my application, I have found that method taking more time to move cursor on first time. Resultset has only 10 records and when control reach at while( taking more time (14 sec) on first time (to reach first record) and after control get into the while loop its working fast.

is there any alternative method to iterate resultset other than next()?

Environment: Wbsphere Application server 6.1

code look like:

ResultSet rs = null;
CallableStatement cstmt = null;

cstmt = dbConnection.prepareCall(sql);

rs = (ResultSet)cstmt.getObject(1);

//Only 10 times iterating as expected.

please advise me, why method taking more time to reach first record.

Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1082

It can also be your PL/SQL CURSOR , which might be causing this delay.

Did you run you procedure on sql console ? try to run procedure on SQL-plus and check if it is taking equal time as JDBC.


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
murugesan govindan

Joined: Jan 02, 2008
Posts: 2

Procedure running in 1 second but after receing the resultset, if I call while( then its taking more time.

sivaraju kumar

Joined: Jul 16, 2009
Posts: 1
you Should have to excecute statement then you have to take the Cursor reuslts.
please find the code and let me know if still problem.

String query = useOracleQuery ? oracleQuery : genericQuery;
System.out.println("Query: " + query + "\n");
CallableStatement stmt = conn.prepareCall(query);

// register the type of the out param - an Oracle specific type
stmt.registerOutParameter(1, OracleTypes.CURSOR);

// set the in param
stmt.setFloat(2, price);

// execute and retrieve the result set
ResultSet rs = (ResultSet)stmt.getObject(1);

// print the results
while ( {
System.out.println(rs.getString(1) + "\t" +
rs.getFloat(2) + "\t" +


Sivakumar(IBM Friend)
I agree. Here's the link:
subject: taking more time
It's not a secret anymore!