2012-09-02 21 views
0

我剛剛從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] 

正在添加和這個論壇之前,我仔細檢查了這:

  1. mysql正在運行。
  2. 用戶具有足夠的權限(通過記錄此用戶並在bash終端內的此db上運行一些選擇命令)。
  3. 我的項目編譯成功。與一些小的改動

配置文件:

# 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 
+0

向我們展示您對此DB的配置,整體而言,僅將密碼更改爲'***'而沒有別的。 – biesior

+0

添加了一些小的更改(用戶,密碼和數據庫名稱)的配置文件 – gmuhammad

+0

您嘗試使用'localhost'而不是'127.0.0.1'。也許它來自MySQL配置中的綁定地址(http://serverfault.com/a/139324)。 –

回答

0

這是memcached沒有啓動的問題。現在我通過啓動memcached來實現它。

0

我認爲這是你的URL檢查對方的回答和解決這個問題:

https://stackoverflow.com/a/10007515/1066240

+0

val appDependencies = Seq( 「mysql」%「mysql-connector-java」%「5.1.18」, 「org.hibernate」%「hibernate-entitymanager」%「3.6.9.Final」, 「org。 apache.httpcomponents「%」httpclient「%」4.1.3「, 」com.github.mumoshu「%%」play2-memcached「%」0.2.1-SNAPSHOT「) – gmuhammad

+0

它已經在那裏。 (如果我沒有錯,那就是你在鏈接中提到的)。我已經說過所有的東西都在Ubuntu 10.04上工作。 :( – gmuhammad

+0

不是:我是指你的'db.mytestdb.url =「mysql:// user1:[email protected] ...」'把它切換到'db.mytestdb.url =「jdbc:mysql://localhost/mytestdb?characterEncoding = UTF-8「'(在啓動時沒有憑據的jdbc) – biesior

0

您是否嘗試過刪除用戶名:密碼遠從這樣的網址?

db.mytestdb.url="jdbc:mysql://localhost:3306/mytestdb" 
db.mytestdb.driver=com.mysql.jdbc.Driver 
db.mytestdb.user="user1" 
db.mytestdb.pass="user1"