2012-04-13 16 views
3

Ich versuche, meine C3P0-Einstellungen anzupassen, um den Fehler zu vermeiden, der am Ende dieses Beitrags angezeigt wird.Spielen! Framework 1.2.4 --- C3P0-Einstellungen zur Vermeidung von Kommunikationsverbindungsfehlern führen zu Leerlaufzeit

Es wurde bei dieser URL vorgeschlagen --- --- http://make-it-open.blogspot.com/2008/12/sql-error-0-sqlstate-08s01.html die Einstellungen anzupassen, wie folgt:

In hibernate.cfg.xml, schreiben

<property name="c3p0.min_size">5</property> 
<property name="c3p0.max_size">20</property> 
<property name="c3p0.timeout">1800</property> 
<property name="c3p0.max_statements">50</property> 

Then "c3p0.properties" erstellen in Ihrem Stamm Klassenpfad Ordner und schreiben

c3p0.testConnectionOnCheckout=true 
c3p0.acquireRetryDelay=1000 
c3p0.acquireRetryAttempts=1 

Ich habe versucht, diese Anpassungen in die Richtung des Spiels! Framework-Dokumentation, wo sie Verwendung sagen „db.pool ...“ wie folgt:

db.pool.timeout=1800 
db.pool.maxSize=15 
db.pool.minSize=5 
db.pool.initialSize=5 
db.pool.acquireRetryAttempts=1 
db.pool.preferredTestQuery=SELECT 1 
db.pool.testConnectionOnCheckout=true 
db.pool.acquireRetryDelay=1000 
db.pool.maxStatements=50 

Sind diese Einstellungen nicht zur Arbeit zu gehen? Soll ich versuchen, sie anders zu gestalten? Mit diesen Einstellungen bekomme ich immer noch den unten gezeigten Fehler, der auf eine lange Leerlaufzeit zurückzuführen ist.

komplette Stack-Trace Fehler:

23:00:44,932 WARN ~ SQL Error: 0, SQLState: 08S01 
2012-04-13T23:00:44+00:00 app[web.1]: 23:00:44,932 ERROR ~ Communications link failure 
2012-04-13T23:00:44+00:00 app[web.1]: 
2012-04-13T23:00:44+00:00 app[web.1]: The last packet successfully received from the server was 274,847 milliseconds ago. The last packet sent successfully to the server was 7 milliseconds ago. 
2012-04-13T23:00:44+00:00 app[web.1]: 23:00:44,934 ERROR ~ Why the driver complains here? 
2012-04-13T23:00:44+00:00 app[web.1]: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed by the driver. 
2012-04-13T23:00:44+00:00 app[web.1]: at com.mysql.jdbc.Util.handleNewInstance(Util.java:407) 
2012-04-13T23:00:44+00:00 app[web.1]: at com.mysql.jdbc.Util.getInstance(Util.java:382) 
2012-04-13T23:00:44+00:00 app[web.1]: at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013) 
2012-04-13T23:00:44+00:00 app[web.1]: at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987) 
2012-04-13T23:00:44+00:00 app[web.1]: at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982) 
2012-04-13T23:00:44+00:00 app[web.1]: at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927) 
2012-04-13T23:00:44+00:00 app[web.1]: at com.mysql.jdbc.ConnectionImpl.throwConnectionClosedException(ConnectionImpl.java:1213) 
2012-04-13T23:00:44+00:00 app[web.1]: at com.mysql.jdbc.ConnectionImpl.getMutex(ConnectionImpl.java:3101) 
2012-04-13T23:00:44+00:00 app[web.1]: at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4975) 
2012-04-13T23:00:44+00:00 app[web.1]: at org.hibernate.jdbc.BorrowedConnectionProxy.invoke(BorrowedConnectionProxy.java:74) 
2012-04-13T23:00:44+00:00 app[web.1]: at $Proxy49.setAutoCommit(Unknown Source) 
2012-04-13T23:00:44+00:00 app[web.1]: at play.db.jpa.JPAPlugin.closeTx(JPAPlugin.java:368) 
2012-04-13T23:00:44+00:00 app[web.1]: at play.db.jpa.JPAPlugin.onInvocationException(JPAPlugin.java:328) 
2012-04-13T23:00:44+00:00 app[web.1]: at play.plugins.PluginCollection.onInvocationException(PluginCollection.java:447) 
2012-04-13T23:00:44+00:00 app[web.1]: at play.Invoker$Invocation.onException(Invoker.java:240) 
2012-04-13T23:00:44+00:00 app[web.1]: at play.jobs.Job.onException(Job.java:124) 
2012-04-13T23:00:44+00:00 app[web.1]: at play.jobs.Job.call(Job.java:163) 
2012-04-13T23:00:44+00:00 app[web.1]: at play.jobs.Job$1.call(Job.java:66) 
2012-04-13T23:00:44+00:00 app[web.1]: at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) 
2012-04-13T23:00:44+00:00 app[web.1]: at java.util.concurrent.FutureTask.run(FutureTask.java:166) 
2012-04-13T23:00:44+00:00 app[web.1]: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:165) 
2012-04-13T23:00:44+00:00 app[web.1]: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266) 
2012-04-13T23:00:44+00:00 app[web.1]: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) 
2012-04-13T23:00:44+00:00 app[web.1]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) 
2012-04-13T23:00:44+00:00 app[web.1]: at java.lang.Thread.run(Thread.java:636) 
2012-04-13T23:00:44+00:00 app[web.1]: Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 

Antwort

4

Create "c3p0.properties" inside 'conf' dir.

Es funktioniert für mich.

Ich denke, dass 'db.pool' bei application.conf nur ein paar Optionen lesen, einen Blick auf Play-Quellcode nehmen (DBPlugin.onApplicationStart()):

ComboPooledDataSource ds = new ComboPooledDataSource(); 
ds.setDriverClass(p.getProperty("db.driver")); 
ds.setJdbcUrl(p.getProperty("db.url")); 
ds.setUser(p.getProperty("db.user")); 
ds.setPassword(p.getProperty("db.pass")); 
ds.setAcquireRetryAttempts(10); 
ds.setCheckoutTimeout(Integer.parseInt(p.getProperty("db.pool.timeout", "5000"))); 
ds.setBreakAfterAcquireFailure(false); 
ds.setMaxPoolSize(Integer.parseInt(p.getProperty("db.pool.maxSize", "30"))); 
ds.setMinPoolSize(Integer.parseInt(p.getProperty("db.pool.minSize", "1"))); 
ds.setMaxIdleTimeExcessConnections(Integer.parseInt(p.getProperty("db.pool.maxIdleTimeExcessConnections", "0"))); 
ds.setIdleConnectionTestPeriod(10); 
ds.setTestConnectionOnCheckin(true); 
0

idleConnectionTestPeriod wird nicht aus der Datei c3p0.properties abgerufen werden. Du musst also dein Spiel-Framework auf 1.3 oder 1.4 upgraden.