Play Framework with Scala,无法连接到数据库 JDBC Postgresql
Play Framework with Scala, cannot connect to database JDBC Postgresql
我正在关注 "Play for Scala" 这本书。我目前正在尝试建立与我机器上 运行 的 PostgreSQL 数据库的连接,但是我无法连接,我不确定为什么。我的一个同事也有一个使用 Play with PostgreSQL 的项目,该项目被克隆到与 PostgreSQL 运行 相同的机器上,并且运行良好。
我收到以下错误:
[info] - application - Creating Pool for datasource 'default'
[error] - application -
! @6pb6jk4k6 - Internal server error, for (GET) [/products] ->
play.api.Configuration$$anon: Configuration error[Cannot connect to database [default]]
at play.api.Configuration$.configError(Configuration.scala:178) ~[play_2.11-2.4.6.jar:2.4.6]
at play.api.Configuration.reportError(Configuration.scala:829) ~[play_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDBApi$$anonfun$connect.apply(DefaultDBApi.scala:48) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDBApi$$anonfun$connect.apply(DefaultDBApi.scala:42) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at scala.collection.immutable.List.foreach(List.scala:381) ~[scala-library-2.11.7.jar:na]
at play.api.db.DefaultDBApi.connect(DefaultDBApi.scala:42) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DBApiProvider.get$lzycompute(DBModule.scala:72) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DBApiProvider.get(DBModule.scala:62) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DBApiProvider.get(DBModule.scala:58) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81) ~[guice-4.0.jar:na]
at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72) ~[guice-4.0.jar:na]
at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61) ~[guice-4.0.jar:na]
at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62) ~[guice-4.0.jar:na]
at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:54) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:132) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.call(MembersInjectorImpl.java:93) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.call(MembersInjectorImpl.java:80) ~[guice-4.0.jar:na]
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:80) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:62) ~[guice-4.0.jar:na]
at com.google.inject.internal.InjectorImpl.injectMembers(InjectorImpl.java:984) ~[guice-4.0.jar:na]
at com.google.inject.util.Providers$GuicifiedProviderWithDependencies.initialize(Providers.java:149) ~[guice-4.0.jar:na]
at com.google.inject.util.Providers$GuicifiedProviderWithDependencies$$FastClassByGuice$a7177aa.invoke(<generated>) ~[guice-4.0.jar:na]
at com.google.inject.internal.cglib.reflect.$FastMethod.invoke(FastMethod.java:53) ~[guice-4.0.jar:na]
at com.google.inject.internal.SingleMethodInjector.invoke(SingleMethodInjector.java:57) ~[guice-4.0.jar:na]
at com.google.inject.internal.SingleMethodInjector.inject(SingleMethodInjector.java:91) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:132) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.call(MembersInjectorImpl.java:93) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.call(MembersInjectorImpl.java:80) ~[guice-4.0.jar:na]
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:80) ~[guice-4.0.jar:na]
at com.google.inject.internal.Initializer$InjectableReference.get(Initializer.java:174) ~[guice-4.0.jar:na]
at com.google.inject.internal.Initializer.injectAll(Initializer.java:108) ~[guice-4.0.jar:na]
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:174) ~[guice-4.0.jar:na]
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110) ~[guice-4.0.jar:na]
at com.google.inject.Guice.createInjector(Guice.java:96) ~[guice-4.0.jar:na]
at com.google.inject.Guice.createInjector(Guice.java:73) ~[guice-4.0.jar:na]
at com.google.inject.Guice.createInjector(Guice.java:62) ~[guice-4.0.jar:na]
at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126) ~[play_2.11-2.4.6.jar:2.4.6]
at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93) ~[play_2.11-2.4.6.jar:2.4.6]
at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21) ~[play_2.11-2.4.6.jar:2.4.6]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get$$anonfun$apply$$anonfun$$anonfun.apply(DevServerStart.scala:153) ~[play-server_2.11-2.4.6.jar:2.4.6]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get$$anonfun$apply$$anonfun$$anonfun.apply(DevServerStart.scala:150) ~[play-server_2.11-2.4.6.jar:2.4.6]
at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.11-2.4.6.jar:2.4.6]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get$$anonfun$apply$$anonfun.apply(DevServerStart.scala:150) ~[play-server_2.11-2.4.6.jar:2.4.6]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get$$anonfun$apply$$anonfun.apply(DevServerStart.scala:121) ~[play-server_2.11-2.4.6.jar:2.4.6]
at scala.Option.map(Option.scala:146) ~[scala-library-2.11.7.jar:na]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get$$anonfun$apply.apply(DevServerStart.scala:121) ~[play-server_2.11-2.4.6.jar:2.4.6]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get$$anonfun$apply.apply(DevServerStart.scala:119) ~[play-server_2.11-2.4.6.jar:2.4.6]
at scala.util.Success.flatMap(Try.scala:231) ~[scala-library-2.11.7.jar:na]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get.apply(DevServerStart.scala:119) ~[play-server_2.11-2.4.6.jar:2.4.6]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get.apply(DevServerStart.scala:111) ~[play-server_2.11-2.4.6.jar:2.4.6]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1(Future.scala:24) ~[scala-library-2.11.7.jar:na]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) ~[scala-library-2.11.7.jar:na]
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402) ~[na:1.8.0_66]
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[na:1.8.0_66]
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[na:1.8.0_66]
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) ~[na:1.8.0_66]
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[na:1.8.0_66]
Caused by: play.api.Configuration$$anon: Configuration error[Exception during pool initialization]
at play.api.Configuration$.configError(Configuration.scala:178) ~[play_2.11-2.4.6.jar:2.4.6]
at play.api.PlayConfig.reportError(Configuration.scala:1048) ~[play_2.11-2.4.6.jar:2.4.6]
at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:69) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.PooledDatabase.createDataSource(Databases.scala:199) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:124) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDatabase.dataSource(Databases.scala:122) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDatabase.getConnection(Databases.scala:143) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDatabase.getConnection(Databases.scala:139) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDBApi$$anonfun$connect.apply(DefaultDBApi.scala:44) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
... 56 common frames omitted
Caused by: com.zaxxer.hikari.pool.PoolInitializationException: Exception during pool initialization
at com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:542) ~[HikariCP-2.3.7.jar:na]
at com.zaxxer.hikari.pool.BaseHikariPool.<init>(BaseHikariPool.java:171) ~[HikariCP-2.3.7.jar:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:60) ~[HikariCP-2.3.7.jar:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:48) ~[HikariCP-2.3.7.jar:na]
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:80) ~[HikariCP-2.3.7.jar:na]
at play.api.db.HikariCPConnectionPool$$anonfun.apply(HikariCPModule.scala:58) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.HikariCPConnectionPool$$anonfun.apply(HikariCPModule.scala:54) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at scala.util.Try$.apply(Try.scala:192) ~[scala-library-2.11.7.jar:na]
at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:54) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
... 62 common frames omitted
Caused by: java.sql.SQLException: JDBC4 Connection.isValid() method not supported, connection test query must be configured
at com.zaxxer.hikari.pool.BaseHikariPool.addConnection(BaseHikariPool.java:441) ~[HikariCP-2.3.7.jar:na]
at com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:540) ~[HikariCP-2.3.7.jar:na]
... 70 common frames omitted
这里是application.conf
中的相关代码:
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost:5432/paperclips"
db.default.username="postgres"
db.default.password="postgres"
在构建文件中:
libraryDependencies ++= Seq(
"com.typesafe.play" %% "anorm" % "2.4.0",
"com.adrianhurt" %% "play-bootstrap3" % "0.4.5-P24",
"net.sf.barcode4j" % "barcode4j" % "2.0",
"postgresql" % "postgresql" % "9.1-901.jdbc4"
)
如果您使用的是更新版本的 PostgreSQL,您可能需要使用更新版本的驱动程序:
libraryDependencies += "org.postgresql" % "postgresql" % "9.4.1208"
我正在关注 "Play for Scala" 这本书。我目前正在尝试建立与我机器上 运行 的 PostgreSQL 数据库的连接,但是我无法连接,我不确定为什么。我的一个同事也有一个使用 Play with PostgreSQL 的项目,该项目被克隆到与 PostgreSQL 运行 相同的机器上,并且运行良好。
我收到以下错误:
[info] - application - Creating Pool for datasource 'default'
[error] - application -
! @6pb6jk4k6 - Internal server error, for (GET) [/products] ->
play.api.Configuration$$anon: Configuration error[Cannot connect to database [default]]
at play.api.Configuration$.configError(Configuration.scala:178) ~[play_2.11-2.4.6.jar:2.4.6]
at play.api.Configuration.reportError(Configuration.scala:829) ~[play_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDBApi$$anonfun$connect.apply(DefaultDBApi.scala:48) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDBApi$$anonfun$connect.apply(DefaultDBApi.scala:42) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at scala.collection.immutable.List.foreach(List.scala:381) ~[scala-library-2.11.7.jar:na]
at play.api.db.DefaultDBApi.connect(DefaultDBApi.scala:42) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DBApiProvider.get$lzycompute(DBModule.scala:72) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DBApiProvider.get(DBModule.scala:62) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DBApiProvider.get(DBModule.scala:58) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81) ~[guice-4.0.jar:na]
at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72) ~[guice-4.0.jar:na]
at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61) ~[guice-4.0.jar:na]
at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62) ~[guice-4.0.jar:na]
at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:54) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:132) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.call(MembersInjectorImpl.java:93) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.call(MembersInjectorImpl.java:80) ~[guice-4.0.jar:na]
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:80) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:62) ~[guice-4.0.jar:na]
at com.google.inject.internal.InjectorImpl.injectMembers(InjectorImpl.java:984) ~[guice-4.0.jar:na]
at com.google.inject.util.Providers$GuicifiedProviderWithDependencies.initialize(Providers.java:149) ~[guice-4.0.jar:na]
at com.google.inject.util.Providers$GuicifiedProviderWithDependencies$$FastClassByGuice$a7177aa.invoke(<generated>) ~[guice-4.0.jar:na]
at com.google.inject.internal.cglib.reflect.$FastMethod.invoke(FastMethod.java:53) ~[guice-4.0.jar:na]
at com.google.inject.internal.SingleMethodInjector.invoke(SingleMethodInjector.java:57) ~[guice-4.0.jar:na]
at com.google.inject.internal.SingleMethodInjector.inject(SingleMethodInjector.java:91) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:132) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.call(MembersInjectorImpl.java:93) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.call(MembersInjectorImpl.java:80) ~[guice-4.0.jar:na]
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092) ~[guice-4.0.jar:na]
at com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:80) ~[guice-4.0.jar:na]
at com.google.inject.internal.Initializer$InjectableReference.get(Initializer.java:174) ~[guice-4.0.jar:na]
at com.google.inject.internal.Initializer.injectAll(Initializer.java:108) ~[guice-4.0.jar:na]
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:174) ~[guice-4.0.jar:na]
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110) ~[guice-4.0.jar:na]
at com.google.inject.Guice.createInjector(Guice.java:96) ~[guice-4.0.jar:na]
at com.google.inject.Guice.createInjector(Guice.java:73) ~[guice-4.0.jar:na]
at com.google.inject.Guice.createInjector(Guice.java:62) ~[guice-4.0.jar:na]
at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126) ~[play_2.11-2.4.6.jar:2.4.6]
at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93) ~[play_2.11-2.4.6.jar:2.4.6]
at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21) ~[play_2.11-2.4.6.jar:2.4.6]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get$$anonfun$apply$$anonfun$$anonfun.apply(DevServerStart.scala:153) ~[play-server_2.11-2.4.6.jar:2.4.6]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get$$anonfun$apply$$anonfun$$anonfun.apply(DevServerStart.scala:150) ~[play-server_2.11-2.4.6.jar:2.4.6]
at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.11-2.4.6.jar:2.4.6]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get$$anonfun$apply$$anonfun.apply(DevServerStart.scala:150) ~[play-server_2.11-2.4.6.jar:2.4.6]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get$$anonfun$apply$$anonfun.apply(DevServerStart.scala:121) ~[play-server_2.11-2.4.6.jar:2.4.6]
at scala.Option.map(Option.scala:146) ~[scala-library-2.11.7.jar:na]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get$$anonfun$apply.apply(DevServerStart.scala:121) ~[play-server_2.11-2.4.6.jar:2.4.6]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get$$anonfun$apply.apply(DevServerStart.scala:119) ~[play-server_2.11-2.4.6.jar:2.4.6]
at scala.util.Success.flatMap(Try.scala:231) ~[scala-library-2.11.7.jar:na]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get.apply(DevServerStart.scala:119) ~[play-server_2.11-2.4.6.jar:2.4.6]
at play.core.server.DevServerStart$$anonfun$mainDev$$anon$$anonfun$get.apply(DevServerStart.scala:111) ~[play-server_2.11-2.4.6.jar:2.4.6]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1(Future.scala:24) ~[scala-library-2.11.7.jar:na]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) ~[scala-library-2.11.7.jar:na]
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402) ~[na:1.8.0_66]
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[na:1.8.0_66]
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[na:1.8.0_66]
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) ~[na:1.8.0_66]
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[na:1.8.0_66]
Caused by: play.api.Configuration$$anon: Configuration error[Exception during pool initialization]
at play.api.Configuration$.configError(Configuration.scala:178) ~[play_2.11-2.4.6.jar:2.4.6]
at play.api.PlayConfig.reportError(Configuration.scala:1048) ~[play_2.11-2.4.6.jar:2.4.6]
at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:69) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.PooledDatabase.createDataSource(Databases.scala:199) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:124) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDatabase.dataSource(Databases.scala:122) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDatabase.getConnection(Databases.scala:143) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDatabase.getConnection(Databases.scala:139) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.DefaultDBApi$$anonfun$connect.apply(DefaultDBApi.scala:44) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
... 56 common frames omitted
Caused by: com.zaxxer.hikari.pool.PoolInitializationException: Exception during pool initialization
at com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:542) ~[HikariCP-2.3.7.jar:na]
at com.zaxxer.hikari.pool.BaseHikariPool.<init>(BaseHikariPool.java:171) ~[HikariCP-2.3.7.jar:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:60) ~[HikariCP-2.3.7.jar:na]
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:48) ~[HikariCP-2.3.7.jar:na]
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:80) ~[HikariCP-2.3.7.jar:na]
at play.api.db.HikariCPConnectionPool$$anonfun.apply(HikariCPModule.scala:58) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at play.api.db.HikariCPConnectionPool$$anonfun.apply(HikariCPModule.scala:54) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
at scala.util.Try$.apply(Try.scala:192) ~[scala-library-2.11.7.jar:na]
at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:54) ~[play-jdbc_2.11-2.4.6.jar:2.4.6]
... 62 common frames omitted
Caused by: java.sql.SQLException: JDBC4 Connection.isValid() method not supported, connection test query must be configured
at com.zaxxer.hikari.pool.BaseHikariPool.addConnection(BaseHikariPool.java:441) ~[HikariCP-2.3.7.jar:na]
at com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:540) ~[HikariCP-2.3.7.jar:na]
... 70 common frames omitted
这里是application.conf
中的相关代码:
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost:5432/paperclips"
db.default.username="postgres"
db.default.password="postgres"
在构建文件中:
libraryDependencies ++= Seq(
"com.typesafe.play" %% "anorm" % "2.4.0",
"com.adrianhurt" %% "play-bootstrap3" % "0.4.5-P24",
"net.sf.barcode4j" % "barcode4j" % "2.0",
"postgresql" % "postgresql" % "9.1-901.jdbc4"
)
如果您使用的是更新版本的 PostgreSQL,您可能需要使用更新版本的驱动程序:
libraryDependencies += "org.postgresql" % "postgresql" % "9.4.1208"