Reputation: 86925
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
Upvotes: 1
Views: 1261
Reputation: 3024
According the source code of tomcat8-dbcp. After close(true)
of org.apache.tomcat.jdbc.pool.DataSourceProxy
is invoked, the class variable pool
will reset to null. But a new object will be created using the same configuration once other methods access the pool
variable. So you don't have to reinitialize the DataSource.
Upvotes: 1