is is possible to use C3P0 with GoogleSQL?

418 views
Skip to first unread message

Pascal Voitot Dev

unread,
Nov 3, 2011, 4:54:25 AM11/3/11
to google-cloud...@googlegroups.com
Hello,
I'm trying to plug a C3P0 pooled datasource on GoogleSQL.
Due to the GAE/JRE class whitelist, I'm stuck with missing classes...
The main one is:
java.lang.NoClassDefFoundError: javax/naming/NamingException

Is it simply impossible to use C3P0 with GoogleSQL/GAE or is there a work-around?

If it's impossible to use C3P0, what do you advise to replace it and get a datasource and not only a conection as explained in the doc? (BasicDataSource?)

thanks in advance
Pascal

Rob Clevenger

unread,
Nov 3, 2011, 9:38:14 AM11/3/11
to google-cloud...@googlegroups.com
I've heard others have success with Apache DBCP,  however I don't think a connection pool is required. The time to check a connection for validity should be close to the time to open a new connection.

If you do use one, make sure the connection is valid before using one from the pool (using Connection.isValid() or a simple query, like "DO 1")

Rob

Pascal Voitot Dev

unread,
Nov 3, 2011, 9:46:31 AM11/3/11
to google-cloud...@googlegroups.com
I'll try that...
The connection model is not really clear in the doc.
Apparently this is MySQL but it's a GAE JDBC Driver so we don't really know what this driver does or not...
How does it work? One connection per GAE instance or something like that?

Thanks
Pascal

Rob Clevenger

unread,
Nov 3, 2011, 9:47:46 AM11/3/11
to google-cloud...@googlegroups.com
You don't want to share it across requests, I typically open  the connection at the beginning of a request and close it at the end.

Rob

Pascal Voitot Dev

unread,
Nov 3, 2011, 9:53:08 AM11/3/11
to google-cloud...@googlegroups.com
On Thu, Nov 3, 2011 at 2:47 PM, Rob Clevenger <rcle...@google.com> wrote:
You don't want to share it across requests, I typically open  the connection at the beginning of a request and close it at the end.


Yes this is a good manner in a stateless world :)
Anyway, I'm trying to plug GoogleSQL to Play+Siena and I try to modify the least possible! Play uses C3P0 ComboPooledDatasource and C3P0 requires NamingException :(. So I'll try to plug Apache DBCP instead of that...

Pascal
 

javabuddy

unread,
Nov 3, 2011, 10:38:56 AM11/3/11
to Google Cloud SQL discuss
I tried datanucleus + DBCP but no luck. Let me know if you find
anything different.

On Nov 3, 8:53 am, Pascal Voitot Dev <pascal.voitot....@gmail.com>
wrote:
> On Thu, Nov 3, 2011 at 2:47 PM, Rob Clevenger <rclev...@google.com> wrote:
> > You don't want to share it across requests, I typically open  the
> > connection at the beginning of a request and close it at the end.
>
> Yes this is a good manner in a stateless world :)
> Anyway, I'm trying to plug GoogleSQL to Play+Siena and I try to modify the
> least possible! Play uses C3P0 ComboPooledDatasource and C3P0 requires
> NamingException :(. So I'll try to plug Apache DBCP instead of that...
>
> Pascal
>
>
>
>
>
>
>
> > Rob
>
> > On Thu, Nov 3, 2011 at 6:46 AM, Pascal Voitot Dev <
> > pascal.voitot....@gmail.com> wrote:
>
> >> I'll try that...
> >> The connection model is not really clear in the doc.
> >> Apparently this is MySQL but it's a GAE JDBC Driver so we don't really
> >> know what this driver does or not...
> >> How does it work? One connection per GAE instance or something like that?
>
> >> Thanks
> >> Pascal
>

Pascal Voitot Dev

unread,
Nov 3, 2011, 1:16:33 PM11/3/11
to google-cloud...@googlegroups.com
Ok I have some success (DDL works, tables are created) but now i have this weird error when trying to insert rows.
Siena creates a preparedstatement with a few parameters and when calling preparedstatement.setObject, it gives a NPE.
Caused by: java.lang.NullPointerException
	at com.google.cloud.sql.jdbc.PreparedStatement.setObject(PreparedStatement.java:407)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:165)
	at siena.jdbc.JdbcPersistenceManager.setParameter(JdbcPersistenceManager.java:420)

To be noted that this exact code works perfectly with MySQL/Postgres naturally.
Before using mass debugging weapons, do you see any reason why a preparedstatement couldn't work there?

Thanks
Pascal
Reply all
Reply to author
Forward
0 new messages