So I'm inside a MDB, and I execute some sort of JDBC 2.0 command, like statement.executeUpdate(), connection.commit(), or do a getConnection() with CONCUR_UPDATABLE, and get these sorts of errors:
It appears that my container is smart of enough to combine my JBDC data source and my MDB into one single transaction.
So I solved this by switching the bean from Container-managed transactions to Bean-managed transactions. This is definitely a hack, since I do not understand what the consequences exactly are of doing this.
(Let's just assume for the moment that I had a good reason for not using a entity EJB.)
Can someone help me figure out to do either one of two things? 1. Keep it at bean-managed, but understand the consequences of that, and anything I need to do to avoid issues. We're not big on full transactional 'stuff' anyway for this bean, so I don't need to start/commit a global transaction per se, but is there something I'm missing? Can I just leave it as is and not have issues?
2. Is there a way for my JDBC connection to properly participate in this 'global transaction'? Do I just do nothing and let the EJB Container commit my updates and close my connections? How do I obtain a "CONCUR_UPDATABLE" in a way that makes the system happy? Etc...
Just to set some context, I'm running the MDB on WebSphere Application Server 5.1, using MQ 5.3 as my JMS provider. [ October 05, 2007: Message edited by: Jimmy Ho ]
A global transaction would include dequeueing from the queue and subsequent processing by the MDB as a single unit of work. If the MDB throws an exception the message will not be dequeued and marked as processed.
You could modify your JDBC datasource to use XADatasource interface instead of a javax.sql.Datasource interface. XADatasource will participate in your global transaction and in my opinion will not complain about commit.
If you change the transaction mechanism to bean then our messaging system will not participate in the transaction unless you manually add code for it to do so. This could lead to your messages being removed from the queue even though your MDB had some failures processing it. You could, however add code in our MDB to put this message back into the queue for processing.