JDBC resultset close

Posted by KM on Stack Overflow See other posts from Stack Overflow or by KM
Published on 2010-03-23T21:05:04Z Indexed on 2010/03/23 21:13 UTC
Read the original article Hit count: 551

Filed under:
|
|
|

I am doing profiling of my Java application and found some interesting statistics for a jdbc PreparedStatement call:

Given below is the environment details: Database: Sybase SQL Anywhere 10.0.1 Driver: com.sybase.jdbc3.jdbc.SybDriver connection pool: c3p0 JRE: 1.6.0_05

The code in question is given below:

try {
    ps = conn.prepareStatement(sql);
    ps.setDouble(...);
    rs = ps.executeQuery();
              ......

    return xyz;
}
finally {
    try {
        if (rs != null) rs.close();
        if (ps != null) ps.close();
    }
    catch (SQLException sqlEx) {

    }
}

From JProfiler stats, I find that this particular resultspace.close() statement alone takes a large amount of time. It varies from 25 ms to 320s while for other code blocks which are of identical in nature, i find that this takes close to 20 microseconds.

Just to be sure, I ran this performance test multiple times and confirmed this data. I am puzzled by this behaviour - Thoughts?

© Stack Overflow or respective owner

Related posts about java

Related posts about jdbc