Re: which transaction to be used ?
hi, this is not clear .
could you please tell precisely, what cant be done for JDBC?
DataSource ds1 =(DataSource)//jndi lookup
//transaction starts here
//trans ends here
Now, please tell...what cant be done here ?
If you perform an operation that need access to several *independent*
databases and that operation as a whole must be transactional, then the
jdbc transaction can not help you. A jdbc transaction only works within
*one* database at a time.
Consider this example:
You are building web interface for a stock exchange sales system. The
stock exchange already has a stock sales system, and a customer account
system, which are independent of each other, because of regulatory,
security and stability reasons. Now you want to add a web interface to
this. For obvious reasons you can not add this to the existing systems,
so you have to build a new system running independently of the others.
For the system to be able to perform its sales operations through the
web interface, it needs access to both the customer account system and
the stock sales system with system wide atomicity. That means that if
the sale fails in one of the two subsystems it will fail in all. This is
because you don't want to be charged for stocks you never received, and
the other part does not want to give you stocks for which you don't have
the money for)
This is why we have JTA. JTA also supports a wider sense of resources in
j2ee, not just database transactions, for example between different ejb
beans in different containers/machines etc.
Hope this clears things up for you.