Results 1 to 5 of 5

Thread: Two database connections at the same time

  1. #1
    Join Date
    Aug 2007
    Posts
    2

    Default Two database connections at the same time

    Hello.

    What would be the preferred way to connect to two databases at the same time using hibernate, spring and declarative transactions?

    We are trying to migrate data from source database to target database and manually created two Spring contexts with each using its own database.

    We are using the "DataSourceTransactionManager" to manage the declarative transaction in each Spring context created. When we manually start both Spring contexts and start both transactions with its own transaction manager, somehow both transactions become synchronized and need to be nested. If they aren't nested an Exception occurs (java.lang.IllegalStateException: Cannot deactivate transaction synchronization - not active). Why did both transactions synchronize? What would be the preferred way to manage the transactions in such a case?

    Any suggestion appreciated.

    Thanks, Tomaz

  2. #2
    Join Date
    Dec 2006
    Location
    Jakarta
    Posts
    45

    Default

    if i'm not mistaken
    using 2 database must use a JTATransactionManager
    Isyak Melton
    Senior IT Consultant

  3. #3
    Join Date
    Aug 2007
    Posts
    2

    Default

    Quote Originally Posted by isyak View Post
    if i'm not mistaken
    using 2 database must use a JTATransactionManager
    Thanks.. I'm aware of this but we don't want to use JTATransactionManager - it's too heavyweight. Is there another way?

  4. #4
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    Quote Originally Posted by quikee View Post
    I'm aware of this but we don't want to use JTATransactionManager - it's too heavyweight. Is there another way?
    No (not that I'm aware of). Why is it too heavy-weighted? You don't need to use a full-blown JEE server but can go with a lightweight solution like Jencks, JOTM or Atomikos. Of course there is a overhead from using JTA and it needs effort to set it up, but that's necessary when you need to synchronize the two transactions.

    Joerg
    This post can contain insufficient information.

  5. #5
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    You should be able to have 2 separate transaction managers for 2 databases. Can you post your datasource/transaction manager/transaction config please?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •