i'm using spring-boot and datasource with jdbc template (postgres). in my service i do
@Autowired
public MyDao(DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
and later jdbcTemplate().query(...);
. all works as expected but when i restart db, it stops working. looks like datasource doesn't reconnect. i got:
org.postgresql.util.PSQLException: This connection has been closed.
i got same error when i add:
spring:
datasource:
testOnBorrow: true
validationQuery: select 1
how to make datasource reconnect automatically?