Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2004
    Posts
    10

    Unanswered: SQLException: java.sql.Connection.close() requested while a transaction is in progres

    I am trying to query (a SELECT) a dab3 database with JAVA JDBC API.

    The select query works fine, but when i try to close the JDBC Connection that I opened processing Query, I get the above titled error.

    The full stack trace is below:

    com.ibm.db2.jcc.b.SQLException: java.sql.Connection.close() requested while a transaction is in progress on the connection.The transaction remains active, and the connection cannot be closed.
    at com.ibm.db2.jcc.b.l.j(l.java:556)
    at com.ibm.db2.jcc.b.l.close(l.java:540)

    Any one got an idea how to resolve this?
    Thanks in advance,
    Jeeva

  2. #2
    Join Date
    Jan 2004
    Posts
    10

    Wink Re: SQLException: java.sql.Connection.close() requested while a transaction is in progres

    Sorry, for the typo - i meant db2 not db3!

  3. #3
    Join Date
    Jun 2003
    Posts
    2

    Re: SQLException: java.sql.Connection.close() requested while a transaction is in progres

    Got the same problem as you. I am using the type 2 com.ibm.db2.jcc.DB2Driver driver.

    Any luck?

  4. #4
    Join Date
    Jan 2004
    Posts
    10

    Re: SQLException: java.sql.Connection.close() requested while a transaction is in progres

    Yes, Got a solution - Kinda workaround.

    Before closing the connection, If I do a COMMIT, then connection closes normally.

    But Not sure Why do you have do a COMMIT for a SELECT is something unanswerd.

    The samething works alright without a COMMIt In ORACLE.

    Weird!

    -Jeeva

  5. #5
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: SQLException: java.sql.Connection.close() requested while a transaction is in pro

    Originally posted by jeeva
    Yes, Got a solution - Kinda workaround.

    Before closing the connection, If I do a COMMIT, then connection closes normally.

    But Not sure Why do you have do a COMMIT for a SELECT is something unanswerd.

    The samething works alright without a COMMIt In ORACLE.

    Weird!

    -Jeeva
    normally you would need to close ResultSet and Statement before attempting to close the Connection... I think this is where your problem lies.

  6. #6
    Join Date
    Jan 2004
    Posts
    10

    Re: SQLException: java.sql.Connection.close() requested while a transaction is in pro

    Yeah, I verified that we do Close the ResultSet. We are also closing Statement.

    Finally Close the COnnection - before which with out a COMMIT - it causes the error!

  7. #7
    Join Date
    Mar 2016
    Posts
    1

    Smile autocommit needs to be set true before close

    When you set autocommit=false before executing savepoint / rollback operations, you need to set autocommit=true before closing the connection.

Posting Permissions

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