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.

> 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.


>       } 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.


>              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

Reply via email to