Taketo Matsunaga
Taketo Matsunaga

Reputation: 43

How to keep connection with Spring boot, Hibernate and Websphere Application Server

My application uses the frameworks and application server below:

  1. Spring Boot(1.5.4.RELEASE) with hibernate.

  2. Websphere Application Server Liberty for Java on Bluemix

The application works fine however after the running for hours connections time out. See following exception:

2017-09-01T11:40:40.57+0900 [APP/PROC/WEB/0] OUT 2017-09-01 02:40:40,563 [http-nio-8080-exec-2] [5baba2cb-5bfd-4846-b8e0-8782aa729639] [] WARN  o.h.e.jdbc.spi.SqlExceptionHelper [SqlExceptionHelper.java:127] - SQL Error: -4499, SQLState: 08001 
2017-09-01T11:40:40.58+0900 [APP/PROC/WEB/0] OUT or socket output stream.  Error location: Reply.fill() - socketInputStream.read (-1).  Message: Connection timed out (Write failed). ERRORCODE=-4499, SQLSTATE=08001 

I know Spring boot needs to be set configuration properties in application.properties.

spring.datasource.testOnBorrow=true
spring.datasource.testWhileIdle=true
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.numTestsPerEvictionRun=3
spring.datasource.minEvictableIdleTimeMillis=600000
spring.datasource.validationQuery=SELECT 1

However, I found out with Spring boot 1.3+, we must use the implementation-specific settings using their respective prefix (spring.datasource.tomcat., spring.datasource.hikari., and spring.datasource.dbcp2.*), and (apparently) DOES NOT SUPPORT Websphere Application Server Liberty Profile.

My question is how should I configure to keep connections alive (or renew them)?

Thank you in advance!

Upvotes: 2

Views: 1340

Answers (1)

Henry
Henry

Reputation: 815

What datasource are you using? In our case we are using tomcat which is the default option. So we have

# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.test-while-idle=true
spring.datasource.tomcat.time-between-eviction-runs-millis=300000
spring.datasource.tomcat.validation-query=SELECT 1

Upvotes: 0

Related Questions