-->
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: How do I enable c3p0 as connection pool
PostPosted: Fri Nov 14, 2003 8:08 pm 
Newbie

Joined: Fri Nov 14, 2003 8:03 pm
Posts: 1
Hi,

I tried to use c3po as connection pool.

I added the following entries to the property file

hibernate.c3p0.initialPoolSize 1
hibernate.c3p0.minPoolSize 5
hibernate.c3p0.maxPoolSize 20
hibernate.c3p0.timeout 45000
hibernate.c3p0.max_statements 50
hibernate.c3p0.validate false

and restarted my app ... it was still using
the Hibernate connection pooling.
So I was looking around in the example
property file and found the following entry and added
it to the property file:

hibernate.connection.provider_class net.sf.hibernate.connection.C3P0ConnectionProvider

But it is still not working.
I'm using Hibernate 2.0.3 and I have c3p0.jar on
my classpath.

Any idea why it's not working???

Thank you very much!

Rico


Top
 Profile  
 
 Post subject: You're missing equals signs in the hibernate.properties file
PostPosted: Fri Nov 14, 2003 8:59 pm 
Regular
Regular

Joined: Sun Sep 21, 2003 11:43 pm
Posts: 85
Location: Massachusetts
You listed hibernate.properties file properties without assigning them using the equal sign. When I put your lines into my hibernate.properties file for the 2.0.3 jar, it defaults to the built-in connection pool:

1. Using:
hibernate.c3p0.initialPoolSize 1
hibernate.c3p0.minPoolSize 5
hibernate.c3p0.maxPoolSize 20
hibernate.c3p0.timeout 45000
hibernate.c3p0.max_statements 50
hibernate.c3p0.validate false
hibernate.connection.provider_class net.sf.hibernate.connection.C3P0ConnectionProvider

You get:
Nov 14, 2003 7:47:23 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20

2. Using them with equals signs:
hibernate.c3p0.initialPoolSize=1
hibernate.c3p0.minPoolSize=5
hibernate.c3p0.maxPoolSize=20
hibernate.c3p0.timeout=45000
hibernate.c3p0.max_statement=50
hibernate.c3p0.validate=false
hibernate.connection.provider_class=net.sf.hibernate.connection.C3P0ConnectionProvider
You get:

Nov 14, 2003 7:57:38 PM net.sf.hibernate.connection.ConnectionProviderFactory newConnectionProvider
INFO: Initializing connection provider: net.sf.hibernate.connection.C3P0ConnectionProvider
Nov 14, 2003 7:57:38 PM net.sf.hibernate.connection.C3P0ConnectionProvider configure

I do find it strange that when in 2.0.3 when I use hibernate.cfg.xml instead of hibernate, I don't need to specify conneciton.provider_class for it to use c3p0.

Regards,
David


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 06, 2004 3:21 pm 
Newbie

Joined: Wed Sep 22, 2004 2:01 pm
Posts: 9
I am using Hibernate 2.1 and I can't get it to use c3po! I am using hibernate.cfg.xml and here is what I've got in it:

Code:
<hibernate-configuration>

    <session-factory>
        <!-- database properties -->
        <property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
        <property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
        <property name="connection.username">user</property>
        <property name="connection.password">xxx</property>
        <property name="connection.url">xxx</property>
      <!-- c3po -->
      <property name="c3po.max_size">15</property>
      <property name="c3po.min_size">1</property>
      <property name="c3po.timeout">200</property>
      <property name="c3po.max_statements">20</property>
      <property name="c3po.idle_test_period">300</property>
      <property name="c3po.acquire_increment">1</property>

        <property name="show_sql">true</property>
        <property name="use_outer_join">true</property>

        <!-- mapping files -->
        <mapping resource="ccnmtl/brownfield/Group.hbm.xml"/>
        <mapping resource="ccnmtl/brownfield/User.hbm.xml"/>
        <mapping resource="ccnmtl/brownfield/Test.hbm.xml"/>
        <mapping resource="ccnmtl/brownfield/HistoryEvent.hbm.xml"/>

    </session-factory>

</hibernate-configuration>


When Hibernate logs its startup, it mentions this:

