[2.0-RC2] MySQL URL in application.conf - Error with and without double quotes

2,832 views
Skip to first unread message

Severin Kistner

unread,
Feb 15, 2012, 2:34:49 PM2/15/12
to play-fr...@googlegroups.com
I try to connect to my MySQL database in the format from the Wiki (https://github.com/playframework/Play20/wiki/SettingsJDBC):
db.url=mysql://localhost:root@secret/myDatabase
Then i get this Error:

[error] Configuration error: Configuration error [conf/application.conf: 25: Expecting end of input or a comma, got ':' (if you intended ':' to be part of the value for 'db.url', try enclosing the value in double quotes, or you may be able to rename the file .properties rather than .conf)]

The obvious solution would be double quotes like this:
db.url="mysql://localhost:root@secret/myDatabase"
But then i get another Scala type related error:

! @69d5l7a4m - Internal server error, for request [GET /] ->

play.api.Configuration$$anon$1: Configuration error [conf/application.conf: 25: url.url has type STRING rather than OBJECT]
        at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:71) ~[play_2.9.1-2.0-RC2.jar:2.0-RC2]
        at play.api.Configuration.reportError(Configuration.scala:258) ~[play_2.9.1-2.0-RC2.jar:2.0-RC2]
        at play.api.Configuration.readValue(Configuration.scala:107) ~[play_2.9.1-2.0-RC2.jar:2.0-RC2]
        at play.api.Configuration.getString(Configuration.scala:126) ~[play_2.9.1-2.0-RC2.jar:2.0-RC2]
        at play.api.db.BoneCPApi$$anonfun$4.apply(DB.scala:378) ~[play_2.9.1-2.0-RC2.jar:2.0-RC2]
        at play.api.db.BoneCPApi$$anonfun$4.apply(DB.scala:377) ~[play_2.9.1-2.0-RC2.jar:2.0-RC2]
Caused by: com.typesafe.config.ConfigException$WrongType: conf/application.conf: 25: url.url has type STRING rather than OBJECT
        at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:124) ~[akka-actor.jar:2.0-RC1]
        at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:137) ~[akka-actor.jar:2.0-RC1]
        at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:108) ~[akka-actor.jar:2.0-RC1]
        at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:146) ~[akka-actor.jar:2.0-RC1]
        at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:188) ~[akka-actor.jar:2.0-RC1]
        at play.api.Configuration$$anonfun$getString$1.apply(Configuration.scala:126) ~[play_2.9.1-2.0-RC2.jar:2.0-RC2]


What is the reason for this error, why is string wrong?
I can't really make sense of all the regex and why it is "url.url" and not "db.url".

Ben McCann

unread,
Feb 15, 2012, 3:40:49 PM2/15/12
to play-fr...@googlegroups.com
You definitely need the double quotes.  I have db.default.url on the lefthand side though.

Here's what is in the default application.conf:
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
db.default.user=sa
db.default.password=

Notice they all have default and the URL has double quotes.

Guillaume Bort

unread,
Feb 15, 2012, 4:29:05 PM2/15/12
to play-fr...@googlegroups.com
Yes there is a mistake in the documentation. Just use:

db.default.url="mysql://localhost:root@secret/myDatabase"

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/F52N9OzfPj0J.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.

--
Guillaume Bort

Severin Kistner

unread,
Feb 16, 2012, 4:07:34 PM2/16/12
to play-fr...@googlegroups.com
I still can't get it to work, now he complains about the driver.
Which one should is use, i tried com.mysql.jdbc.Driver but then i get
again an error on db.default.url.

Cannot connect to database [default]

Why has mysql and postgres a special url and what is the right driver for them?

Thanks for the quick answer btw.
Greetings Severin

Ben McCann

unread,
Feb 16, 2012, 4:30:08 PM2/16/12
to play-fr...@googlegroups.com, seki...@gmail.com
This is a standard JDBC thing.  It is not something specific to play.

You need the following driver to connect to MySQL:
db.default.driver=com.mysql.jdbc.Driver

And you need a URL starting with jdbc:mysql:// and surrounded by double quotes:
db.default.url="jdbc:mysql://localhost/your_database_name"

You can read more about the format of the URL in many JDBC tutorials if you are having trouble forming it.  Any Java framework will make you use the same URL.

Илья Скорик

unread,
Feb 17, 2012, 1:31:35 AM2/17/12
to play-fr...@googlegroups.com
Why is the documentation for the connection to the database is not correct?

2012/2/17 Ben McCann <benjamin...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/play-framework/-/Wqoz8lP8ElMJ.


>
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.

--
С уважением, Илья Скорик
Yours faithfully, Ilya Skorik

Ben McCann

unread,
Feb 17, 2012, 1:36:42 AM2/17/12
to play-fr...@googlegroups.com
I added quotes around all the URLs in the Java documentation.  Let me know if you still have trouble with it.


2012/2/16 Илья Скорик <il...@skorik.me>

Severin Kistner

unread,
Feb 17, 2012, 9:19:01 AM2/17/12
to play-fr...@googlegroups.com
Thanks Ben, now i got it working. It took me 2 minute after i viewed
the jdbc documentation, i am new to the java ecosystem.

This is my url: "jdbc:mysql://localhost/db?user=play&password=secret"

2012/2/17 Ben McCann <b...@benmccann.com>:

Ben McCann

unread,
Feb 17, 2012, 11:34:03 AM2/17/12
to play-fr...@googlegroups.com
The username and password usually go in their own configuration variables instead of on the URL:

db.default.user="username"
db.default.password="pass"


2012/2/17 Severin Kistner <seki...@googlemail.com>

Technotim

unread,
May 28, 2012, 6:40:00 PM5/28/12
to play-fr...@googlegroups.com
I'm having the same problem.
My connection string seems right:

db.default.url="jdbc:mysql://localhost/database/"
db.default.driver=com.mysql.jdbc.Driver
db.default.user=play
db.default.pass=password

Results in "Cannot connect to database [default]" error, the database already exists, and I can modify it through phpmyadmin. Is there something on the server side that needs to be configured so the URL works correctly?

Thanks,
-Tim

kutabale

unread,
Jul 24, 2012, 9:49:47 AM7/24/12
to play-fr...@googlegroups.com
Hi Did any one figure out this connection to MySql issue. I still have problem to actually connect to the data base. i get this error
 
partitionCount.url has type NUMBER rather than OBJECT
 
db.default.url="jdbc:mysql://68.53.235.112:3307/activities"

Meglio

unread,
Jul 24, 2012, 12:53:22 PM7/24/12
to play-fr...@googlegroups.com
Julia, sorry for offtopic, but my grand mother name is Юлия Скорик - wow what a sign LOL

Meglio

unread,
Jul 24, 2012, 12:54:16 PM7/24/12
to play-fr...@googlegroups.com
Well at least can you tell what exact play and jvm version do you use?
Maybe make a screenshot showing all details of your error, with trace?
Then it will be easier to help.

Havoc Pennington

unread,
Jul 24, 2012, 7:22:06 PM7/24/12
to play-fr...@googlegroups.com
Hi,

On Tue, Jul 24, 2012 at 9:49 AM, kutabale <liris...@gmail.com> wrote:
> Hi Did any one figure out this connection to MySql issue. I still have
> problem to actually connect to the data base. i get this error
>
> partitionCount.url has type NUMBER rather than OBJECT
>
> db.default.url="jdbc:mysql://68.53.235.112:3307/activities"
>

The error is about partitionCount.url but you showed us the config for
db.default.url - maybe partitionCount.url is somewhere else in the
file? What is it set to?

Havoc
Reply all
Reply to author
Forward
0 new messages