• Post Reply Bookmark Topic Watch Topic
  • New Topic

XADataSource vs. Common Everyday DataSource

 
Ted Bell
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I was reading over the XA portion of the JDBC 3.0 spec, and have a question about using XA DataSources.

It was my understanding that an XADS was only needed when more than one datasource/database was involved. After reading over a portion of the spec, now I am not so sure.

I have a case where a stateless EJB calls both an entity bean and a separate DAO class, and I want the staetless SB method to encompas one transaction. If I am right, I should actually be using an XA datasource for this, because this transaction is distributed (because it can span multiple physical connections), even though there is only a single underlying database.

Can someone tell me which is correct?

Thanks a bunch.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you are right. Without XA you are limited to local transations, not global ones.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think we need a XADataSource for the situation you just described. If there is only one local database, which the DAO ( i assume is getting the connection from the java.sql.DataSource) and CMP entity bean access (hopefully is using the same DataSource), i'm not sure why we need a
XADataSource. Can someone please clear our confusion?
thanks.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Art Vandelay:
Hi all,
(because it can span multiple physical connections), even though there is only a single underlying database.


I overlooked this part. Yes there are multiple connections but you can still use a Non XA Driver. For eg weblogic 8.1 has an option 'honouring global transactions'. This needs to be enabled. So if the DAO and EJB CMP are obtaining Connections from the Data Source within the same transaction context, weblogic will return the same connection object (that got associated with the tx context during the first access).
That way everything s'd still be fine.

Never used other app servers, so cant comment about this feature in other app servers.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!