use of org.apache.tomcat.dbcp.dbcp2.PoolableConnection in project Openfire by igniterealtime.
the class EmbeddedConnectionProvider method start.
@Override
public void start() {
File databaseDir = new File(JiveGlobals.getHomeDirectory(), File.separator + "embedded-db");
// If the database doesn't exist, create it.
if (!databaseDir.exists()) {
databaseDir.mkdirs();
}
try {
serverURL = "jdbc:hsqldb:" + databaseDir.getCanonicalPath() + File.separator + "openfire";
} catch (IOException ioe) {
Log.error("EmbeddedConnectionProvider: Error starting connection pool: ", ioe);
}
final ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(serverURL, "sa", "");
final PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, null);
poolableConnectionFactory.setMaxConnLifetimeMillis((long) (0.5 * JiveConstants.DAY));
final GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
poolConfig.setMinIdle(3);
poolConfig.setMaxTotal(25);
final GenericObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<>(poolableConnectionFactory, poolConfig);
poolableConnectionFactory.setPool(connectionPool);
dataSource = new PoolingDataSource<>(connectionPool);
}
Aggregations