有我的配置:
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
我已经使用 MySql-workbench 创建了 play2test.mwb,我尝试了其他方式,例如:
db.default.driver="com.mysql.jdbc.Driver"
db.default.url="jdbc:mysql:root:play2test"
db.default.user="root"
db.default.pass="123456"
但总是会出现此错误:db 的类型为 STRING 而不是 OBJECT
在终端:
[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]
我试图取消评论
ebean.default="models.*"
并添加了 sbt 依赖项:
"mysql" % "mysql-connector-java" % "5.1.21"
但它没有工作:((((那么我怎么能解决它:(。
对不起,如果我的英语不好