三个Web应用程序使用相同的数据库时,无法建立数据库连接

福码

一个db被三个Web应用程序使用,其中两个是一点点流量应用程序,而第三个则是不大量流量应用程序。

当我第一次使用第三个应用程序时,它是一个宁静的Web服务,它工作正常。但是当我在使用其他两个之后使用它时,我的所有应用程序都停止工作

这是我针对所有三个应用程序的休眠配置文件:

<property name="hibernate.c3p0.min_size">3</property>
    <property name="hibernate.c3p0.max_size">10</property>
    <property name="hibernate.c3p0.acquire_increment">1</property>
    <property name="hibernate.c3p0.timeout">300</property>
    <property name="hibernate.c3p0.idle_test_period">3000</property>
    <property name="hibernate.c3p0.max_statements">40</property>
    <property name="hibernate.jdbc.batch_size">10</property>
    <property name="hibernate.cache.use_second_level_cache">false</property>
    <property name="hbm2ddl.auto">update</property>
    <property name="dynamic-update">true</property>

请指教!

日志很大,据我认为,我已经在此处粘贴了相关日志:

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 155,938 milliseconds ago.  The last packet sent successfully to the server was 155,938 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
    at sun.reflect.GeneratedConstructorAccessor245.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3829)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2449)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2713)
    at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:5060)
    at com.mchange.v2.c3p0.impl.NewProxyConnection.setAutoCommit(NewProxyConnection.java:881)
    at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:37)
    at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:424)
    ... 49 more
Caused by: java.net.SocketException: Software caused connection abort: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(Unknown Source)
    at java.net.SocketOutputStream.write(Unknown Source)
    at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
    at java.io.BufferedOutputStream.flush(Unknown Source)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3810)
    ... 56 more
org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
    at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
    at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:427)
    at org.hibernate.jdbc.JDBCContext.connect(JDBCContext.java:168)
    at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:103)
    at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:86)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1129)
    at org.hibernate.loader.Loader.doQuery(Loader.java:373)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:210)
    at org.hibernate.loader.Loader.doList(Loader.java:1562)
    at org.hibernate.loader.Loader.list(Loader.java:1545)
    at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1316)
    at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:299)
    at com.csat.db.crud.QuestionCRUD.SearchQuestion(QuestionCRUD.java:56)
    at com.csat.rest.resource.SurveyRequest.getSurvey(SurveyRequest.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1483)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1414)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 71,198 milliseconds ago.  The last packet sent successfully to the server was 0 milliseconds ago.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3567)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3456)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3997)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2468)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2713)
    at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:5060)
    at com.mchange.v2.c3p0.impl.NewProxyConnection.setAutoCommit(NewProxyConnection.java:881)
    at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:37)
    at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:424)
    ... 49 more
Caused by: java.net.SocketException: Software caused connection abort: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)
    at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)
    at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)
    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3014)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3467)
    ... 58 more
mot

将参数添加到您的休眠配置:

<property name="hibernate.c3p0.acquire_increment">1</property> 
<property name="hibernate.c3p0.idle_test_period">0</property> 
<property name="hibernate.c3p0.timeout">0</property> 
<property name="hibernate.c3p0.validate">true</property>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用SQLite数据库的Mac应用程序在10.9小牛中创建了三个数据库

来自分类Dev

无法使用Node.js(OpenShift应用程序)连接到MySQL数据库

来自分类Dev

使用Jsp的Android应用程序数据库与Web应用程序的连接

来自分类Dev

应用程序和数据库连接

来自分类Dev

应用程序未连接到Mongoose数据库

来自分类Dev

Web应用程序的单个数据库连接

来自分类Dev

无法使用Sequelize从本地节点应用程序连接到Heroku Postgresql数据库

来自分类Dev

Windows Phone 8.1应用程序与数据库连接

来自分类Dev

android Hybrid应用程序与数据库的脱机连接

来自分类Dev

可以通过Navicate连接mysql数据库,但无法从C#应用程序连接

来自分类Dev

在独立应用程序中处理数据库连接

来自分类Dev

建立与数据库的连接

来自分类Dev

JSP的Web应用程序的数据库连接无法加载

来自分类Dev

Mongodb数据库连接代码中断应用程序

来自分类Dev

Heroku上的数据库连接错误:将Web应用程序连接到Postgresql

来自分类Dev

无法从我的Django Web应用程序连接到Amazon RDS Postgres数据库

来自分类Dev

应用程序和数据库连接

来自分类Dev

无法使用新建立的数据库

来自分类Dev

Rails应用程序与Advantage数据库的连接

来自分类Dev

汽车数据库Web和桌面应用程序的数据库设计

来自分类Dev

Windows Phone 8.1应用程序与数据库连接

来自分类Dev

无法使用Rails应用程序连接到sqlite3数据库

来自分类Dev

使用数据库连接将代码部署到Azure Web时,Flask应用程序无法呈现,但是在本地服务器上运行良好

来自分类Dev

建立数据库连接时出错

来自分类Dev

使用托管的Web应用程序连接到SQL Server数据库

来自分类Dev

Windows窗体应用程序中的数据库连接

来自分类Dev

如何使用相同的数据库连接网站和桌面应用程序

来自分类Dev

一个 Web 应用程序中的多个数据库连接 - java

来自分类Dev

无法将数据从 Firebase 实时数据库检索到 Web 应用程序中

Related 相关文章

  1. 1

    使用SQLite数据库的Mac应用程序在10.9小牛中创建了三个数据库

  2. 2

    无法使用Node.js(OpenShift应用程序)连接到MySQL数据库

  3. 3

    使用Jsp的Android应用程序数据库与Web应用程序的连接

  4. 4

    应用程序和数据库连接

  5. 5

    应用程序未连接到Mongoose数据库

  6. 6

    Web应用程序的单个数据库连接

  7. 7

    无法使用Sequelize从本地节点应用程序连接到Heroku Postgresql数据库

  8. 8

    Windows Phone 8.1应用程序与数据库连接

  9. 9

    android Hybrid应用程序与数据库的脱机连接

  10. 10

    可以通过Navicate连接mysql数据库,但无法从C#应用程序连接

  11. 11

    在独立应用程序中处理数据库连接

  12. 12

    建立与数据库的连接

  13. 13

    JSP的Web应用程序的数据库连接无法加载

  14. 14

    Mongodb数据库连接代码中断应用程序

  15. 15

    Heroku上的数据库连接错误:将Web应用程序连接到Postgresql

  16. 16

    无法从我的Django Web应用程序连接到Amazon RDS Postgres数据库

  17. 17

    应用程序和数据库连接

  18. 18

    无法使用新建立的数据库

  19. 19

    Rails应用程序与Advantage数据库的连接

  20. 20

    汽车数据库Web和桌面应用程序的数据库设计

  21. 21

    Windows Phone 8.1应用程序与数据库连接

  22. 22

    无法使用Rails应用程序连接到sqlite3数据库

  23. 23

    使用数据库连接将代码部署到Azure Web时,Flask应用程序无法呈现,但是在本地服务器上运行良好

  24. 24

    建立数据库连接时出错

  25. 25

    使用托管的Web应用程序连接到SQL Server数据库

  26. 26

    Windows窗体应用程序中的数据库连接

  27. 27

    如何使用相同的数据库连接网站和桌面应用程序

  28. 28

    一个 Web 应用程序中的多个数据库连接 - java

  29. 29

    无法将数据从 Firebase 实时数据库检索到 Web 应用程序中

热门标签

归档