Hi, I'm using:
- JDK 1.6 - Tomcat 7.0.12 - Apache Commons DBCP 1.4 - MySQL 5.1.42 - The latest MySQL JDBC driver I have an application that, so far, hasn't had transactional processing. I mean I have the autocommit in "on" mode, so every update/delete gets commited separately. I need to fix it so it starts grouping changes to the DB in a transaction and implement the ACID stuff, using the commit and rollback. I read the documentation and it is not hard, but I have two complications: 1- I'm using DBCP, the connection pool: The way I have programmed my app is that a business object asks a resultset that comes after a query, which in turn asks for a statement, which in turn asks for a connection from the pool. That means that the business object dosn't know which connection from the pool will attend its requirement at the end. What should I do? Should I start asking the pool for a connection, set the autocommit to "false", use this connection for all the changes I need to make, then commit (or rollback), and then at the end "close" (return to the pool) the connection? Is that it? 2- My app uses two databases, even though both run inside the same MySQL instance. I mantain two DBCP pools, one for each database. Then how do I manage the transactions, if I need to make changes to both databases and that implies using two different connections? Do I need to use the JTA stuff that Java EE brings, for distributed processing, or is there an easier approach? Thanks a lot in advance!