-->
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: c3po & MySQL causing "prepareStatement" error.
PostPosted: Fri Feb 13, 2004 5:40 am 
Newbie

Joined: Fri Feb 13, 2004 5:30 am
Posts: 1
Does anyone know why I would get the following exception when using c3p0 as my connection pool up against a MySQL DB? I realize that c3p0 doesn't support the new JDBC3 variants, but is there anything I can do to get around this exception? Maybe there's a param I need to tweak or a different driver I should be using?
=========================
java.lang.IllegalArgumentException: Unexpected number of args to prepareStatement [right now we do not support new JDBC3 variants!]
at com.mchange.v2.c3p0.stmt.ValueIdentityStatementCacheKey._find(ValueIdentityStatementCacheKey.java:79)
at com.mchange.v2.c3p0.stmt.StatementCacheKey.find(StatementCacheKey.java:45)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.checkoutStatement(GooGooStatementCache.java:90)
at com.mchange.v2.c3p0.impl.C3P0PooledConnection$ProxyConnectionInvocationHandler.invoke(C3P0PooledConnection.java:601)
at com.mchange.v2.c3p0.impl.$Proxy2.prepareStatement(Unknown Source)
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:246)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:524)
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:906)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)
at
*** SNIP ***
============================

Here's my hibernate.cfg.xml file:

<hibernate-configuration>
<session-factory>

<property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>

<property name="connection.url">jdbc:mysql://localhost:3306/yadda?autoReconnect=true</property>
<property name="connection.username">yadda</property>
<property name="connection.password"></property>

<property name="c3p0.max_size">4</property>
<property name="c3p0.min_size">2</property>
<property name="c3p0.timeout">10000</property>
<property name="c3p0.max_statements">10</property>

<property name="statement_cache.size">0</property>


<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<!-- Mapping files -->
<mapping resource="com/blah/blah/BLAH.hbm.xml"/>

</session-factory>
</hibernate-configuration>
===============================

and I'm using the latest MySQL J driver: mysql-connector-java-3.0.10-stable-bin.jar

Thanks for any help...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2004 1:18 am 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
Hi.

This is an outright limitation of the present version of c3p0 -- it doesn't have anything to do with MySQL or your JDBC driver. You cannot use Statement-pooling in conjunction with c3p0 if your application uses PreparedStatements that makes use of any of the following JDBC3 features:

- ResultSet holdability
- PreparedStatements returning autogenerated keys
- PreparedStatements generated with explicit rather than default column names
- PreparedStatements generated with explicit rather than default column indexes

The workaround, for the moment, is to turn statement pooling off, by leaving maxStatements set at 0. This limitation will be removed in the next major version of c3p0.

Sorry about this!

Steve Waldman
c3p0 maintainer


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 5:21 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
swaldman wrote:
This is an outright limitation of the present version of c3p0 -- it doesn't have anything to do with MySQL or your JDBC driver.


May be you should try Proxool ? (http://proxool.sourceforge.net


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 6:25 am 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
...by popular demand...

There's an interim release on Sourceforge of c3p0 [c3p0-0.8.4.5] that lifts the API restrictions on the poolable PreparedStatements. The original poster should now be able to turn on statement pooling and run his application without error. (Please try it! If you do have any problems let me know!)

As far as I know, all JDBC 3.0 API that an underlying JDBC driver supports is now supported by c3p0.

smiles,
Steve
(c3p0-maintainer)


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.