0

There is my configure :

 db.default.driver=com.mysql.jdbc.Driver
 db.default.url="jdbc:mysql:root:play2test" //Cannot connect to database [default] -> play mark this line
 db.default.user=root
 db.default.pass=123456

I already created play2test.mwb with MySql-workbench, i have tried other way like :

 db.default.driver="com.mysql.jdbc.Driver"
 db.default.url="jdbc:mysql:root:play2test" 
 db.default.user="root"
 db.default.pass="123456"

but allways get this error : db has type STRING rather than OBJECT

in terminal :

[error] c.j.b.h.AbstractConnectionHook - Failed to obtain initial connection Sleeping for 0ms and trying again. Attempts left: 0. Exception: null
[error] application - 

! @6epj0nb4d - Internal server error, for request [GET /] ->

play.api.Configuration$$anon$1: Configuration error [Cannot connect to database [default]]
    at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:71) ~[play_2.9.1.jar:2.0.4]
    at play.api.Configuration.reportError(Configuration.scala:258) ~[play_2.9.1.jar:2.0.4]
    at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:249) ~[play_2.9.1.jar:2.0.4]
    at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:240) ~[play_2.9.1.jar:2.0.4]
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.3]
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.3]
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql:root:play2test
    at java.sql.DriverManager.getConnection(DriverManager.java:640) ~[na:1.6.0_27]
    at java.sql.DriverManager.getConnection(DriverManager.java:200) ~[na:1.6.0_27]
    at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:256) ~[bonecp.jar:0.7.1.RELEASE]
    at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:305) ~[bonecp.jar:0.7.1.RELEASE]
    at com.jolbox.bonecp.BoneCPDataSource.maybeInit(BoneCPDataSource.java:150) ~[bonecp.jar:0.7.1.RELEASE]
    at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:112) ~[bonecp.jar:0.7.1.RELEASE]

I tried to uncomment at

ebean.default="models.*"

and added the sbt dependency:

 "mysql" % "mysql-connector-java" % "5.1.21"

But it did'nt work :(((( So how can i solved it :(.

Sry if my english is bad

Mèo Béo
  • 111
  • 1
  • 4
  • 11

3 Answers3

4

Try following way:

   db.default.url="jdbc:mysql://your_server_address:3306/play2test" 
   db.default.driver="com.mysql.jdbc.Driver"
   db.default.user=root
   db.default.pass="123456"
   db.default.host=your_server_address
wattostudios
  • 8,446
  • 13
  • 40
  • 54
2

Your connection url is formatted wrong. Try using:

db.default.url="jdbc:mysql://localhost/play2test"

And make sure you set the product dependency in /project/Build.scala, change the 5.1.25 to whatever version your mysql connector is

val appDependencies = Seq(

"mysql" % "mysql-connector-java" % "5.1.25"

)

And in the same file, make sure that this line is not commented

ebean.default="models.*"
Mark M
  • 1,550
  • 10
  • 21
  • i try this : #ebean.default="models.*" => but still not working :( – Mèo Béo Jul 09 '13 at 08:23
  • Uncomment it and try again, also to be sure, double check that your MySQL service is running, and that all your connection properties are enclosed in quotes, including driver and username. – Mark M Jul 09 '13 at 08:29
0

The url should be something like:

db.default.url="jdbc:mysql://your_server_address/play2test"
M. Abbas
  • 6,073
  • 4
  • 30
  • 40
  • i try: db.default.url="jdbc:mysql://localhost:9000/play2test" and db.default.url="jdbc:mysql://localhost/play2test ----but it's not still working :( – Mèo Béo Jul 09 '13 at 08:18