Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot get Hibernate 3.1 to work with c3p0

 
Chris Johnston
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is driving me crazy. Especially since I cannot seem to find any info
about the problem on Google.

Here is the deal, I have set up Hibernate and as long as I use its built in
JDBC connection pooling, everything works fine. However, as soon as I try
and use c3p0, nothing works. I have a JUnit test class that tests my
PersistenceDAO against a live MySQL 4.x database. Basically, it tries to
insert, update, delete a bunch of objects to make sure that Hibernate is
working correctly. This works fine, all tests pass, if I don't use c3p0. As
soon as I turn it on, not a single test passes. I have no idea what is going
on here. In an attempt to answer as many questions as possible, please see
below:

IDE: NetBeans 5.0

Hibernate: version 3.1 using the library version that come bundled with it.
c3p0: version c3p0-0.9.0.jar (I have tried the latest version as well,didn't work)
MySQL: version 4.1.20 running on CentOS 4.3
JDBC: mysql-connector-java-3.1.12-bin.jar

Below are my hibernate config file and, as far as I can tell, the important
parts from the stack trace. As you can see from the config file, I am using
what is more or less a default use of c3p0, but nothing is working. Below
everything, I have also included the source code from one of the methods
from my PersistenceDao class in case the problem is in the code.

Thanks for the help with this,
Chris


hibernate.cfg.xml


The stacktrace



PersistenceDao method


[ July 03, 2006: Message edited by: Chris Johnston ]
[ July 03, 2006: Message edited by: Chris Johnston ]
 
Chris Johnston
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I seemed to have fixed the problem, but I don't really understand how. I commented out the following statement in my hibernate.cfg file and the tests passed



I don't understand why that would make such a big difference. Can someone explain this please?
 
ravi bhosale
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Me to also faced problem with Hibernate 3.1.2 and c3po. Finally its solved by building source of c3p0-0.9.0.2.

For me problem is because of different log4j version used by Hibernate and C3po. But now its working.
 
Nobody Cares
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am experiencing exactly the same issue...has anyone resolved this issue since the initial post?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Nobody Cares",

You are quite inccorect. We do care! Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
nirumagic tniranjan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, try as in below.

session.saveOrUpdate(object);
session.commit();


If you want use connection pooling better use jndi lookup. It is the best practise and nice performence.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic