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 656183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:41:09+00:00 2026-05-13T22:41:09+00:00

I am using NHibernate to connect to a legacy rdbms system. Under high production

  • 0

I am using NHibernate to connect to a legacy rdbms system. Under high production load the rdbms service fails. To maintain the availability we have a failover rdbms service. Is there a way to configure NHibernate to use the FailOver Connection String when the primary connection is down?

Additional Info: I am using Castle over NHibernate. If Castle provides handling of failover connections then that will also do it for me.

  • 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-05-13T22:41:10+00:00Added an answer on May 13, 2026 at 10:41 pm

    You can build your own NHibernate.Connection.IConnectionProvider which provides failover support.

    This should be a subclass of ConnectionProvider which overrides CloseConnection() GetConnection() and Configure().

    The connection provider is specified in your hibernate configuration as property connection.provider.

    Here is an untested implementation which is based on DriverConnectionProvider.

    public class FailoverConnectionProvider : ConnectionProvider
    {
        static string FailoverConnectionStringProperty = "connection.failover_connection_string";
        string failover_connstring;
    
        public override void CloseConnection(IDbConnection conn)
        {
            base.CloseConnection(conn);
            conn.Dispose();
        }
    
        public override IDbConnection GetConnection()
        {
            try {
                return GetConnection( ConnectionString );
            } catch {
                return GetConnection( failover_connstring );
            }
        }
    
        IDbConnection GetConnection( string connstring )
        {
            log.Debug("Obtaining IDbConnection from Driver");
            IDbConnection conn = Driver.CreateConnection();
            try {
                conn.ConnectionString = connstring;
                conn.Open();
            } catch (Exception) {
                conn.Dispose();
                throw;
            }
    
            return conn;
        }
    
        public override void Configure(IDictionary<string, string> settings)
        {
            base.Configure( settings );
    
            settings.TryGetValue(FailoverConnectionStringProperty, out failover_connstring);
    
            if (failover_connstring == null) {
                throw new HibernateException("Could not find connection string setting (set " + FailoverConnectionStringProperty + " property)");
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service using NHibernate, I am trying to connect this WCF
I am trying to connect to an Oracle Database using nHibernate. I can connect
I'm using NHibernate on a legacy database with Oracle 8i client. I can perform
I'm using NHibernate to connect to an ERP database on our DB2 server. We
I'm trying to connect my application with an Oracle database using NHIBERNATE 3.1.0.4000 version
I have a library that was written using nHibernate and I am trying to
I have a really strange issue when using hibernate to connect to a MySQLDB
I am using NHibernate with fluent mapping. I have the following scenario: public class
I'm using Fluent NHibernate (the NH3 build - #694) and LINQ to connect to
I am writing a desktop application using NHibernate to connect to the database. My

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.