0

I have a spring boot application in production. The spring boot version is 1.3.5. The connection to database is getting closed since no requests are being hit for a large amount of time. I have decided to use below properties to keep the connection alive

**spring.datasource.validationQuery=SELECT 1 from dual

spring.datasource.test-while-idle=true

spring.datasource.time-between-eviction-runs-millis=30000** 

Ideally the query need to be run for every 30 seconds. I would like to test whether the query is being working properly. I am unable to understand how to test these properties. Can anyone let me know is there any way to test this. I have added below properties in properties file but still query is not getting printed in console.

**spring.jpa.show-sql=true

logging.level.org.hibernate.SQL=INFO

logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

logging.level.org.springframework.jdbc.core.JdbcTemplate=DEBUG

logging.level.org.springframework.jdbc.core.StatementCreatorUtils=TRACE**
Varunteja
  • 41
  • 1
  • 7
  • You've added logging for JPA, Hibernate and for `JdbcTemplate`. However, the validation query logic happens at the connection pool itself, and thus none of those work. I don't know of any setting within Tomcat JDBC (or Hikari) to enable logging for the validation query. Most JDBC drivers however provide some way of tracing. Can you tell us which JDBC driver you're using? (eg. Postgres, MySQL, H2, ...). – g00glen00b Sep 18 '19 at 07:07
  • Thanks for reply. I am using Oracle JDBC driver – Varunteja Sep 18 '19 at 09:26
  • Hikari would recommend not using the validation query. https://github.com/brettwooldridge/HikariCP. JPA, Hibernate, and JdbcTemplate? Too complex. – duffymo Sep 18 '19 at 12:26

0 Answers0