#1
  1. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Posts
    26
    Rep Power
    0

    jdbc connection..


    Hi,

    a simple question..

    I open a connection to a oracle/mysql db.
    Create a statement
    Create a ResultSet

    Execute statement..
    execute the Resultset..

    DONT close the statement..
    DONT close the ResutlSet

    CLOSE the connection..

    Would this automatically close the statement and resultset??

    any explanations??
    thnx,
    sgaucho
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    From the javadoc:
    public void close()
    throws SQLException

    Releases a Connection's database and JDBC resources immediately instead of waiting for them to be automatically released.
    That sounds to me like everything gets closed. And I know for a fact that you can't use a ResultSet after the connection has been closed.
  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Posts
    26
    Rep Power
    0
    Thnx...

    but i had read somewhere that not closing the statements would leave open cursors in the database.. isnt it so?

    My problem is I am opening connections to both Oracle and Mysql Databases and at the end of the script closing the connections to both..

    But no matter what I do, I c that the connections are not freed at all.. In one case I open two connections to 2 diff databases in MySQL and in the Mysqlfront I see that about 40 connections are spawned/created and hardly 50 % are closed/freed at the end!!!!!

    Why does this happen and how do I remedy this??

    thnx again,
    sands
  6. #4
  7. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Well, it's possible that java hasn't gotten around to garbage collecting the connections, yet. That seems like it would be horribly innefficient to me, though.

IMN logo majestic logo threadwatch logo seochat tools logo