Results 1 to 6 of 6
  1. #1
    nanimtech is offline Member
    Join Date
    Apr 2008
    Posts
    5
    Rep Power
    0

    Thumbs up Exception : ResultSet is closed

    Hi folks
    I have a problem while closing the ResultSet in JDBC.
    iam using Postgre DB, here for normal execution it is working fine,
    but while we are doing load test at the rate of 30 or 40 hits to the
    application on a peak volume it is throwing the error like
    "PSQLException:This ResultSet is closed."
    can you please let me know what are all the possibilities....
    here is my DB releasing code..



    if (pConnection != null) {
    pConnection.close();
    pConnection = null;

    if (pStatement != null) {
    pStatement.close();
    pStatement = null;

    if(pResultSet != null) {
    pResultSet.close();
    pResultSet = null;




    All these statements are enclosed in try/catch block...


    I really appreciate for any thoughts...

    --Naresh

  2. #2
    rico16135 is offline Member
    Join Date
    Apr 2008
    Posts
    28
    Rep Power
    0

    Default

    why are you checking to see if it is null? just close it in a finally clause.

    your setting it to null after you close it.

  3. #3
    felixtfelix is offline Member
    Join Date
    Dec 2007
    Location
    Mumbai, India
    Posts
    37
    Rep Power
    0

    Default

    hi,

    You have to close the objects in the certain order

    1. ResultSet
    2. PreparedStatement
    3. Connection

    Regards
    Felix T

  4. #4
    danielstoner's Avatar
    danielstoner is offline Senior Member
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    191
    Rep Power
    7

    Default

    What line of code throws the exception? Does it happen when you try to use the ResultSet after a query? Can you show the actual code that uses the ResultSet and indicate the problem line?
    Daniel @ [www.littletutorials.com]
    Language is froth on the surface of thought

  5. #5
    sneha1284 is offline Member
    Join Date
    Aug 2009
    Posts
    1
    Rep Power
    0

    Default ResultSet is never null

    Just to add never check

    ResultSet rs;
    .
    .
    .
    .
    (rs != null)

    as the resultset is never null

  6. #6
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    800
    Rep Power
    6

    Default

    Close it in order.
    -----------------
    1.Close the resultset
    2.Close the statement
    3.Close the Connection

    Check whether connection is alive and also check whether Ur connection pooling object size is sufficient.
    Ramya:cool:

Similar Threads

  1. ResultSet size
    By bugger in forum JDBC
    Replies: 18
    Last Post: 06-25-2011, 08:36 PM
  2. Replies: 1
    Last Post: 03-08-2008, 06:41 PM
  3. ResultSet to XML
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-14-2008, 09:50 AM
  4. Empty ResultSet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-09-2008, 08:36 PM
  5. ResultSet example
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-20-2008, 08:59 AM

Posting Permissions

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