gpt4 book ai didi

mysql - Spring boot 多数据源连接中的 JDBCConnectionException

转载 作者:行者123 更新时间:2023-11-29 18:03:46 25 4
gpt4 key购买 nike

当我们尝试使用 spring boot 多数据源连接时,出现 JDBCConnection 异常,一天连接良好,但第二天出现连接异常,我们需要重新启动 tomcat 才能正常工作,任何主体都可以帮助我们了解导致连接在一段时间后关闭的确切属性

spring.xy.datasource.url=jdbc:mysql://azurnae-db013.xxx.yy.net:3306/devdb
spring.xy.datasource.username=user
spring.xy.datasource.password=pass
spring.xy.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.xy.datasource.pool-size=100

Below is the excpetion

could not prepare statement; nested exception is org.hibernate.exception.JDBCConnectionException: could not prepare statement",

最佳答案

这是我的 tomcat web 应用程序的配置:

<Resource name="jdbc/itsme" 
auth="Container"
type="javax.sql.DataSource"
maxTotal="100"
initialSize="1"
maxActive="85"
maxIdle="15"
minIdle="1"
maxWait="10000"
maxAge="3600000"
timeBetweenEvictionRunsMillis="60000"
minEvictableIdleTimeMillis="60000"
validationQuery="SELECT 1"
validationInterval="30000"
testOnBorrow="true"
removeAbandoned="true"
removeAbandonedTimeout="60"
driverClassName="com.mysql.cj.jdbc.Driver"/>

您需要的属性是minIdle、validationQuery、validationInterval、testOnBorrow,配置好这些后您就不会有问题了

关于mysql - Spring boot 多数据源连接中的 JDBCConnectionException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48091697/

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