Timeout exception when connecting to Mysql database via Play-slick

338 views
Skip to first unread message

SargeKhan

unread,
Dec 8, 2015, 3:45:39 AM12/8/15
to Slick / ScalaQuery
I am using play-slick plugin to connect with mysql database. My application.conf file is as follow:

slick.dbs.default.driver= "slick.driver.MySQLDriver$"
slick.dbs.default.db.dataSourceClass = "slick.jdbc.DatabaseUrlDataSource"
slick.dbs.default.db.properties.driver = "com.mysql.jdbc.Driver"
slick.dbs.default.db.url="jdbc:mysql://127.0.0.1:3306"
slick.dbs.default.db.username="root"
slick.dbs.default.db.password="xxxx"
slick.dbs.default.db.connectionTimeout=15s
slick.dbs.default.db.numThreads = 12
slick.dbs.default.db.connectionTestQuery="select 1"

And whenever my application tries to communicate with the database it gets this error:
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[SQLTimeoutException: Timeout after 15001ms of waiting for a connection.]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:265) ~[play_2.11-2.4.3.jar:2.4.3]

I have checked that mysql is listening on port 3306. There is a service mysqld that's running. What am I missing? Thanks for the help.

SargeKhan

unread,
Dec 8, 2015, 6:13:04 AM12/8/15
to Slick / ScalaQuery
I still don't completely understand why it worked but my guess is that: 
in slick.dbs.default.db.dataSourceClass property we need to specify the class that specifies the connection properties. Where as I was just importing the default properties. And so, my url configurations etc.. were not being read. Removing that line did the trick.
If anyone knows the actual reason. Please let me know. 
Reply all
Reply to author
Forward
0 new messages