在 DB2 连接正常工作数月后,Spring Boot 突然卡在“HikariPool-1 正在启动...”

问题描述 投票:0回答:1

我有两个 Spring Boot 应用程序连接到两个数据库。第一个是使用“com.ibm.db2.jcc.DB2Driver”驱动程序的云上 DB2。第二个使用其他驱动程序。一年多来,我一直在本地运行这个应用程序,没有出现任何问题。我已经停止使用这些应用程序几个星期了,并在另一个使用“com.ibm.db2.db2jcc4.DB2Driver”且不是 Maven 应用程序的应用程序中工作。我一直在尝试运行我的旧应用程序而不更改配置,现在它们都卡在第一个数据库连接上,直到超时并移动到另一个,连接没有问题。

这里是日志:

2024-07-28 01:26:07.862 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : Driver class com.ibm.db2.jcc.DB2Driver found in Thread context class loader jdk.internal.loader.ClassLoaders$AppClassLoader@e42661c8
2024-07-28 01:26:07.908  INFO 53348 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2024-07-28 01:26:07.948  INFO 53348 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.6.15.Final
2024-07-28 01:26:08.083  INFO 53348 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2024-07-28 01:26:08.225 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : HikariPool-1 - configuration:
2024-07-28 01:26:08.228 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : allowPoolSuspension................................false
2024-07-28 01:26:08.228 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : autoCommit................................true
2024-07-28 01:26:08.228 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : catalog................................none
2024-07-28 01:26:08.228 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : connectionInitSql................................none
2024-07-28 01:26:08.228 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : connectionTestQuery................................none
2024-07-28 01:26:08.229 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : connectionTimeout................................30000
2024-07-28 01:26:08.229 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : dataSource................................none
2024-07-28 01:26:08.229 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : dataSourceClassName................................none
2024-07-28 01:26:08.229 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : dataSourceJNDI................................none
2024-07-28 01:26:08.229 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : dataSourceProperties................................{password=<masked>}
2024-07-28 01:26:08.229 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : driverClassName................................"com.ibm.db2.jcc.DB2Driver"
2024-07-28 01:26:08.229 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : exceptionOverrideClassName................................none
2024-07-28 01:26:08.230 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : healthCheckProperties................................{}
2024-07-28 01:26:08.230 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : healthCheckRegistry................................none
2024-07-28 01:26:08.230 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : idleTimeout................................600000
2024-07-28 01:26:08.230 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : initializationFailTimeout................................1
2024-07-28 01:26:08.230 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : isolateInternalQueries................................false
2024-07-28 01:26:08.230 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : jdbcUrl................................jdbc:db2://2fc27203-0678-410a-8a5d-ae2eb14c932d.c3n41cmd0nqnrk39u98g.private.databases.appdomain.cloud:32614/bludb:sslConnection=true;sslCertLocation=/Users/kalioofarril/Documents/APCC/DigiCertGlobalRootCA_db2apccdev2_public.crt;
2024-07-28 01:26:08.230 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : keepaliveTime................................0
2024-07-28 01:26:08.231 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : leakDetectionThreshold................................0
2024-07-28 01:26:08.231 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : maxLifetime................................1800000
2024-07-28 01:26:08.231 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : maximumPoolSize................................10
2024-07-28 01:26:08.231 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : metricRegistry................................none
2024-07-28 01:26:08.231 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : metricsTrackerFactory................................none
2024-07-28 01:26:08.231 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : minimumIdle................................10
2024-07-28 01:26:08.231 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : password................................<masked>
2024-07-28 01:26:08.232 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : poolName................................"HikariPool-1"
2024-07-28 01:26:08.232 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : readOnly................................false
2024-07-28 01:26:08.232 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : registerMbeans................................false
2024-07-28 01:26:08.232 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : scheduledExecutor................................none
2024-07-28 01:26:08.232 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : schema................................none
2024-07-28 01:26:08.232 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : threadFactory................................internal
2024-07-28 01:26:08.232 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : transactionIsolation................................default
2024-07-28 01:26:08.232 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : username................................"71ccdba8"
2024-07-28 01:26:08.232 DEBUG 53348 --- [           main] com.zaxxer.hikari.HikariConfig           : validationTimeout................................5000
2024-07-28 01:26:08.232  INFO 53348 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2024-07-28 01:28:08.682 DEBUG 53348 --- [           main] com.zaxxer.hikari.pool.PoolBase          : HikariPool-1 - Failed to create/setup connection: [jcc][t4][2043][11550][4.33.31] Exception java.net.SocketTimeoutException: Error opening socket to server /166.9.59.42 on port 32,614 with message: connect timed out. ERRORCODE=-4499, SQLSTATE=08001
2024-07-28 01:28:08.688 DEBUG 53348 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Cannot acquire connection from data source

java.sql.SQLTimeoutException: [jcc][t4][2043][11550][4.33.31] Exception     java.net.SocketTimeoutException: Error opening socket to server /166.9.59.42 on port 32,614 with message: connect timed out. ERRORCODE=-4499, SQLSTATE=08001

相同的代码和环境变量在云服务器和我同事的电脑上运行良好。我唯一的提示是一个问题是,尝试通过 db GUI 连接的人正在使用 jcc4 驱动程序,而他的解决方案是更改使用的驱动程序。我认为另一个应用程序以某种方式使 jcc4 驱动程序在我的计算机上的某个端口上运行,该端口可能与我想要使用的 jcc 驱动程序相同,因此干扰了此数据库连接。

这是我能想到的唯一解释,但我不是司机专家,所以也许我完全不同意。

我的 application.properties 文件包含:

apcc.datasource.driver-class-name=com.ibm.db2.jcc.DB2Driver
apcc.datasource.url=jdbc:db2://${APCC_DB_URL}:${APCC_DB_PORT}/${APCC_DB_NAME}:sslConnection=true;sslCertLocation=${APCC_DB_CERT_PATH};
apcc.datasource.username=${APCC_DB_USER}
apcc.datasource.password=${APCC_DB_PASSWORD}

我尝试将 URL 上的 dbs 从 dev 更改为 qa,从云应用程序获取工作 URL。我曾尝试更改 java 版本并删除和创建新版本。

java spring-boot db2 hikaricp
1个回答
0
投票

检查应用程序和数据库之间的防火墙。由于您保持端口号不变,因此该端口可能被防火墙阻止并且未开放以接受连接请求。

或者,如果可能的话,考虑更改端口号,然后它应该可以工作。

上述解决方案假设数据库服务器是健康的。

© www.soinside.com 2019 - 2024. All rights reserved.