我剛剛從Ubuntu 10.04重新安裝了我的操作系統到12.04,我在Ubuntu 10.04上使用了play 2.0.1,一切都在10.04上正常運行,但現在使用相同的遊戲2.0.1事情搞砸了,現在我每次運行命令play "run 80"
服務器啓動,但是當我打我的應用程序的索引頁它給了我以下異常:playframework 2.0.1:連接數據庫總是失敗
[error] application -
! @6bh1b1h5g - Internal server error, for request [GET /] ->
play.api.Configuration$$anon$1: Configuration error [Cannot connect to database [mytestdb]]
at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:71) ~[play_2.9.1.jar:2.0.1]
at play.api.Configuration.reportError(Configuration.scala:258) ~[play_2.9.1.jar:2.0.1]
at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:240) ~[play_2.9.1.jar:2.0.1]
at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:231) ~[play_2.9.1.jar:2.0.1]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.2]
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.2]
正在添加和這個論壇之前,我仔細檢查了這:
- mysql正在運行。
- 用戶具有足夠的權限(通過記錄此用戶並在bash終端內的此db上運行一些選擇命令)。
- 我的項目編譯成功。與一些小的改動
配置文件:
# This is the main configuration file for the application.
# ~~~~~
# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
# If you deploy your application to several instances be sure to use the same key!
application.secret="*********************************"
# The application languages
# ~~~~~
application.langs="en"
# Global object class
# ~~~~~
# Define the Global object class for this application.
# Default to Global in the root package.
# global=Global
# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
db.mytestdb.url="mysql://user1:[email protected]:3306/mytestdb"
db.mytestdb.driver=com.mysql.jdbc.Driver
db.mytestdb.user="user1"
db.mytestdb.pass="user1"
db.mytestdb.jndiName=mytestdbDS
jpa.default=TESTmytestdb
jpa.TESTmytestdb=TESTmytestdb
# Logger
# ~~~~~
# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .
# Root logger:
logger.root=ERROR
# Logger used by the framework:
logger.play=INFO
# Logger provided to your application:
logger.application=DEBUG
向我們展示您對此DB的配置,整體而言,僅將密碼更改爲'***'而沒有別的。 – biesior
添加了一些小的更改(用戶,密碼和數據庫名稱)的配置文件 – gmuhammad
您嘗試使用'localhost'而不是'127.0.0.1'。也許它來自MySQL配置中的綁定地址(http://serverfault.com/a/139324)。 –