-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Jboss / JTA / Multiple Database Configuration Example
PostPosted: Thu Feb 24, 2011 3:10 pm 
Newbie

Joined: Sat Jul 24, 2010 6:17 pm
Posts: 8
Hello friends -

For the life of me, I've been struggling to find a good example somewhere of a configuration example for setting up a situation using Hibernate to talk to multiple databases and wrap everything up in a JTA transaction. My business case is this:

1) Goto SqlServer. Get some values where exportedSw == false.
2) Based on those values, goto Oracle and look up some other values.
3) Take these values and make inserts into Mysql.
4) Update SqlServer telling it that I have successfully gotten the values handled, and I don't need to get them on the next run.
5) Repeat run.

Works great, but if I get a failure at step 4, I need step 3 not to commit.

OK, JTA is what I need. But I seriously am having big trouble finding an example of configuring a JTA solution for multiple databases. I get that my HibernateTransactionFactory definitions will need to be set appropriately, and that I can configure my datasources within Jboss to utilize an XA compliant driver. But what I don't see is how / where these tie together, and I also find myself wondering if I need to tie together within Jboss the datasources to be entangled logically; i,e., if I had two different applications, that both needed JTA support across different databases, what would this configuration look like?

Any insight is appreciated.

Thank you.

brian


Top
 Profile  
 
 Post subject: Re: Jboss / JTA / Multiple Database Configuration Example
PostPosted: Tue Sep 13, 2011 7:10 am 
Newbie

Joined: Tue Jul 15, 2008 8:27 am
Posts: 12
Location: Germany
I am currently also looking into how to properly use multiple DBs in Jboss (with Hibernate - though with a different focus...),

Here is what might help you:

Use XA-DataSources configuration instead of <local-tx-datasource>

Example:
Code:
<datasources>
    <xa-datasource>
        <!-- Example for PostgreSQL
        -->
        <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
        <xa-datasource-property name="ServerName">localhost</xa-datasource-property>
        <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
        <xa-datasource-property name="DatabaseName">myBDName</xa-datasource-property>
        <xa-datasource-property name="User">myDBUser</xa-datasource-property>
        <xa-datasource-property name="Password">PasswordOfMyDBUser</xa-datasource-property>
        <track-connection-by-tx />
   <jndi-name>myAppDS1</jndi-name>
    </xa-datasource>
</datasources>


and also add the other DataSources analogously, for proper TransactionHandling in JBoss search for XA and JBoss (didn't get that far, yet ;) )

Hope this helps,
Cheers, Arndt


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.