hibernate configuration for app engine

巧了我就是萌 提交于 2019-12-12 03:01:11

问题


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
      }

回答1:


I suggest you check out the official docs on how to use JPA-based ORM libs with Cloud SQL.



来源:https://stackoverflow.com/questions/25158746/hibernate-configuration-for-app-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!