-->
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.  [ 10 posts ] 
Author Message
 Post subject: Best Connection pool for production use
PostPosted: Tue May 30, 2006 1:40 pm 
Newbie

Joined: Tue May 30, 2006 2:49 am
Posts: 7
Hi

I am new to Hibernate. Can anybody tell me , which is the best connection pool for production use with Hibernate 3.1.3. And how can I configure it? What are the entries required in hibernate.cfg.xml file?

Thanks and Regards
Albin Joseph
http://www.javacertificate.net


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 8:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
This depends on your deployment model. Also is subjective. Anyway;

Application server: The best is to use the application server's connection pool/data resource(s).

Non-application server: I use C3P0. Configuring is easy and samples are in the documentation and on C3P0 web site.


Top
 Profile  
 
 Post subject: Re: Best Connection pool for production use
PostPosted: Wed May 31, 2006 5:48 am 
Beginner
Beginner

Joined: Wed May 17, 2006 3:38 am
Posts: 45
Hibernate supports the following connection pool:
for production - C3PO, Apache DBCP and Proxol
for trivial testing - there is default pooling mechanism
[C3PO, Proxol are recommended]

You must test it out to see which connection pool suits you best.
For example, if you use C3P0, then you can mention it in the hibernate.properties as:

hibernate.c3p0.property=value

There are several properties:for example
hibernate.c3p0.min_size=5

refer Hibernate API doc and C3P0 doc for details


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 8:29 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
As of Hibernate 3, Hibernate doesn't officially support Apache DBCP anymore.

Ref: http://forum.hibernate.org/viewtopic.php?t=942293&highlight=apache+dbcp

[edit]I thought there was a post from gavin or one of the other team members that was stickied for a while explaining this, but I can't find it for the life of me.


Last edited by pmularien on Wed May 31, 2006 8:51 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 8:38 am 
Beginner
Beginner

Joined: Wed May 17, 2006 3:38 am
Posts: 45
Thanks for that update


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 11:28 am 
Newbie

Joined: Tue May 30, 2006 2:49 am
Posts: 7
I am using Tomcat as my container. But I don't want to use tomcat's connection pooling mechanism.

Thanks to all.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 1:20 pm 
Newbie

Joined: Tue May 30, 2006 2:49 am
Posts: 7
I have configured c3po in my application. But now I am getting an exception. Below is the stack trace of my application.

java.lang.NoClassDefFoundError: com/mchange/v2/c3p0/PoolConfig
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:84)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:366)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at com.javacertificate.data.table.Exam.findByPrimaryKey(Unknown Source)
at com.ibm._jsp._exam._jspService(_exam.java:74)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:88)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:117)
at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.handleRequest(JSPExtensionServletWrapper.java:171)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2837)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:220)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:204)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1681)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback.java:201)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:103)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:548)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:934)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1021)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1332)


Below is my c3p0.properties file.

c3p0.acquireIncrement = 2
c3p0.acquireRetryAttempts = 25
c3p0.acquireRetryDelay = 1000
c3p0.autoCommitOnClose = false
c3p0.automaticTestTable
c3p0.breakAfterAcquireFailure
c3p0.checkoutTimeout = 0
c3p0.connectionTesterClassName
c3p0.factoryClassLocation
c3p0.forceIgnoreUnresolvedTransactions
c3p0.idleConnectionTestPeriod
c3p0.initialPoolSize =
c3p0.maxIdleTime
c3p0.maxStatementsPerConnection
c3p0.numHelperThreads
c3p0.preferredTestQuery
c3p0.propertyCycle
c3p0.testConnectionOnCheckin
c3p0.testConnectionOnCheckout
c3p0.usesTraditionalReflectiveProxies



Below is my hibernate.cfg.xml file

<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.acquire_increment">2</property>
<property name="hibernate.c3p0.idle_test_period">100</property>
<property name="hibernate.c3p0.max_size">100</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.min_size">10</property>
<property name="hibernate.c3p0.timeout">100</property>

What is the solution for this problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 2:51 am 
Beginner
Beginner

Joined: Wed May 17, 2006 3:38 am
Posts: 45
"NoClassDefFoundError" should be a class-path problem.....so whether all necessary jar files are there in the classpath has to be checked if you use IDE(from project properties) or "CLASSPATH" variable, if you use console(windows/unix)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 2:54 am 
Newbie

Joined: Tue May 30, 2006 2:49 am
Posts: 7
If I am removing the c3po.properties from my classpath, The code is working fine. So all the required jar files are present in the classpath. I guess there is something wrong with the properties file.

_________________
Thanks and Regards

Albin Joseph
http://www.javacertificate.net


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 3:00 am 
Beginner
Beginner

Joined: Wed May 17, 2006 3:38 am
Posts: 45
I am not sure about the c3p0.properties file....why are you using it when the properties are mentioned in the .cfg file itself....this redunduncy may perhaps is confusing the Hibernate Loader mechanism


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