显然 Play DB Plugin 并没有阻止使用这种 url。如果您查看模块 play-jdbc 第 345 行中的 DB.scala,它只是将 url 传递给 JDBC。
conf.getString("url") match {
case Some(PostgresFullUrl(username, password, host, dbname)) =>
datasource.setJdbcUrl("jdbc:postgresql://%s/%s".format(host, dbname))
datasource.setUsername(username)
datasource.setPassword(password)
case Some(url @ MysqlFullUrl(username, password, host, dbname)) =>
val defaultProperties = """?useUnicode=yes&characterEncoding=UTF-8&connectionCollation=utf8_general_ci"""
val addDefaultPropertiesIfNeeded = MysqlCustomProperties.findFirstMatchIn(url).map(_ => "").getOrElse(defaultProperties)
datasource.setJdbcUrl("jdbc:mysql://%s/%s".format(host, dbname + addDefaultPropertiesIfNeeded))
datasource.setUsername(username)
datasource.setPassword(password)
case Some(url @ H2DefaultUrl()) if !url.contains("DB_CLOSE_DELAY") =>
if (Play.maybeApplication.exists(_.mode == Mode.Dev)) {
datasource.setJdbcUrl(url + ";DB_CLOSE_DELAY=-1")
} else {
datasource.setJdbcUrl(url)
}
case Some(s: String) =>
datasource.setJdbcUrl(s)
case _ =>
throw conf.globalError("Missing url configuration for database [%s]".format(conf))
}
所以 pb 可能在数据源本身(BoneCP)