-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: C3P0ConnectionProvider configured with datasource
PostPosted: Wed Dec 10, 2008 3:20 pm 
Newbie

Joined: Thu Dec 04, 2008 10:39 am
Posts: 3
Hibernate version: 3.2.5ga, hibernate-c3p0 3.3.0ga
c3p0 version: 0.9.1.2
Tomcat version: 6.0.18

Hibernate.cfg.xml mapping:
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/TESTDB</property>
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>

context.xml

<context>
<ResourceLink name="jdbc/TESTDB" global="jdbc/TESTDB" type="javax.sql.DataSource" />
</context>

Global resource in server.xml
<Resource auth="Container"
description="DB Connection"
driverClass="org.gjt.mm.mysql.Driver"
maxPoolSize="4" minPoolSize="2" acquireIncrement="1"
name="jdbc/TESTDB" user="rp_dbo" password="darmis"
factory="org.apache.naming.factory.BeanFactory"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
jdbcUrl="jdbc:mysql://localhost:3306/testdb" />


Stacktrace:

15:18:19,460 INFO C3P0ConnectionProvider:81 - C3P0 using driver: null at URL: null
15:18:19,460 INFO C3P0ConnectionProvider:82 - Connection properties: {}
15:18:19,460 INFO C3P0ConnectionProvider:85 - autocommit mode: false
15:18:19,460 WARN C3P0ConnectionProvider:88 - No JDBC Driver class was specified by property hibernate.connection.driver_class

Problem:
When configureing Hibernate to use C3P0ConnectionProvider instead of default connectionprovider it seems like Hibernate does not find my configured datasource.

If I remove C3P0ConnectionProvider from my hibernate configuration file, hibernate will find my resource and my test application can handle database transactions. When I try to use C3P0 by adding hibernate.connection.provicer_class C3P0ConnectionProvider it fails to find my datasource.

If I use C3P0ConnectionProvider and configure my datasource with driver_class, url, username and password in my hibernate config file. Hibernate will use C3P0 and it all works fine. So it seems like C3P0ConnectionProvider cannot be configured to use datasource configured in tomcat.

Any idea what i’m doing wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2008 5:04 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
If you have a DataSource in JNDI there's no need to tell Hibernate to use C3P0. By providing the C3P0 configuration, you're telling Hibernate to manage an instance of C3P0 and it is trying to do so, but missing other key configuration. Remove hibernate.connection.provider_class and you'll be OK (if you have a DataSource already). If not, then remove the .datasource property and configure C3P0 as per the Hibernate manual.

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2008 7:38 am 
Newbie

Joined: Thu Dec 04, 2008 10:39 am
Posts: 3
Thank you!

That makes sense. I have now configured C3P0 properties in my resource definition in tomcat (server.xml). Hibernate automatic detects that my JNDI resource is configured with C3P0 without C3P0ConnectionProvider.

My connection pool works fine now. Thank you cbredsen!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.