I'm already a developer

Fix: Caused by: java.sql.SQLException: Connection is closed! at Play2.3(Java)・MySQL5.6

Today, I will describe how to deal with the following error in Playframework 2.3 (Java). MySQL version is 5.6.

@6pp2cmieh: Execution exception in null:null
        at play.api.Application$class.handleError(Application.scala:296)
        at play.api.DefaultApplication.handleError(Application.scala:402)
        at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320)
        at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320)
        at scala.Option.map(Option.scala:146)
        at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3.applyOrElse(PlayDefaultUpstreamHandler.scala:320)
        at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3.applyOrElse(PlayDefaultUpstreamHandler.scala:316)
        at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:344)
        at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:343)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
        at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:46)
        at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:40)
        at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:248)
        at scala.concurrent.Promise$class.complete(Promise.scala:55)
        at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:153)
        at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:23)
        at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:41)
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: javax.persistence.PersistenceException: java.sql.SQLException: Connection is closed!
        at com.avaje.ebeaninternal.server.transaction.JdbcTransaction.rollback(JdbcTransaction.java:640)
        at com.avaje.ebeaninternal.server.transaction.JdbcTransaction.rollback(JdbcTransaction.java:625)
        at com.avaje.ebeaninternal.server.transaction.TransactionMap$State.rollback(TransactionMap.java:96)
        at com.avaje.ebeaninternal.server.transaction.DefaultTransactionThreadLocal.rollback(DefaultTransactionThreadLocal.java:89)
        at com.avaje.ebeaninternal.server.transaction.DefaultTransactionScopeManager.rollback(DefaultTransactionScopeManager.java:37)
        at com.avaje.ebeaninternal.server.core.DefaultServer.rollbackTransaction(DefaultServer.java:884)
        at helper.TransactionHelper.rollbackTransaction(TransactionHelper.java:99)
        at filter.BatchGlobalSettings$SessionAction.call(BatchGlobalSettings.java:111)
        at play.core.j.JavaAction$$anonfun$11.apply(JavaAction.scala:82)
        at play.core.j.JavaAction$$anonfun$11.apply(JavaAction.scala:82)
        at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
        at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
        at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:40)
        at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:46)
        at play.core.j.HttpExecutionContext.execute(HttpExecutionContext.scala:32)
        at scala.concurrent.impl.Future$.apply(Future.scala:31)
        at scala.concurrent.Future$.apply(Future.scala:492)
        at play.core.j.JavaAction$class.apply(JavaAction.scala:82)
        at play.core.Router$HandlerInvokerFactory$JavaActionInvokerFactory$$anon$15$$anon$1.apply(Router.scala:252)
        at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130)
        at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130)
        at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
        at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:129)
        at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:128)
        at scala.Option.map(Option.scala:146)
        at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:128)
        at play.api.mvc.Action$$anonfun$apply$1.apply(Action.scala:121)
        at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:483)
        at play.api.libs.iteratee.Iteratee$$anonfun$mapM$1.apply(Iteratee.scala:483)
        at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:519)
        at play.api.libs.iteratee.Iteratee$$anonfun$flatMapM$1.apply(Iteratee.scala:519)
        at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$14.apply(Iteratee.scala:496)
        at play.api.libs.iteratee.Iteratee$$anonfun$flatMap$1$$anonfun$apply$14.apply(Iteratee.scala:496)
        at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
        at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
        ... 6 more
Caused by: java.sql.SQLException: Connection is closed!
        at com.jolbox.bonecp.ConnectionHandle.checkClosed(ConnectionHandle.java:459)
        at com.jolbox.bonecp.ConnectionHandle.rollback(ConnectionHandle.java:1270)
        at com.avaje.ebeaninternal.server.transaction.JdbcTransaction.rollback(JdbcTransaction.java:637)
        ... 40 more

Caused by: java.sql.SQLException: Connection is closed!

I searched first with Caused by: java.sql.SQLException: Connection is closed! on google. I could see many results, but I could not resolve this problem.

So, I tried to output SQL logs to see what SQL actually runs when I run an error.

http://qiita.com/ispern/items/d49ac839063a122e7c67

Looking at the SQL that actually dropped, the text contained pictograms. So, So I changed the target column to allow pictograms.

ALTER TABLE `hoge`
CHANGE COLUMN `fuga` `fuga` VARCHAR(5000) CHARACTER SET 'utf8mb4' NULL DEFAULT NULL COMMENT 'hogehoge' ;

And then, I could resolve this error -> Caused by: java.sql.SQLException: Connection is closed!

This error also occurs for other causes, so it seems good to explore the cause while debugging.