-->
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.  [ 4 posts ] 
Author Message
 Post subject: Configure c3p0 as connection pool
PostPosted: Mon Mar 08, 2010 9:00 am 
Newbie

Joined: Sat May 10, 2008 7:39 am
Posts: 4
I want to use the c3p0 connection pool, but i just cannot configure hibernate to use it.
Please can somebody assist me? Pleeeease ...

Here is what i have done so far:

In my maven pom.xml i declared these dependencies:
Code:
<dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-core</artifactId>
         <version>3.3.2.GA</version>
      </dependency>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-entitymanager</artifactId>
         <version>3.4.0.GA</version>
      </dependency>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-c3p0</artifactId>
         <version>3.3.2.GA</version>
      </dependency>
      <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
         <version>5.1.12</version>
         <scope>compile</scope>
      </dependency>
      <dependency>
         <groupId>c3p0</groupId>
         <artifactId>c3p0</artifactId>
         <version>0.9.1.2</version>
      </dependency>

In my persistence.xml i have this configuration:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
  <persistence-unit name="xxxPU" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>xxxx</class>
    <class>xxxx</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
      <property name="hibernate.connection.username" value="xxx"/>
      <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
      <property name="hibernate.connection.password" value="xxx"/>
      <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/xxx"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
      <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
      <property name="hibernate.hbm2ddl.auto" value="update"/>
      <property name="hibernate.show_sql" value="false"/>
      <property name="hibernate.format_sql" value="false"/>
      <property name="connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/>
      <property name="hibernate.c3p0.acquire_increment" value="1"/>
      <property name="hibernate.c3p0.idle_test_period" value="60"/>
      <property name="hibernate.c3p0.max_size" value="10"/>
      <property name="hibernate.c3p0.max_statements" value="0"/>
      <property name="hibernate.c3p0.min_size" value="2"/>
      <property name="hibernate.c3p0.timeout" value="60"/>
      <property name="hibernate.c3p0.validate" value="false"/>
    </properties>
  </persistence-unit>
</persistence>

And finally in my application i use the persistence unit like this:
Code:
emf = Persistence.createEntityManagerFactory("xxxPU");

But the hibernate log always tells me:
Quote:
[INFO] Started Jetty Server
INFO - Version - Hibernate Annotations 3.4.0.GA
INFO - Environment - Hibernate 3.3.2.GA
INFO - Environment - hibernate.properties not found
INFO - Environment - Bytecode provider name : javassist
INFO - Environment - using JDK 1.4 java.sql.Timestamp handling
INFO - Version - Hibernate Commons Annotations 3.1.0.GA
INFO - Version - Hibernate EntityManager 3.4.0.GA
...
INFO - rManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)

I must be mistaken somewhere. Does anybody see the problem?


Top
 Profile  
 
 Post subject: Re: Configure c3p0 as connection pool
PostPosted: Mon Mar 08, 2010 9:54 am 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
Hi,
try using this
Code:
<property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/>


Top
 Profile  
 
 Post subject: Re: Configure c3p0 as connection pool
PostPosted: Mon Mar 08, 2010 12:05 pm 
Newbie

Joined: Sat May 10, 2008 7:39 am
Posts: 4
Thank you very much. I had that property in the configuration file but i missed the hibernate prefix.
Thanks so much :-) !!!


Top
 Profile  
 
 Post subject: Re: Configure c3p0 as connection pool
PostPosted: Thu Aug 01, 2013 1:48 pm 
Newbie

Joined: Mon Dec 19, 2011 8:10 pm
Posts: 1
Oddly, for me I don't have to explicitly call out the provider_class, and it "just works" but maybe it's better to do it explicitly?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.