[英]how to connect to postgresql in play framework 2.0 (Java)
i am have problem while connecting to postgresql with playframework. 我在用playframework连接到postgresql时遇到问题。
error is Driver not found: [org.postgresql.Driver] 错误是找不到驱动程序:[org.postgresql.Driver]
we have added Code in application.conf: 我们在application.conf中添加了代码:
db.default.url="postgres://localhost:root@secret/testdb"
db.default.driver=org.postgresql.Driver
db.default.user=""
db.default.password=""
code in Build.scala: Build.scala中的代码:
"postgresql" % "postgresql" % "9.1-902.jdbc4"
And we have placed postgresql-9.1-902.jdbc4.jar file in libraries folder 并且我们将postgresql-9.1-902.jdbc4.jar文件放置在库文件夹中
Could anyone has suggestions regarding this problem. 任何人都可以对这个问题提出建议。
I don't think that is a valid version of the Postgres library. 我认为这不是Postgres库的有效版本。 Try: 尝试:
"postgresql" % "postgresql" % "9.1-901-1.jdbc4"
Then restart Play. 然后重新启动播放。
Do you have the PostgreSQL JDBC driver in your classpath ? 您的类路径中是否有PostgreSQL JDBC驱动程序 ? See the final section of this document . 请参阅本文档的最后一节。
For example, if you use MySQL5, you need to add a dependency for the connector: 例如,如果使用MySQL5,则需要为连接器添加依赖项:
val appDependencies = Seq(
// Add your project dependencies here,
...
"mysql" % "mysql-connector-java" % "5.1.18"
...
)
You are most likely missing the jdbc driver. 您很可能缺少jdbc驱动程序。
Get the driver from http://jdbc.postgresql.org/download.html . 从http://jdbc.postgresql.org/download.html获取驱动程序。
Place it in the lib/ directory in application folder. 将其放在应用程序文件夹的lib /目录中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.