Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8745437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:00:48+00:00 2026-06-13T12:00:48+00:00

I’ve got two DB providers configured in my spring config like this (spread across

  • 0

I’ve got two DB providers configured in my spring config like this (spread across two different files)

<db:provider id="FirstDbProvider"
                   provider="MySql"                   connectionString="Database=xxxxxxx;Host=xxxxxxx;Username=xxxxxxx;Password=xxxxxxxxx"/>

  <db:provider id="SecondDbProvider"
                   provider="MySql"                   connectionString="Database=xxxxxxx;Host=xxxxxxx;Username=xxxxxxx;Password=xxxxxxxxx"/>

But when I try and run my app, it fails when creating the sessionFactory that makes use of SecondDBProvider. I get this

SecondSessionFactory’ defined in ‘file [Second.Dao.xml] line 21’ : Initialization of object failed : There was no DB provider available, unable to create connection

Should I be OK to use two DB Providers in this way? Any ideas what might be causing this error. I can connect to the database from the command line using the credentials etc specified in my DB Provider.

It works perfectly if I go back to just having one database.
I can add the second db:provider to my spring.dao.xml file and it all still works (i.e. I can retrieve an entity from the first database).
It’s only when I add a second sessionFactory that it stops working and I can’t retrieve anything, not even from the first database.

So, I guess something somewhere is being shared perhaps and causing a conflict

Update

Here’s the config (I renamed some things for obvious reasons)

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
         xmlns:db="http://www.springframework.net/database">

  <!-- Referenced by main application context configuration file -->
  <description>
    Config for Database 1
  </description>

  <!-- Property placeholder configurer for database settings -->
  <object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
    <property name="ConfigSections" value="databaseSettings"/>
  </object>

  <!-- Database Configuration -->
  <db:provider id="FirstDbProvider"
                   provider="MySql"
                   connectionString="Database=xxxxx;Host=xxxxxxx;Username=xxxxxx;Password=xxxxxx"/>

  <!-- NHibernate Configuration -->
  <object id="FirstSessionFactory" type="Utils.Hibernate.CustomLocalSessionFactoryObject, Utils">
    <property name="DbProvider" ref="FirstDbProvider"/>
    <property name="MappingAssemblies">
      <list>
        <value>FirstDao.Dao</value>
      </list>
    </property>
    <property name="HibernateProperties">
      <dictionary>
        <entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
        <entry key="dialect" value="NHibernate.Dialect.MySQLDialect"/>
        <entry key="connection.driver_class" value="NHibernate.Driver.MySqlDataDriver"/>
        <entry key="use_proxy_validator" value="false" />
        <entry key="show_sql" value="true"/>
        <entry key="format_sql" value="false"/>
        <entry key="generate_statistics" value="false"/>
        <entry key="adonet.batch_size" value="20"/>
        <entry key="hbm2ddl.auto" value="update"/>
        <entry key="prepare_sql" value="true"/>
      </dictionary>
    </property>
    <property name="ExposeTransactionAwareSessionFactory" value="true" />
  </object>


  <!-- Transaction Management Strategy - local database transactions -->
  <object id="transactionManager"
        type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate32">

    <property name="DbProvider" ref="FirstDbProvider"/>
    <property name="SessionFactory" ref="FirstSessionFactory"/>

  </object>

  <!-- Exception translation object post processor -->
  <object type="Spring.Dao.Attributes.PersistenceExceptionTranslationPostProcessor, Spring.Data"/>

  <!-- Data Access Objects -->
  <object id="firstDao" type="FirstDao.Dao.MyDao, HRDataCheck.Dao">
    <property name="SessionFactory" ref="FirstSessionFactory"/>
  </object>

</objects>

Here’s my second file (for the other DBProvider)

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
         xmlns:db="http://www.springframework.net/database">


  <!-- Database Configuration -->
  <db:provider id="SecondDbProvider"
                   provider="MySql"
                   connectionString="Database=xxxxxx;Host=xxxxxx;Username=xxxxx;Password=xxxxxxxx"/>

  <!-- NHibernate Configuration -->
  <object id="SecondSessionFactory" type="Utils.Hibernate.CustomLocalSessionFactoryObject, Utils">
    <property name="DbProvider" ref="SecondDbProvider"/>
    <property name="MappingAssemblies">
      <list>
        <value>SecondDao.Dao</value>
      </list>
    </property>
    <property name="HibernateProperties">
      <dictionary>
        <entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
        <entry key="dialect" value="NHibernate.Dialect.MySQLDialect"/>
        <entry key="connection.driver_class" value="NHibernate.Driver.MySqlDataDriver"/>
        <entry key="use_proxy_validator" value="false" />
        <entry key="show_sql" value="true"/>
        <entry key="format_sql" value="false"/>
        <entry key="generate_statistics" value="false"/>
        <entry key="adonet.batch_size" value="20"/>
        <entry key="prepare_sql" value="true"/>
      </dictionary>
    </property>
    <property name="ExposeTransactionAwareSessionFactory" value="true" />
  </object>


  <!-- Data Access Objects -->
  <object id="secondDao" type="Blah.SecondDao, SecondDaoAssembly">
    <property name="SessionFactory" ref="SecondSessionFactory"/>
  </object>

</objects>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:00:49+00:00Added an answer on June 13, 2026 at 12:00 pm

    Here is your problem: You have no transactions management setup for your SecondSessionFactory.

    <object id="transactionManager"
             type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate32">
         <property name="DbProvider" ref="FirstDbProvider"/>
         <property name="SessionFactory" ref="FirstSessionFactory"/>
    
       </object>
    

    try
    <!--Transaction Management Strategy - local database transactions-->
    <object id="transactionManager" type="Spring.Data.Core.TxScopeTransactionManager, Spring.Data">
    <property name="TransactionSynchronization" value="Always"/>
    </object>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I would like to count the length of a string with PHP. The string
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.