JTA is useful not only for different database, but also for different connection to the same database.
Transaction manager manage Transaction by begin / suspend / getTransaction / setTransactionTimeout, its other methods just delegate to Transaction
Transaction then delegate call to each XAResource in list.
Can close connection before JTA transaction commit? Yes, TransactionManager will call XAResource.end() method to disassociate the transaction from that connection (but sqls sent by this connection will still in effect), and the connection may (or may not) return to connection pool.