带有Cloud SQL的应用引擎上的连接池 [英] Connection pool on app engine with Cloud SQL

查看:90
本文介绍了带有Cloud SQL的应用引擎上的连接池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这听起来像是应用引擎(1)支持连接池的更新的云JDBC SQL驱动程序。

我们的应用程序使用Spring + Hibernate,我们正尝试使用现有的Java框架之一进行连接池(BoneCP,C3p0,Hikari),并且目前失败由于应用程序引擎的限制使用它们中的任何一个。使用下面的Spring + Hibernate + C3p0来堆栈跟踪。有没有人设法让这个工作?

  [INFO] java.lang.NoClassDefFoundError:java.lang.management.ManagementFactory是一个受限制的类。有关更多详细信息,请参阅Google App Engine开发人员指南。 
[INFO],com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
[INFO],位于com.mchange.v2.c3p0.management。 ActiveManagementCoordinator<初始化>(ActiveManagementCoordinator.java:54)
[信息]在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)
[信息]在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl。的java:57)
[信息]在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[信息]在java.lang.reflect.Constructor.newInstance(Constructor.java:526)
[INFO] at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:127)
[INFO] at com.google.appengine.tools.development。 agent.runtime.Runtime.newInstance(Runtime.java:148)
[信息]在com.mchange.v2.c3p0.C3P0Registry< clinit>(C3P0Registry.java:146)
[INFO]在java.lang.Class.forName0(本地方法)
[INFO] at java.lan g.Class.forName(Class.java:190)
[INFO] at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
[INFO ]在com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
[信息]在com.mchange.v2.c3p0.impl.DriverManagerDataSourceBase<初始化> (DriverManagerDataSourceBase.java:212)
[INFO] at com.mchange.v2.c3p0.DriverManagerDataSource。< init>(DriverManagerDataSource.java:72)
....

(1):旧驱动程序= com.google.appengine.api.rdbms.AppEngineDriver。新驱动程序= com.mysql.jdbc.GoogleDriver。

解决方案

我们最终解决了这个问题,使用Tomcat DBCP( http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html )。大多数其他池的问题是它们使用线程,这是应用程序引擎的模型在前端实例(长寿命线程)上阻止的线程。

It sounds like the newer cloud SQL JDBC drivers for app engine (1) support connection pooling.

Our app uses Spring+Hibernate and we're trying to use one of the existing java frameworks for connection pooling (BoneCP, C3p0, Hikari), and have failed so far to use any of them because of app engine limitations. Stack trace using Spring+Hibernate+C3p0 below. Did anyone manage to get this to work?

[INFO] java.lang.NoClassDefFoundError: java.lang.management.ManagementFactory is a restricted class. Please see the Google  App Engine developer's guide for more details.
[INFO]  at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
[INFO]  at com.mchange.v2.c3p0.management.ActiveManagementCoordinator.<init>(ActiveManagementCoordinator.java:54)
[INFO]  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[INFO]  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
[INFO]  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[INFO]  at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
[INFO]  at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:127)
[INFO]  at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:148)
[INFO]  at com.mchange.v2.c3p0.C3P0Registry.<clinit>(C3P0Registry.java:146)
[INFO]  at java.lang.Class.forName0(Native Method)
[INFO]  at java.lang.Class.forName(Class.java:190)
[INFO]  at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
[INFO]  at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
[INFO]  at com.mchange.v2.c3p0.impl.DriverManagerDataSourceBase.<init>(DriverManagerDataSourceBase.java:212)
[INFO]  at com.mchange.v2.c3p0.DriverManagerDataSource.<init>(DriverManagerDataSource.java:72)
....

(1): Old driver = com.google.appengine.api.rdbms.AppEngineDriver. New driver = com.mysql.jdbc.GoogleDriver.

解决方案

We ended up solving this by using Tomcat DBCP (http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html). The problem with most other pools is that they use threading, which app engine's model prevent on frontend instances (long-lived threads that is).

这篇关于带有Cloud SQL的应用引擎上的连接池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