-->
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.  [ 14 posts ] 
Author Message
 Post subject: Unable to use BitMechanic JDBC connection pool
PostPosted: Sun Oct 03, 2004 10:33 am 
Newbie

Joined: Fri Oct 01, 2004 8:36 pm
Posts: 8
I'm trying to use the BitMechanic JDBC pool when creating Hibernate Sessions.,

My code in the Factory reads:

Code:
public static Session currentSession() {
        net.sf.hibernate.Session s = (net.sf.hibernate.Session) SESSION.get();
        // Open a new Session, if this Thread has none yet
        if (s == null) {
            try {
                s = SESSIONFACTORY.openSession((Connection) SqlMan.getConnection());
                SESSION.set(s);
            } catch (Exception e) {
                Logger.addError(e.toString());
            }
        }
        return s;
    }

My SqlMan.getConnection() class returns a java.sql.Connection. I'm getting an

Code:
java.lang.AbstractMethodError: com.bitmechanic.sql.PooledConnection.prepareStatement(Ljava/lang/String;I)Ljava/sql/PreparedStatement;


Any ideas?

Hibernate version:
2.1.6
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.solidstategroup.forum.Thread" table="H_Thread">
<meta attribute="class-description">
Represents a thread
</meta>

<id name="id" type="int">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>

<property name="subject" type="string" length="275" not-null="true"/>
<property name="numberOfViews" type="int" not-null="true"/>
<property name="numberOfReplies" type="int" not-null="true"/>
</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Session session = HibernateSession.currentSession();
Transaction tx = null;

try {
tx = session.beginTransaction();
Thread t = new Thread("Test", 5, 2);
session.save(t);
tx.commit();
} catch (Exception e) {
Logger.addError(e.toString());
} finally {
try {
session.close();
} catch (HibernateException e) {
Logger.addError(e.toString());
}
}

Full stack trace of any exception that occurs:
0 [main] INFO cfg.Environment - Hibernate 2.1.6
0 [main] INFO cfg.Environment - loaded properties from resource hibernate.properties: {hibernate.connection.username=root, hibernate.connection.password=spit69fire, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql://192.168.1.2:3306/test, hibernate.connection.driver_class=com.mysql.jdbc.Driver}
0 [main] INFO cfg.Environment - using CGLIB reflection optimizer
0 [main] INFO cfg.Configuration - configuring from file: hibernate.cfg.xml
125 [main] INFO cfg.Configuration - Mapping resource: com/solidstategroup/forum/Thread.hbm.xml
266 [main] INFO cfg.Binder - Mapping class: com.solidstategroup.forum.Thread -> H_Thread
360 [main] INFO cfg.Configuration - Configured SessionFactory: null
360 [main] INFO cfg.Configuration - processing one-to-many association mappings
360 [main] INFO cfg.Configuration - processing one-to-one association property references
360 [main] INFO cfg.Configuration - processing foreign key constraints
391 [main] INFO dialect.Dialect - Using dialect: net.sf.hibernate.dialect.MySQLDialect
407 [main] INFO cfg.SettingsFactory - Maximim outer join fetch depth: 2
407 [main] INFO cfg.SettingsFactory - Use outer join fetching: true
407 [main] INFO connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
407 [main] INFO connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
407 [main] INFO connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://192.168.1.2:3306/test
407 [main] INFO connection.DriverManagerConnectionProvider - connection properties: {user=root, password=spit69fire}
407 [main] INFO transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
422 [main] INFO cfg.SettingsFactory - Use scrollable result sets: true
422 [main] INFO cfg.SettingsFactory - Use JDBC3 getGeneratedKeys(): true
422 [main] INFO cfg.SettingsFactory - Optimize cache for minimal puts: false
422 [main] INFO cfg.SettingsFactory - Query language substitutions: {}
422 [main] INFO cfg.SettingsFactory - cache provider: net.sf.hibernate.cache.EhCacheProvider
438 [main] INFO cfg.Configuration - instantiating and configuring caches
563 [main] INFO impl.SessionFactoryImpl - building session factory
860 [main] INFO impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
java.lang.AbstractMethodError: com.bitmechanic.sql.PooledConnection.prepareStatement(Ljava/lang/String;I)Ljava/sql/PreparedStatement;
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at net.sf.hibernate.util.GetGeneratedKeysHelper.prepareStatement(GetGeneratedKeysHelper.java:39)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:254)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:525)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:932)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:775)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
at com.solidstategroup.forum.Test.main(Test.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Exception in thread "main"
Process finished with exit code 1

Name and version of the database you are using:
MySQL 4.0.20

The generated SQL (show_sql=true):
--
Debug level Hibernate log excerpt:
--


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 5:18 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Are you using JDK 1.3.1?
If true try to recompile Hibernate on this JDK.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 5:20 am 
Newbie

Joined: Fri Oct 01, 2004 8:36 pm
Posts: 8
I'm using JDK 1.4.2.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 5:30 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
So your driver seems not been compliant with the .sql package of the JDK 1.4.2

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 5:32 am 
Newbie

Joined: Fri Oct 01, 2004 8:36 pm
Posts: 8
I'm using the latest MySQL Connector, version 3.0.15. Could it be that the Connection Pooling code needs recompiling?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 5:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Your connection pool does not support JDBC3, apparently. Use a better connection pool, or yell at BitMechanic to fix it.

For a workaround, disable use of getGeneratedKeys() in hibernate.properties.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 5:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
P.S. Why do we always seem to get the blame when connection pools and JDBC drivers are broken??


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 5:36 am 
Newbie

Joined: Fri Oct 01, 2004 8:36 pm
Posts: 8
Apologies. I've just started learning Hibernate and really think it is an incredible API. I guess with the number of JDBC drivers and DBMS's there is a large potential for nasty little errors like this.

If I were to recompile the BitMechanic source code, would that help me?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 5:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
If I were to recompile the BitMechanic source code, would that help me?


Probably not. You would need to actually change the src to add support for the extra JDBC3 methods.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 5:42 am 
Newbie

Joined: Fri Oct 01, 2004 8:36 pm
Posts: 8
Ok. Thanks for your help. Maybe it's time to drop the BitMechanic stuff and use the Jakarta DBCP.

Are there any guides on best practise for things like Connection Pooling with respect to Hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 5:43 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
prefer c3p0 or proxool
all is documented on c3p0 and proxool site and of course hibernate wiki gives hints

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 5:49 am 
Newbie

Joined: Fri Oct 01, 2004 8:36 pm
Posts: 8
Thanks for the tips. Is there any reason as to why you prefer these two APIs?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 6:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Just experience, there seem to be more problems comming up with DBCP than with the other two.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 7:12 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you can also check
http://forum.hibernate.org/viewtopic.php?t=931132

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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