Results 1 to 3 of 3
  1. #1
    Peter is offline Senior Member
    Join Date
    Jun 2007
    Posts
    119
    Rep Power
    0

    Default Oracle Resultset slow

    I have a problem with an Oracle Resultset using jdbc. It works about once a week when doing a simple
    long value = results.getLong("value");
    the process will hang and start spinning and use up about 75% of the CPU on the server. The only way to get it going again is to kill it and restart. As you can guess the other users aren't very happy when this happens.

    what's the problem???
    thanks
    Java Code:
    for(;;) {
    Statement mainStmt = connection.createStatement();
    java.sql.ResultSet results = getData(mainStmt);
    if (results != null) {
    String message = null;
    try {
    while (results.next()) {
    message = null;
    //this is the statement that hangs.
    mod_date = results.getLong("modified_date");
    try {
    message = createXMLString(results);
    publishMessage(message);
    } catch(Exception ex) {
    errorHandler(false, 0, procName,
    "Unable to create TextMessage for "
    + results.getString("ID") + ":" + ex.toString());
    message = null;
    publishError = true;
    }
    } //while
    
    results.close();
    results = null;
    mainStmt.close();
    
    } catch (Exception ex) {
    errorHandler(false, 0, procName, "unknown error:"
    + ex.toString());
    ex.printStackTrace();
    }
    }
    rest(60);
    } //for
    Last edited by Peter; 07-04-2007 at 01:53 PM.

  2. #2
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    7

    Default

    When you are creating following object
    Statement mainStmt = connection.createStatement();
    java.sql.ResultSet results = getData(mainStmt);
    in for loop will make the heap occupied with the objects. instead, place the same statements out side the for loop and also String message = null as well. Objects which are created in the loop, should be moved outside the loop, would solve your problem.

  3. #3
    Ed
    Ed is offline Senior Member
    Join Date
    Jun 2007
    Posts
    110
    Rep Power
    0

    Default

    Database object may not be closed properly, which is causing the pile up of objects in the heap

Similar Threads

  1. slow JasperReport
    By bbq in forum Advanced Java
    Replies: 3
    Last Post: 02-11-2008, 08:34 AM
  2. eclipse very slow
    By katie in forum Eclipse
    Replies: 2
    Last Post: 11-05-2007, 10:20 AM
  3. Replies: 1
    Last Post: 07-31-2007, 04:53 PM
  4. Export query result, procces is to slow
    By Daniel in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 06-28-2007, 06:35 PM
  5. Slow reports in Netbeans
    By Alan in forum NetBeans
    Replies: 1
    Last Post: 05-29-2007, 03:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •