You do not have to do anything "special" to handle a distributed transaction.
Conceptually, in between the begin and end of a transaction whatever you do is inside the ambit of that transaction. Whether you update 2 databases, 1 Database and 1 JMS queue or 100 databases, it does not really matter.
All it matters is that the driver must support distributed transactions i.e. it must be an XA driver.
In case you are using weblogic,
this article will give you a good idea.