Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java playframework 2.0.1:连接到数据库总是失败_Java_Mysql_Playframework 2.0_Ubuntu 12.04 - Fatal编程技术网

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

Java playframework 2.0.1:连接到数据库总是失败,java,mysql,playframework-2.0,ubuntu-12.04,Java,Mysql,Playframework 2.0,Ubuntu 12.04,我刚刚将我的操作系统从Ubuntu 10.04重新安装到12.04,我在Ubuntu 10.04上使用play 2.0.1,在10.04上一切都正常,但现在使用同样的play 2.0.1,事情变得一团糟,现在每次我运行命令play“run 80”服务器启动,但当我点击我的应用程序的索引页时,会出现以下异常: [error] application - ! @6bh1b1h5g - Internal server error, for request [GET /] -> play.a

我刚刚将我的操作系统从Ubuntu 10.04重新安装到12.04,我在Ubuntu 10.04上使用play 2.0.1,在10.04上一切都正常,但现在使用同样的play 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]
在参加这个论坛之前,我仔细检查了一下:

  • mysql正在运行
  • 用户具有足够的权限(通过记录此用户并在bash终端内的此db上运行一些select命令)
  • 我的项目编译成功
  • 配置文件有一些小改动:

    # 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
    

    我想这是关于你的URL检查其他答案并修复它:


    您是否尝试过像这样从url中删除user:password

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

    是memcached问题没有启动。现在,我通过启动memcached使其工作。

    向我们展示您对此数据库的配置,整个数据库,仅将密码更改为
    ***
    ,而不更改任何其他内容。添加了配置文件,并进行了一些小的更改(用户、密码和数据库名称),您是否尝试使用
    本地主机
    而不是
    127.0.0.1
    。也许它来自MySQL配置()中的绑定地址。@nico_ekito:127.0.0.1版本的Ubuntu10.04是如何工作的。使用localhost对我来说似乎很奇怪,但是让我试试,我会告诉你的。@nico_ekito:没有改变,得到相同的错误。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”)它已经在那里了。(如果我没记错的话,这就是你在链接中提到的内容)。我已经说过在Ubuntu 10.04上一切都处于工作状态。:(不:我指的是你的
    db.mytestdb.url=”mysql://user1:user1@127.0.0.1…”
    将其切换到
    db.mytestdb.url=”jdbc:mysql://localhost/mytestdb?characterEncoding=UTF-8“
    (url中没有凭据的jdbc)这样做了,但仍然不起作用。我记得在10.04上我用Sun JDK运行,在12.04上我打开了JDK。这有什么区别吗?