应用程序引擎的休眠配置 [英] hibernate configuration for app engine
本文介绍了应用程序引擎的休眠配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何配置hibernate.cfg.xml以访问云端sql以及本地mysql实例?
下面的代码在JDBC中工作,我在hibernate中需要这样的配置。
how to configure hibernate.cfg.xml for accessing cloud sql as well as local mysql instance? following code worked in JDBC,I need such a configuration in 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
}
推荐答案
您可以查看如何将基于JPA的ORM库与Cloud SQL 。
这篇关于应用程序引擎的休眠配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文