user3876446
user3876446

Reputation:

hibernate configuration for app engine

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
      }

Upvotes: 0

Views: 1893

Answers (1)

Peter Knego
Peter Knego

Reputation: 80330

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

Upvotes: 1

Related Questions