2

I'd like to set some JDBC properties on the application.config.

For example: useLegacyDatetimeCode=false&useUnicode=true&serverTimezone=UTC

And this is my application.config.

play {
    db.prototype.hikaricp {
        connectionTimeout = 30 seconds
        maximumPoolSize = 5
    }
}
db {
    default {
        driver="org.mariadb.jdbc.Driver"
        url="jdbc:mariadb://host:port"
        username="user"
        password="password"
    }
}

However, my program need to access multiple databases so that I cannot combine the url, username, password and properties in the url property.

Is it possible to configure it?

I've tried this, but it does not work.

db {
    default {
        driver="org.mariadb.jdbc.Driver"
        url="jdbc:mariadb://host:port"
        username="user"
        password="password"
        useLegacyDatetimeCode=false
    }
}

Thanks.

Benoit
  • 3,569
  • 2
  • 22
  • 20
kalin
  • 89
  • 1
  • 7

1 Answers1

0

So, in order to set the JDBC driver specific properties in play configuration you have to configure them through the connection pool implementation. It will then initiate connections with the given properties to the connection driver. For example with default connection pool implementation in play (HikariCP)

# SQLServer driver properties, timeout In seconds
db.default.hikaricp.dataSource.queryTimeout = 15

This will map any property to the driver props

Benoit
  • 3,569
  • 2
  • 22
  • 20