JDBC programms running long time performance issue

Posted by phyerbarte on Stack Overflow See other posts from Stack Overflow or by phyerbarte
Published on 2012-06-15T16:47:21Z Indexed on 2012/06/15 21:16 UTC
Read the original article Hit count: 203

Filed under:
|
|
|
|

My program has an issue with Oracle query performance, I believe the SQL have good performance, because it returns quickly in SQLPlus.

But when my program has been running for a long time, like 1 week, the SQL query (using JDBC) becomes slower (In my logs, the query time is much longer than when I originally started the program). When I restart my program, the query performance comes back to normal.

I think it is could be something wrong with the way I use the preparedStatement, because the SQL I'm using does not use placeholders "?" at all. Just a complex select query.

The query process is done by a util class. Here is the pertinent code building the query:

public List<String[]> query(String sql, String[] args) {
    Connection conn = null;
    conn = openConnection();
    conn.setAutocommit(true);
    ....
    PreparedStatement preStatm = null;
    ResultSet rs = null;
    ....//set preparedstatment arg code 
    rs = preStatm.executeQuery();
      ....
    finally{
           //close rs
           //close prestatm
           //close connection
     }
 }

In my case, the args is always null, so it just passes a query sql to this query method. Is that possible this way could slow down the DB query after program long time running? Or I should use statement instead, or just pass args with "?" in the SQL? How can I find out the root cause for my issue? Thanks.

© Stack Overflow or respective owner

Related posts about linux

Related posts about Performance