【问题标题】:hibernate configuration for app engine应用引擎的休眠配置
【发布时间】:2014-09-29 07:00:12
【问题描述】:

如何配置 hibernate.cfg.xml 以访问云 sql 以及本地 mysql 实例? 以下代码在 JDBC 中工作,我需要在 hibernate 中进行这样的配置。

if (SystemProperty.environment.value() ==
          SystemProperty.Environment.Value.Production) {
        // Load the class that provides the new "jdbc:google:mysql://" prefix.
        Class.forName("com.mysql.jdbc.GoogleDriver");
        url = "jdbc:google:mysql://your-project-id:your-instance-name/guestbook?user=root";
      } else {
        // Local MySQL instance to use during development.
        Class.forName("com.mysql.jdbc.Driver");
        url = "jdbc:mysql://127.0.0.1:3306/guestbook?user=root";

        // Alternatively, connect to a Google Cloud SQL instance using:
        // jdbc:mysql://ip-address-of-google-cloud-sql-instance:3306/guestbook?user=root
      }

【问题讨论】:

    标签: java mysql hibernate google-app-engine google-cloud-sql


    【解决方案1】:

    我建议您查看how to use JPA-based ORM libs with Cloud SQL 上的官方文档。

    【讨论】:

      猜你喜欢
      • 2011-09-18
      • 2012-10-31
      • 2010-11-08
      • 2015-07-28
      • 2016-05-06
      • 2018-10-21
      • 2012-11-19
      • 2011-01-05
      • 2010-12-26
      相关资源
      最近更新 更多