How do I configure c3p0 checkoutTimeout?

Skip to first unread message

Tomas Ramirez

Sep 4, 2023, 3:09:24 PM9/4/23
to Fluent NHibernate
Hello, I'm super new to Fluent NHibernate, and ORMs in general; so maybe assume I don't know anything :D

How do I configure c3p0 checkoutTimeout, in Fluent NHibernate?

The app appears to be hanging when the DB server is offline, when it tries to run BuildSessionFactory. It sounds like I need to configure c3p0's checkoutTimeout, or else it will wait forever for the DB connection (

I failed to find any examples, and it looks like c3p0 has its own <c3p0-config> element, when you do it the XML way; so I'm not sure how I'm supposed to do that with Fluent NHibernate (

Here's what the code looks like:

_sessionFactory = Fluently.Configure()
    .Mappings(m => DatabaseHelper.BaseDbMappingsInMainDb.ForEach(db => m.FluentMappings.Add(db)))
.ExposeConfiguration(config =>
    config.SetProperty("prepare_sql", "true");
    config.SetProperty("command_timeout", "30");
    config.SetProperty("default_flush_mode", "Commit"); // default: Unspecified

So, I can see how I would normaly set properties; but since checkoutTimeout is a property under the nested <c3p0-config> element (which seems to be nested under the normal config element), I doubt it's going to work if I just try to configure it directly.

(I am about to start experimenting with the code; but this is a weird little sub-app that runs within an installer; so it's not trivially easy for me to test this code out, at the moment.)

Many thanks.

Tomas Ramirez

Sep 5, 2023, 1:30:48 PM9/5/23
to Fluent NHibernate
I never figured out the answer to this question; but I was able to solve my problem. SQL Server's connection string has the Connection Timeout property, and whoever wrote this code originally accidentally set it to 10000, probably thinking milliseconds, but it's seconds, so about 2.78 hrs; which is why it appeared to be waiting indefinitely.
Reply all
Reply to author
0 new messages