-->
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.  [ 2 posts ] 
Author Message
 Post subject: Not sure if C3PO is working
PostPosted: Thu Aug 20, 2009 4:28 am 
Newbie

Joined: Thu Aug 20, 2009 4:22 am
Posts: 7
Hi,
I'm using:
Hibernate 3
Spring 2.5.6
c3po-0.9.1


I have c3po configured in my spring-config.xml file :

Code:
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context.xsd
               http://www.springframework.org/schema/tx
               http://www.springframework.org/schema/tx/spring-tx.xsd
               http://www.springframework.org/schema/aop
               http://www.springframework.org/schema/aop/spring-aop.xsd">
   <bean id="datasourceGD"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="org.postgresql.Driver" />
      <property name="url" value="jdbc:postgresql://@DATABASENAME@" />
      <property name="username" value="digital" />
      <property name="password" value="d1gital" />
   </bean>
   <bean id="transactionManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="sessionFactory" ref="sessionFactory" />
   </bean>
   <bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="dataSource" ref="datasourceGD" />
      <property name="configLocation" value="classpath:hibernate.cfg.xml" />
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect
            </prop>
            <prop key="hibernate.jdbc.batch_size">0</prop>
            <!-- second level cache -->
            <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider
            </prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.cache.use_minimal_puts">true</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
            <!-- Connection pooling -->
            <prop key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
            <prop key="hibernate.c3p0.min_size">1</prop>
            <prop key="hibernate.c3p0.max_size">5</prop>
            <prop key="hibernate.c3p0.timeout">5000</prop>
            <!-- logging properties -->
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.format_sql">false</prop>
            <prop key="hibernate.use_sql_comments">false</prop>
         </props>
      </property>
   </bean>

</beans>


But when I run my app and monitor the connections on the postgres db it always goes way more than the setting for max_size. I also cannot see any debug for c3po so am not even sure if c3po is being picked up and used by the app.

Am I missing out a config setting?

Many thanks

Euan


Top
 Profile  
 
 Post subject: Re: Not sure if C3PO is working
PostPosted: Thu Aug 20, 2009 6:09 am 
Newbie

Joined: Thu Aug 20, 2009 4:22 am
Posts: 7
Hi,

I changed my spring-config.xml to the following:

Code:
<bean id="datasourceGD"
      class="com.mchange.v2.c3p0.ComboPooledDataSource">
      <property name="driverClass" value="org.postgresql.Driver" />
      <property name="jdbcUrl" value="jdbc:postgresql://localhost/digital" />
      <property name="user" value="digital" />
      <property name="password" value="d1gital" />
      <property name="maxPoolSize" value="30"/>
   </bean>


and this now seems to pick up the conneciton pool. The settings I have in the hibernateProperties section of the spring-config.xml seem to make no difference whatsoever, so at the moment it looks like they need to be set in the dataasource.

Not sure why though.

Code:
<property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect
            </prop>
            
            <prop key="hibernate.jdbc.batch_size">0</prop>
            <!-- second level cache -->
            <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider
            </prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.cache.use_minimal_puts">true</prop>
               <prop key="hibernate.cache.use_second_level_cache">true</prop>


            <!-- <prop key="hibernate.max_fetch_depth">100</prop>  -->
            <!-- Connection pooling -->
            <prop key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
            <prop key="hibernate.c3p0.min_size">1</prop>
            <prop key="hibernate.c3p0.max_size">30</prop>
            <prop key="hibernate.c3p0.timeout">5000</prop>
            <!-- logging properties -->
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.format_sql">false</prop>
            <prop key="hibernate.use_sql_comments">false</prop>
         </props>
      </property>


At any rate it looks like changing the class for the datasource to com.mchange.v2.c3p0.ComboPooledDataSource and adding the c3po values within this seems to produce the results I'm looking for. I'd love to know exactly why, still looking into it. If anyone has some thoughts on this I'd appreciate it.

Also, thanks to this post as I got the information I needed from it.

https://forums.hibernate.org/viewtopic.php?f=1&t=931159&start=0

Euan


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