playframework 2.0.1:连接数据库总是失败

时间:2012-09-02 10:34:58

标签: java mysql playframework-2.0 ubuntu-12.04

我刚刚将我的操作系统从Ubuntu 10.04重新安装到12.04,我在ubuntu 10.04上使用了play 2.0.1,一切都在10.04上运行正常,但现在使用相同的播放2.0.1事情搞砸了,现在每次我运行服务器启动的命令play "run 80"但是当我点击我的应用程序的索引页面时,它给出了以下异常:

[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终端内的此数据库上运行一些select命令)。
  3. 我的项目编译成功。
  4. 配置文件有一些小的改动:

    # 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:user1@127.0.0.1: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
    

3 个答案:

答案 0 :(得分:0)

我认为这是关于您的网址检查其他答案并修复它:

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

答案 1 :(得分:0)

您是否尝试过将用户:密码从这个网址中移除?

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

答案 2 :(得分:0)

这是未启动的memcached问题。现在我通过启动memcached来实现它。