Discussions

EJB design: User Transaction & Connection

  1. User Transaction & Connection (8 messages)

    What I understand is that ,if I use a bean managed transaction using UserTransaction then I have to use UserTransaction.commit() ,rollback() etc, which in turn will call the JDBC related methods e.g. connection.commit().

    My question is..Is there any gain using the Java Transaction API in this case over the simple JDBC ?
  2. UserTransactions can be used across the container managed servcies, who can engage in a 2 PC. Ex: Can be used across JMS and Database. Where as the JDBC connection can be used only for a JDBC. Also even with in the JDBC if you want to use the JDBC connection for a transaction then you are holding the connection till the connection is released. Where as if you are using JTA then the transactions can be spanned across the Database connections. Hope this helps
  3. User Transaction & Connection[ Go to top ]

    Thanks Sattya ,
    In my case since I am using a single datasource(Sybase)so I am not going to make use of distributed transaction or two phase commit.

    It appears that Sybase do not supports distributed transactions even JTA is not working out ,so the only option left was to define the transaction boundaries yourself setting auto commit to false and use JDBC.

    I was speculating what I am loosing by not using JTA and how much value addition UserTransaction can provide over the vanilla JDBC in a Single transaction case.

    The only difference that appears to me for this particular case is that transactions can be spanned across the Database connections.

    What do you say ?
  4. Yes you are right! But you would face the problem of the Connection Management (hanging connections) when you are the jdbc way of managing the transactions. Consider a scenario when there is a abrupt killing of the server when you are in the middle of a transaction, the connections are seen to be hung. I had tried it sometime ago..

    I also did found that third party XA drivers are available for Sybase.

    HTH
  5. I was speculating what I am loosing by not using JTA and how much value addition UserTransaction can provide over the vanilla JDBC in a Single transaction case.The only difference that appears to me for this particular case is that transactions can be spanned across the Database connections.What do you say ?

    and What about the Connection Pooling of the Container? with JDBC you should manage it yourself.
  6. and What about the Connection Pooling of the Container? with JDBC you should manage it yourself.
    I can still use the Connection Poll offered by Server/Container.So no need to manage myself.I think connection pooling concept is not clubbed with the transaction management.
  7. You are right Naveen[ Go to top ]

    You are right. If you are not using distibuted transactions or two phase commit, then we can use simple JDBC transaction management. With this we are not going to loose any thing.
  8. Sybase poor transaction support[ Go to top ]

    None of the transaction will work in sybase if some one calls stored procedure having #temp tables.

    be aware of the stupid #temp tables in the procedures.

    In case you are just using simple statements then ensure you have a timeout on the connection objects otherwise they will just keep hanging
  9. Sybase poor transaction support[ Go to top ]

    Thanks for these valuable inputs.Since I know the response time for my transactions ,so adding some buffer on top of that ,may be 200 - 400 % and using that as a timeout for my connection to handle the hang situation should workout.