Attempting to use C3P0 with Mybatis - problem configuring

9 views
Skip to first unread message

Scott Walton

unread,
Feb 27, 2026, 8:29:27 AM (2 days ago) Feb 27
to mybatis-user
I have created a C3P0DataSourceFactory and in the factory, I configured all the required elements for C3P0 (url, user, password and a connectionCustomizer). I have given the class name of the datasource factory in the Mybatis config. I can succesfully run SQL statements through Mybatis only if I give Mybatis the full correct URL. I have verified (logging statements) that the datasourceFactory has been called, C3P0 has initialized, and the connectionCustomizer has been called. The difficulty is that Mybatis is using the url in the Mybatis config and not the connection provided by C3P0.

I have configured C3P0 in the DataSourceFactory and Mybatis in XML.

I know I must be missing one little piece somewhere, but I can't seem to find it!

Could someone please suggest how to correctly configure Mybatis to use connections from the C3P0?

Scott Walton

Scott Walton

unread,
Feb 27, 2026, 12:37:46 PM (2 days ago) Feb 27
to mybatis-user
Figured it out! What I didn't realize is that the url supplied to Mybatis is passed back to C3P0, along with the the user and password. So the only configuration information needed in the DataSourceFactory is that need for C3P0. At the same time I had a bug in my Mybatis mapper that made it look like the connection customizer wasn't functioning. Once I fixed those two elements, it works fine.

Scott Walton
Reply all
Reply to author
Forward
0 new messages