Is it possible to force termination of a tomcat-dbcp connection pool and any open connections? And then reinitialize the pool, reusing the pool configuration?
@Autowired
private org.apache.tomcat.jdbc.pool.DataSource ds;
ds.close(true);
//ds.open(); does not exists. how to reinitialize, without having to reconfigure the pool
According the source code of tomcat8-dbcp. After
close(true)oforg.apache.tomcat.jdbc.pool.DataSourceProxyis invoked, the class variablepoolwill reset to null. But a new object will be created using the same configuration once other methods access thepoolvariable. So you don't have to reinitialize the DataSource.