お世話になってます。
今、PlayでMydsqlに接続したいのですが、
うまくいきません。
設定は間違ってないかなと思うんですが、
何が悪いのでしょうか?
お分りの方居られましたら、ご教示下さい。
宜しくお願い致します。
本当に困ってます。助けて下さい。
試したこと
default.driverClassName = com.mysql.jdbc.Driver
で記入したが駄目。
●$activator libraryDependencies
[info] List(org.scala-lang:scala-library:2.11.7, com.typesafe.play:play-enhancer:1.1.0, com.typesafe.play:twirl-api:1.1.1, com.typesafe.play:play-ebean:3.0.2, com.typesafe.play:play-server:2.5.10, com.typesafe.play:play-test:2.5.10:test, com.typesafe.play:play-omnidoc:2.5.10:docs, com.typesafe.play:play-java:2.5.10, com.typesafe.play:play-netty-server:2.5.10, com.typesafe.play:play-logback:2.5.10, com.typesafe.play:play-java-jdbc:2.5.10, com.typesafe.play:play-cache:2.5.10, com.typesafe.play:play-java-ws:2.5.10, mysql:mysql-connector-java:5.1.36, mysql:mysql-connector-java:5.1.36)
●build.sbt
libraryDependencies ++= Seq( javaJdbc, cache, javaWs, "mysql" % "mysql-connector-java" % "5.1.36" )
●application.conf
play.db{ (中略) config="db" default="default" (中略) } db{ (中略) default.driver = com.mysql.jdbc.Driver ebean.default=["models.*"] default.username = root default.password = "nfgwe4706" default.schema = "sample_db" default.port = "3306" default.jdbcUrl = "jdbc:mysql://localhost/sample_db" (中略) }
●エラー内容
play.api.Configuration$$anon$1: Configuration error[Cannot connect to database [default]] at play.api.Configuration$.configError(Configuration.scala:154) at play.api.Configuration.reportError(Configuration.scala:806) at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:48) at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:42) at scala.collection.immutable.List.foreach(List.scala:381) at play.api.db.DefaultDBApi.connect(DefaultDBApi.scala:42) at play.api.db.DBApiProvider.get$lzycompute(DBModule.scala:72) at play.api.db.DBApiProvider.get(DBModule.scala:62) at play.api.db.DBApiProvider.get(DBModule.scala:58) at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81) Caused by: play.api.Configuration$$anon$1: Configuration error[jdbcUrl is required with driverClassName.] at play.api.Configuration$.configError(Configuration.scala:154) at play.api.PlayConfig.reportError(Configuration.scala:996) at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:70) at play.api.db.PooledDatabase.createDataSource(Databases.scala:199) at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:123) at play.api.db.DefaultDatabase.dataSource(Databases.scala:121) at play.api.db.DefaultDatabase.getConnection(Databases.scala:142) at play.api.db.DefaultDatabase.getConnection(Databases.scala:138) at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:44) at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:42) Caused by: java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName. at com.zaxxer.hikari.HikariConfig.validate(HikariConfig.java:782) at play.api.db.HikariCPConfig.toHikariConfig(HikariCPModule.scala:141) at play.api.db.HikariCPConnectionPool$$anonfun$1.apply(HikariCPModule.scala:57) at play.api.db.HikariCPConnectionPool$$anonfun$1.apply(HikariCPModule.scala:54) at scala.util.Try$.apply(Try.scala:192) at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:54) at play.api.db.PooledDatabase.createDataSource(Databases.scala:199) at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:123) at play.api.db.DefaultDatabase.dataSource(Databases.scala:121) at play.api.db.DefaultDatabase.getConnection(Databases.scala:142)
●エラー内容2
play.api.Configuration$$anon$1: Configuration error[Cannot connect to database [default]] at play.api.Configuration$.configError(Configuration.scala:154) at play.api.Configuration.reportError(Configuration.scala:806) at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:48) at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:42) at scala.collection.immutable.List.foreach(List.scala:381) at play.api.db.DefaultDBApi.connect(DefaultDBApi.scala:42) at play.api.db.DBApiProvider.get$lzycompute(DBModule.scala:72) at play.api.db.DBApiProvider.get(DBModule.scala:62) at play.api.db.DBApiProvider.get(DBModule.scala:58) at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81) Caused by: play.api.Configuration$$anon$1: Configuration error[jdbcUrl is required with driverClassName.] at play.api.Configuration$.configError(Configuration.scala:154) at play.api.PlayConfig.reportError(Configuration.scala:996) at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:70) at play.api.db.PooledDatabase.createDataSource(Databases.scala:199) at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:123) at play.api.db.DefaultDatabase.dataSource(Databases.scala:121) at play.api.db.DefaultDatabase.getConnection(Databases.scala:142) at play.api.db.DefaultDatabase.getConnection(Databases.scala:138) at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:44) at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:42) Caused by: java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName. at com.zaxxer.hikari.HikariConfig.validate(HikariConfig.java:893) at play.api.db.HikariCPConfig.toHikariConfig(HikariCPModule.scala:141) at play.api.db.HikariCPConnectionPool$$anonfun$1.apply(HikariCPModule.scala:57) at play.api.db.HikariCPConnectionPool$$anonfun$1.apply(HikariCPModule.scala:54) at scala.util.Try$.apply(Try.scala:192) at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:54) at play.api.db.PooledDatabase.createDataSource(Databases.scala:199) at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:123) at play.api.db.DefaultDatabase.dataSource(Databases.scala:121) at play.api.db.DefaultDatabase.getConnection(Databases.scala:142)
●application.conf(2018.01.21)
akka { } play.crypto.secret = "changeme" play.modules { enables += "play.api.db.DBModule" enables += "play.api.db.HikariCPModule" } fixedConnectionPool=2 play.i18n { langs = [ "en" ] } play.evolutions { db.default.enabled = false } play.db { prototype { # Sets a fixed JDBC connection pool size of 50 #hikaricp.minimumIdle = 50 #hikaricp.maximumPoolSize = 50 } } db { default.driver=com.mysql.jdbc.Driver default.username=root default.password="nfgwe4706" default.jdbcUrl="jdbc:mysql://localhost:3306/sample_db" } db.default.hikaricp.driverClassName=com.mysql.cp.jdbc.Driver db.default.hikaricp.username=root db.default.hikaricp.password="nfgwe4706" db.default.hikaricp.jdbcUrl="jdbc:mysql://localhost:3306/sample_db" db.default.hikaricp.minimumIdle=${fixedConnectionPool} db.default.hikaricp.maximumPoolSize=${fixedConnectionPool} ebean.default=["model.*"] "assets.cache./public/stylesheets/bootstrap.min.css"="max-age=3600" database.dispatcher{ type=Dispatcher executor="thread-pool-executor" throughput=1 thread-pool-executor{ fixed-pool-size = ${fixedConnectionPool} } }
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/25 02:15 編集
退会済みユーザー
2019/01/18 03:12
退会済みユーザー
2019/01/18 03:18
2019/01/18 11:38 編集
退会済みユーザー
2019/01/18 05:21
2019/01/18 11:35
2019/01/21 06:42
2019/01/22 00:46