我无法维护到ClearDB实例的连接。当我的应用程序第一次运行时,我可以向它发出访问数据库的请求。一两分钟后,如果我提出同样的请求,我会得到一个通信链接失败。以下是我申请的详细信息:
我联系了ClearDB支持部门,他们告诉我他们不能帮助我,因为他们不直接支持Spray.io,我应该尝试直接从Heroku那里获得帮助。我已经向Heroku发送了一个帮助请求,但并不期待太多,因为我认为那里也不直接支持Spray.io或Slick。我一直在搜索Stackoverflow,也没有运气,所以我现在发布这个。
下面是我在本地复制时得到的完整堆栈跟踪。
java.lang.x:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 185,507 milliseconds ago. The last packet sent successfully to the server was 1 milliseconds ago.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 185,507 milliseconds ago. The last packet sent successfully to the server was 1 milliseconds ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[WARN] [01/26/2014 20:48:42.906] [LottoREST-akka.actor.default-dispatcher-4] [akka://LottoREST/user/lotto-service] Request HttpRequest(GET,http://localhost:8080/drawing,List(Cookie: JSESSIONID=4EFAE21258F8AF891C010DD14F9BC3F1, Accept-Language: en-US, en, Accept-Encoding: gzip, deflate, sdch, User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36, Cache-Control: max-age=0, Connection: keep-alive, Host: localhost:8080),Empty,HTTP/1.1) could not be handled normally
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1121)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3720)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3609)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4160)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2825)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1379)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:989)
at scala.slick.jdbc.StatementInvoker.results(StatementInvoker.scala:34)
at scala.slick.jdbc.StatementInvoker.elementsTo(StatementInvoker.scala:17)
at scala.slick.jdbc.Invoker$class.foreach(Invoker.scala:90)
at scala.slick.jdbc.StatementInvoker.foreach(StatementInvoker.scala:10)
at scala.slick.jdbc.Invoker$class.build(Invoker.scala:66)
at scala.slick.jdbc.StatementInvoker.build(StatementInvoker.scala:10)
at scala.slick.jdbc.Invoker$class.list(Invoker.scala:56)
at scala.slick.jdbc.StatementInvoker.list(StatementInvoker.scala:10)
at scala.slick.jdbc.UnitInvoker$class.list(Invoker.scala:150)
at scala.slick.driver.BasicInvokerComponent$QueryInvoker.list(BasicInvokerComponent.scala:19)
at com.megalottopools.model.DrawingComponent$Drawings$.findAllDrawings(Drawing.scala:28)
at com.megalottopools.model.Model.getDrawings(Model.scala:20)
at com.megalottopools.api.DrawingService$$anonfun$1.apply(DrawingService.scala:27)
at com.megalottopools.api.DrawingService$$anonfun$1.apply(DrawingService.scala:25)
at spray.routing.directives.BasicDirectives$$anonfun$mapRequestContext$1$$anonfun$apply$1.apply(BasicDirectives.scala:30)
at spray.routing.directives.BasicDirectives$$anonfun$mapRequestContext$1$$anonfun$apply$1.apply(BasicDirectives.scala:30)
at spray.routing.directives.BasicDirectives$$anon$3$$anonfun$happly$1.apply(BasicDirectives.scala:92)
at spray.routing.directives.BasicDirectives$$anon$3$$anonfun$happly$1.apply(BasicDirectives.scala:92)
at spray.routing.RouteConcatenation$RouteConcatenation$$anonfun$$tilde$1.apply(RouteConcatenation.scala:30)
at spray.routing.RouteConcatenation$RouteConcatenation$$anonfun$$tilde$1.apply(RouteConcatenation.scala:29)
at spray.routing.directives.BasicDirectives$$anonfun$mapRequestContext$1$$anonfun$apply$1.apply(BasicDirectives.scala:30)
at spray.routing.directives.BasicDirectives$$anonfun$mapRequestContext$1$$anonfun$apply$1.apply(BasicDirectives.scala:30)
at spray.routing.directives.BasicDirectives$$anon$3$$anonfun$happly$1.apply(BasicDirectives.scala:92)
at spray.routing.directives.BasicDirectives$$anon$3$$anonfun$happly$1.apply(BasicDirectives.scala:92)
at spray.routing.RouteConcatenation$RouteConcatenation$$anonfun$$tilde$1.apply(RouteConcatenation.scala:30)
at spray.routing.RouteConcatenation$RouteConcatenation$$anonfun$$tilde$1.apply(RouteConcatenation.scala:29)
at spray.routing.RouteConcatenation$RouteConcatenation$$anonfun$$tilde$1.apply(RouteConcatenation.scala:30)
at spray.routing.RouteConcatenation$RouteConcatenation$$anonfun$$tilde$1.apply(RouteConcatenation.scala:29)
at spray.routing.directives.BasicDirectives$$anonfun$mapRequestContext$1$$anonfun$apply$1.apply(BasicDirectives.scala:30)
at spray.routing.directives.BasicDirectives$$anonfun$mapRequestContext$1$$anonfun$apply$1.apply(BasicDirectives.scala:30)
at spray.routing.directives.ExecutionDirectives$$anonfun$handleExceptions$1$$anonfun$apply$4.apply(ExecutionDirectives.scala:35)
at spray.routing.directives.ExecutionDirectives$$anonfun$handleExceptions$1$$anonfun$apply$4.apply(ExecutionDirectives.scala:33)
at spray.routing.HttpServiceBase$class.runSealedRoute$1(HttpService.scala:36)
at spray.routing.HttpServiceBase$$anonfun$runRoute$1.applyOrElse(HttpService.scala:46)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:425)
at akka.actor.ActorCell.invoke(ActorCell.scala:386)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:230)
at akka.dispatch.Mailbox.run(Mailbox.scala:212)
at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:506)
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: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3166)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3620)
... 51 more
听起来像是连接超时问题。检查c3p0是否能正确地保持到ClearDB的连接活动。一些DB连接池使用网络ping或运行简单的select语句,如select1
来保持连接活动。您可以检查数据库可用的配置选项。为了验证这是一个问题,每隔几秒钟运行一些虚拟的db操作,看看是否在一段时间后得到相同的错误(保持池大小==1)。
我用java从MySQL查询了一些记录。但是在一些查询中,我遇到了一个问题,使查询失败,但在其他情况下,它查询成功。错误消息是下一个: 我尝试过一些方法,比如: 在 但什么都没发生。 我的环境是: MySQL: 5.5.3-m3-log源代码分布 Java: 1.60_16 jdk: HotSpot(TM)64位服务器VM(构建14.2-b01,混合模式) JDBC: mysql连接器-java-
我在Stackoverflow的另一个问题中尝试了这个建议,并在连接方面做了如下更改 但我的项目还是失败了 严重:执行身份验证com时发生异常。mysql。jdbc。例外情况。jdbc4。通信异常:通信链路故障 谁能告诉我克服这个问题的最好方法是什么?
StackOverflow上发布的与通信有关的问题似乎已经够多了。但没有一个能帮我走出困境。 但是,当我试图通过JDBC连接DB服务器时,它仍然失败,出现异常“com.mysql.JDBC.exceptions.jdbc4.CommunicationsException:Communications link Failure”。 测试类如下所示。
我试图连接我的java应用程序与SQL数据库和当我点击保存按钮它给我以下错误 这是我的密码
我有一个带有JDBC mysql连接的服务器,但每天早上检查服务器时都会出现这样的错误: 在com.mysql.jdbc.mysqlio.readfly(mysqlio.java:1395)在com.mysql.jdbc.mysqlio.reuseandreadpacket(mysqlio.java:1539)在com.mysql.jdbc.mysqlio.checkerrorpacket(mys
我在所有项目中都使用Liquibase,我非常喜欢它处理db更新的方式,但最近我遇到了这个问题: 我的服务器上运行了3个应用程序。其中一个跑了大约20年。第二次运行2个月,第三次是新的。 它们都是Spring Boot应用程序。 当我想更新第二个应用的jar时,我停止了旧的jar,运行了新的jar,但我无法让它以上面的错误开始。然后我运行了同一个应用程序的旧罐子,它一开始就很好。我试着停止并重新启