diff --git a/documentation/manual/configuration.textile b/documentation/manual/configuration.textile index ddcaad3801..b1874f44c8 100644 --- a/documentation/manual/configuration.textile +++ b/documentation/manual/configuration.textile @@ -527,6 +527,12 @@ c3p0 is very asynchronous. Slow JDBC operations are generally performed by helpe Default: @3@ +h3(#db.pool.connectionInitSql). db.pool.connectionInitSql + +Sets the SQL string that will be executed on all new connections when they are created, before they are added to the pool (HikariCP only). + +Default: none + h2(#evolutions). Database evolutions diff --git a/framework/src/play/db/hikaricp/HikariDataSourceFactory.java b/framework/src/play/db/hikaricp/HikariDataSourceFactory.java index 32f4969a07..ff4110541a 100644 --- a/framework/src/play/db/hikaricp/HikariDataSourceFactory.java +++ b/framework/src/play/db/hikaricp/HikariDataSourceFactory.java @@ -36,6 +36,10 @@ public DataSource createDataSource(Configuration dbConfig) throws PropertyVetoEx ds.setLoginTimeout(parseInt(dbConfig.getProperty("db.pool.loginTimeout", "0"))); // in seconds ds.setMaxLifetime(parseLong(dbConfig.getProperty("db.pool.maxConnectionAge", "0"))); // in ms + if (dbConfig.getProperty("db.pool.connectionInitSql") != null) { + ds.setConnectionInitSql(dbConfig.getProperty("db.pool.connectionInitSql")); + } + // not used in HikariCP: // db.pool.initialSize // db.pool.idleConnectionTestPeriod