Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    4

    Question Unanswered: transaction not started unless setAutoCommit(false)

    Note : Tested using all late versions of Sybase JConnect.


    re : java.sql.Statement.executeUpdate(String)
    and java.sql.Connection.setAutoCommit(Boolean)

    I was under the impression that whenever executeUpdate() was called a transaction would be started so that the sql in the executeUpdate would execute within the context of a transaction.

    I have found that this is not the case.

    JConnect only starts a transaction if setAutoCommit(false) is in effect.

    This doesn't seem right to me because the sql string in executeUpdate() could contain a number of insert/update/delete operations that should be atomic.

    Does this behaviour seem correct or is JConnect broken ??

  2. #2
    Join Date
    Jun 2002
    Location
    Argentina
    Posts
    78
    I think is correct.
    I have been working with Powerbuilder and I find this trouble very often with the programmers.
    When You use AutoCommit True, then Powerbuilder don't start any transactions, and in that way every insert, delete or update are make automatic and you will not need execute any commit statement
    But if you set AutoCommit False, then Powerbuilder send a Commit statement to the server, then every insert, delete or update will be into a transaction and you will need execute a commit or rollback to end.
    May be this help you with jconnect.

    Bye

    Sebastian Velasco

  3. #3
    Join Date
    Mar 2003
    Posts
    10

    Re: transaction not started unless setAutoCommit(false)

    Hi

    I'am not a jConnect expert but I guess this is due to the default ASE 's behavior.
    ASE uses by default the non chained mode, in another words it does not open a explicit transaction and thus it performs commit automoticly.
    In this case you must open transactions explitcly (begin transaction)

    When set chained = on ASE open implicity a transaction, but does not commit implicity, thus you must commit or rollback explictly.

    I suspect that setAutoCommit property modifies the chained setting of ASE.

    HTH

    Emmanuel

    Originally posted by johnlon
    Note : Tested using all late versions of Sybase JConnect.


    re : java.sql.Statement.executeUpdate(String)
    and java.sql.Connection.setAutoCommit(Boolean)

    I was under the impression that whenever executeUpdate() was called a transaction would be started so that the sql in the executeUpdate would execute within the context of a transaction.

    I have found that this is not the case.

    JConnect only starts a transaction if setAutoCommit(false) is in effect.

    This doesn't seem right to me because the sql string in executeUpdate() could contain a number of insert/update/delete operations that should be atomic.

    Does this behaviour seem correct or is JConnect broken ??

Posting Permissions

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