gpt4 book ai didi

java - 保存时 hibernate 超时

转载 作者:行者123 更新时间:2023-11-29 10:13:28 24 4
gpt4 key购买 nike

我有一个使用 MySql 保存到表中的应用程序(该表有 2 个 JSON 字段,其中一个可以接收大输入)。在生产中我时不时地遇到以下错误:

SqlExceptionHelper - The last packet successfully received from the server was 71,290,382 milliseconds ago.
The last packet sent successfully to the server was 71,290,384 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.

我不明白为什么会发生这种情况,因为我在本地从未遇到过这个问题。这是我目前的配置:

cfg.setProperty("hibernate.c3p0.min_size", "5")
.setProperty("hibernate.c3p0.max_size", "20")
.setProperty("hibernate.c3p0.timeout", "30000")
.setProperty("hibernate.c3p0.max_statements", "50")
.setProperty("hibernate.c3p0.idle_test_period", "3000")
.setProperty("hibernate.connection.autoReconnect", "true")
.setProperty("hibernate.connection.autoReconnectForPools", "true");

我错过了什么吗?

最佳答案

不久前我们也遇到了同样的问题。我在历史记录中进行搜索,虽然您可以保留现有的值,但您需要添加以下值:<property name="connection.is-connection-validation-required">true</property> 。这对我们的工件起到了作用,但您需要检查您的情况,因为您可能有一些其他设置。

作为旁注,我认为应该是:

.setProperty("connection.autoReconnect", "true")
.setProperty("connection.autoReconnectForPools", "true");
<小时/>

我们还有一个c3p0.properties文件:

c3p0.preferredTestQuery=select 1 from dual
c3p0.maxConnectionAge=3600
c3p0.testConnectionOnCheckin=false
c3p0.testConnectionOnCheckout=true
c3p0.acquireRetryDelay=1500
c3p0.acquireRetryAttempts=15
c3p0.breakAfterAcquireFailure=false
c3p0.idleConnectionTestPeriod=200

关注testConnectionOnCheckout特别是。

关于java - 保存时 hibernate 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50548358/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com