I have a multi-tenant spring boot application running on MySQL database with separate schema for individual tenants. The dataSource is decided by passing a header code at runtime. How to make sure the connection doesnt drop in such a system? Once the system's inactivity passes beyond the set time, "SELECT 1" command needs to run and that doesn't specify anything to the system which dataSource to connect to, as a result of this the system throws sql exception.
Here are my config properties:
spring.datasource.url=jdbc:mysql://xxxxxxxx/xxx?useUnicode=true&characterEncoding=utf8&useSSL=false&autoReconnect=true spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL57InnoDBDialect spring.jpa.database=MYSQL spring.jpa.hibernate.ddl-auto=validate spring.datasource.test-on-borrow=true spring.datasource.testWhileIdle = true spring.datasource.timeBetweenEvictionRunsMillis = 60000 spring.datasource.validation-query=SELECT 1 spring.datasource.tomcat.max-wait=10000 spring.datasource.tomcat.max-active=50 spring.datasource.tomcat.test-on-borrow=true spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext hibernate.c3p0.max_size=20 hibernate.c3p0.min_size=5 hibernate.c3p0.idle_test_period=600