Skip to content

Commit 40ea9ff

Browse files
committed
#17 - Improved logging for #16 - ENH: Support specifying database owner username, password and InitDatabase
1 parent d9a9580 commit 40ea9ff

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/io/ebean/datasource/pool/ConnectionPool.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,15 @@ private void initialiseDatabase() throws SQLException {
318318
// successfully obtained a connection so skip initDatabase
319319
connection.clearWarnings();
320320
} catch (SQLException e) {
321+
logger.info("Obtaining connection using ownerUsername:{} to initialise database", config.getOwnerUsername());
321322
// expected when user does not exists, obtain a connection using owner credentials
322-
try (Connection connection = createUnpooledConnection(config.getOwnerUsername(), config.getOwnerPassword())) {
323+
try (Connection ownerConnection = createUnpooledConnection(config.getOwnerUsername(), config.getOwnerPassword())) {
323324
// initialise the DB (typically create the user/role using the owner credentials etc)
324325
InitDatabase initDatabase = config.getInitDatabase();
325-
initDatabase.run(connection, config);
326-
connection.commit();
326+
initDatabase.run(ownerConnection, config);
327+
ownerConnection.commit();
328+
} catch (SQLException e2) {
329+
throw new SQLException("Failed to run InitDatabase with ownerUsername:" + config.getOwnerUsername(), e2);
327330
}
328331
}
329332
}

0 commit comments

Comments
 (0)