简体   繁体   English

配置Grails应用程序以在Heroku上使用ClearDB / MySQL

[英]Configuring Grails application to use ClearDB/MySQL on Heroku

I have a Grails (2.0.0) application and have successfully: 我有一个Grails(2.0.0)应用程序并成功完成了:

  1. Deployed it to Heroku using the H2 database 使用H2数据库将其部署到Heroku
  2. Configured it to use a local MySQL database 配置它以使用本地MySQL数据库
  3. Added the ClearDB addon 添加了ClearDB插件

However, I get a HTTP 503 error when I try to run the application while attempting to use the ClearDB instance. 但是,在尝试使用ClearDB实例时尝试运行应用程序时,出现HTTP 503错误。

Here are snippets from DataSource.groovy (a combination of tricks from various posts, including this tutorial from ClearDB and this help page from Heroku ) 以下是DataSource.groovy的摘录(各种文章的技巧的结合,包括ClearDB的教程Heroku的帮助页面

dataSource {
  pooled = true
  driverClassName = "com.mysql.jdbc.Driver"
}

... ...

production {        
  dataSource {
    dbCreate = "update"
      uri = new URI(System.env.DATABASE_URL?:"mysql://99784530f103:934c2a0@server.cleardb.com/heroku_0ac7f6f45fa34")
      url = "jdbc:mysql://"+uri.host+uri.path
      username = uri.userInfo.split(":")[0]
      password = uri.userInfo.split(":")[1]
    }
}

where the MySQL URL string comes from the DATABASE_URL environment variable. MySQL URL字符串来自DATABASE_URL环境变量。

Any advice? 有什么建议吗?

Figures... Soon after I post the question, I figured it out. 数字...发布问题后不久,我就知道了。 Change "DATABASE_URL" to "CLEARDB_DATABASE_URL_A". 将“ DATABASE_URL”更改为“ CLEARDB_DATABASE_URL_A”。 At least this is now an official Grails2.0/Heroku/ClearDB answer! 至少现在这是Grails2.0 / Heroku / ClearDB的正式答案!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM