【发布时间】: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