In a 2.0 Playframework project, I would like to analyze issued SQL queries by Slick. I am using log4jdbc for that but I can't get it to work.
I have added the log4jdbc.jar file in lib/ folder and changed my application.conf file to following :
db.default.driver=net.sf.log4jdbc.DriverSpy
db.default.url="jdbc:log4jdbc:mysql://127.0.0.1:3306/mydatabase"
db.default.user="username"
db.default.pass="password"
It is resulting in a Cannot connect to database [default] error. Without the log4jdbc, everything works fine. Am I missing something?
Ps : an important notice, I am also using the play-slick extension which seems to be the origin of the problem.
EDIT : By searching a little deeper, the exact error is "No suitable driver found".
Apparently Play DB Plugin doesn't prevent from using this kind of url. If you look in DB.scala in module play-jdbc Line 345, it just passes the url to 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))
}
So the pb might be in the datasource itself (BoneCP)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With