Dne četrtek 05 julij 2001 18:45 ste napisali:
> Jure Lodrant wrote:
> > Hi,
> >
> > here is my problem:
> >
> > I have a sample session bean connecting to a postgres datasource (Using
> > JBOSS 2.2.2 here).
>
> You're connecting by getting a DataSource from JNDI, right? You should be.
>
using InitialContext.lookup() here for DataSource
> > A bussiness
> > method goes like this:
> >
> > try {
> > con.setAutoCommit(false);
>
> Don't do that. You'll never get a connection with autocommit on in any
> EJB container.
>
> > updateOrderItem(productId, orderId);
> > updateInventory(productId, quantity);
> > con.commit();
>
> Don't do that. The connection is enlisted in a transaction, use the
> transaction features. Just returning from the method will commit the
> transaction.
I should say that's not true when using Bean Managed Transactions as opposed
to Container managed transactions.
>
> > } catch (Exception ex) {
> > try {
> >
> > con.rollback();
>
> Don't do that. Again, use the transaction features. To rollback, just
> call the 'setRollbackOnly' method on your session context.
>
setRollbackOnly is used in EJB's using Container managed transactions which
is not the case here.
> > throw new EJBException("Transaction failed: " +
> > ex.getMessage()); } catch (Throwable sqx) {
> > throw new EJBException("Rollback failed: " +
> > sqx.getMessage()); }
> > }
> > }
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user