HikariCP是否支持类似于C的Spring引导应用程序中的命令超时#

HikariCP是否支持类似于C的Spring引导应用程序中的命令超时#,spring,spring-boot,connection-pooling,hikaricp,Spring,Spring Boot,Connection Pooling,Hikaricp,HikariCP是否支持类似于C的Spring引导应用程序中的命令超时# 我正在Spring boot应用程序中使用Hikari连接池。我已使用以下配置启用了connectionTimeout spring.datasource.hikari.connectionTimeout: 30000 如果我增加并发用户的数量,我会在日志中得到以下异常 Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed

HikariCP是否支持类似于C的Spring引导应用程序中的命令超时#

我正在Spring boot应用程序中使用Hikari连接池。我已使用以下配置启用了connectionTimeout

spring.datasource.hikari.connectionTimeout: 30000
如果我增加并发用户的数量,我会在日志中得到以下异常

Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; 
nested exception is java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30000ms.
除了上述例外,我完全满意。我可以增加连接的数量。但我担心的是,很少有端点的响应时间超过2分钟。这些端点从池中获得了DB连接,但处理时间更长。是否有一个设置,在其中我可以提到一些超时,以便如果数据库需要超过一段时间(操作时间-例如40秒),那么它应该发送SQL异常。类似于C#中的命令超时

应用程序属性

# A list of all Hikari parameters with a good explanation is available on https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby
# This property controls the minimum number of idle connections that HikariCP tries to maintain in the pool. Default: same as maximumPoolSize
spring.datasource.hikari.minimumIdle: 10
# This property controls the maximum size that the pool is allowed to reach, including both idle and in-use connections. Basically this value will determine the maximum number of actual connections to the database backend.
# Default: 10
spring.datasource.hikari.maximumPoolSize: 20
#This property controls the maximum number of milliseconds that a client (that's you) will wait for a connection from the pool. If this time is exceeded without a connection becoming available, a SQLException will be thrown. 
#Lowest acceptable connection timeout is 250 ms. Default: 30000 (30 seconds)
spring.datasource.hikari.connectionTimeout: 30000
# This property controls the maximum amount of time that a connection is allowed to sit idle in the pool. This setting only applies when minimumIdle is defined to be less than maximumPoolSize
# Default: 600000 (10 minutes)
spring.datasource.hikari.idleTimeout: 600000
# This property controls the maximum lifetime of a connection in the pool. An in-use connection will never be retired, only when it is closed will it then be removed.
# Default: 1800000 (30 minutes)
spring.datasource.hikari.maxLifetime: 1800000
# This property sets a SQL statement that will be executed after every new connection creation before adding it to the pool. Default: none
spring.datasource.hikari.connectionInitSql: SELECT 1 FROM DUAL
如中所述,似乎
connectionTimeout
值用于获取连接超时。 您可以尝试将其设置为大于30秒的值,看看是否有帮助。

如中所述,似乎
connectionTimeout
值用于获取连接超时。 您可以尝试将其设置为大于30秒的值,看看是否有帮助。

使用此设置可以设置超时:

spring.datasource.druid.query-timeout=10000
使用此设置可以设置超时:

spring.datasource.druid.query-timeout=10000

连接超时和查询超时是两件不同的事情。。如果我错了,请纠正我,但是spring.datasource.hikari.connectionTimeout这个参数意味着,如果db连接不可用,spring将在抛出异常之前等待所提到的超时。连接超时和查询超时是两件不同的事情,对吧。。如果我错了,请纠正我,但是spring.datasource.hikari.connectionTimeout这个参数意味着,如果db连接不可用,spring将在抛出异常之前等待上述超时