1

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
membersound
  • 81,582
  • 193
  • 585
  • 1,120

1 Answers1

1

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.

Beck Yang
  • 3,004
  • 2
  • 21
  • 26