net.sf.hibernate.cfg.Configuration - properties: {show_sql=true, java.vendor=Sun Microsystems Inc., catalina.base=/opt/tomcat4, hibernate.connection.url=xxx, catalina.useNaming=true, os.name=Linux,
sun.boot.class.path=/opt/tomcat4/common/endorsed/xercesImpl.jar:/opt/tomcat4/common/endorsed/xmlParserAPIs.jar:/opt/sun-jdk-1.4.2.05/jre/lib/rt.jar:/opt/sun-jdk-1.4.2.05/jre/lib/i18n.jar:/opt/sun-jdk-1.4.2.05/jre/lib/sunrsasign.jar:/opt/sun-jdk-1.4.2.05/jre/lib/jsse.jar:/opt/sun-jdk-1.4.2.05/jre/lib/jce.jar:/opt/sun-jdk-1.4.2.05/jre/lib/charsets.jar:/opt/sun-jdk-1.4.2.05/jre/classes, sun.java2d.fontpath=, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.4.2_05-b04,
user.name=root, connection.driver_class=oracle.jdbc.OracleDriver, user.language=en,
java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory, sun.boot.library.path=/opt/sun-jdk-1.4.2.05/jre/lib/i386,
dialect=net.sf.hibernate.dialect.Oracle9Dialect, java.version=1.4.2_05, version=2.4.1, user.timezone=US/Eastern, sun.arch.data.model=32, hibernate.use_outer_join=true,
java.endorsed.dirs=/opt/tomcat4/common/endorsed, sun.cpu.isalist=, file.encoding.pkg=sun.io, file.separator=/, java.specification.name=Java Platform API Specification, hibernate.cglib.use_reflection_optimizer=true,
java.class.version=48.0, hibernate.c3po.min_size=1, user.country=US,
connection.url=jdbc:oracle:thin:@chili.cc.columbia.edu:1521:acisora1, java.home=/opt/sun-jdk-1.4.2.05/jre, java.vm.info=mixed mode, os.version=2.4.20-gentoo-r2, hibernate.c3po.idle_test_period=300, hibernate.c3po.max_size=15, path.separator=:, connection.password=xxx, java.vm.version=1.4.2_05-b04, java.util.prefs.PreferencesFactory=java.util.prefs.FileSystemPreferencesFactory, hibernate.connection.password=xxx,
vendor-url=http://xml.apache.org/xalan-j, java.awt.printerjob=sun.print.PSPrinterJob, vendor=Apache Software Foundation, sun.io.unicode.encoding=UnicodeLittle, hibernate.c3po.max_statements=20, hibernate.connection.username=ccnmtl_bfa_dev, hibernate.c3po.acquire_increment=1, java.naming.factory.url.pkgs=org.apache.naming, user.home=/root, java.specification.vendor=Sun Microsystems Inc., org.xml.sax.driver=org.apache.crimson.parser.XMLReaderImpl, java.library.path=/opt/sun-jdk-1.4.2.05/jre/lib/i386/client:/opt/sun-jdk-1.4.2.05/jre/lib/i386:/opt/sun-jdk-1.4.2.05/jre/../lib/i386, java.vendor.url=http://java.sun.com/,
hibernate.connection.driver_class=oracle.jdbc.OracleDriver, connection.username=ccnmtl_bfa_dev, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=net.sf.hibernate.dialect.Oracle9Dialect, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=/opt/sun-jdk-1.4.2.05/lib/tools.jar:/opt/tomcat4/bin/bootstrap.jar, use_outer_join=true, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0,
catalina.home=/opt/tomcat4, sun.cpu.endian=little, sun.os.patch.level=unknown, java.io.tmpdir=/opt/tomcat4/temp, hibernate.c3po.timeout=300, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, os.arch=i386, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.ext.dirs=/opt/sun-jdk-1.4.2.05/jre/lib/ext,
user.dir=/usr/local/share/sandboxes/emattes/tomcat4_4080/brownfield, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, file.encoding=ANSI_X3.4-1968, java.specification.version=1.4, hibernate.show_sql=true}

and then following shortly afterwards, it says this:

net.sf.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)

and proceeds to set things up without c3po. What am I doing wrong?

Thanks!


Top
 Profile  
 
 Post subject: figured it out
PostPosted: Wed Oct 06, 2004 3:31 pm 
Newbie

Joined: Wed Sep 22, 2004 2:01 pm
Posts: 9
Sorry to bother, I figured it out looking at the previous post. (embarassing)...

I did not have this line:
Code:
<property name="connection.provider_class">net.sf.hibernate.connection.C3P0ConnectionProvider</property>


Hopefully nobody had time to look at my post :-)


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.