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:
--