I ran across an interesting error today regarding cftransactions and multiple cfqueries inside of them.
The resulting error was
The root cause was that: java.sql.SQLException: Datasource names for all the database tags within CFTRANSACTION must be the same.
This seems pretty straightforward, until you start digging into the problem, and become led down a few wrongs paths courtesy of google serving up results that aren’t entirely true.
One of the discussions I found was an adobe tech note, which I discovered via a link from a post by Ben Nadal. In this tech note, the solution was to simply replace all cfexit tags, with a cfabort.
Simple, yes, except that I had NO cfexit tags within my cftry/cftransaction statement, they were already cfaborts!
Further investigation revealed that you simply cannot have multiple datasource names withing a cftransaction.
Now, with no actual documentation on the subject, and not actually knowing what spell coldfusion is uttering while it waves its wand over its magic hat, I cannot give a ‘good’ reason as to why. All I know is the problem was fixed once I removed the offending query to outside the cftransaction.
In order to duplicate the desired effect, you will have to keep track of the transactions, and rollback/commit based on the prior cftransaction attempts, which is a discussion for another post.
-Dave