2

I am trying to connect to my database from google cloud sql using hibernate, but I get the following error...

Caused by: java.lang.ClassNotFoundException: Could not load requested class : com.mysql.jdbc.GoogleDriver

but I have the dependency in the pom.xml

<dependency>
     <groupId>mysql</groupId>
     <artifactId>mysql-connector-java</artifactId>
     <version>5.1.38</version>
</dependency>

I call createEntityManagerFactory this way...

    Map<String, String> properties = new HashMap<>();

    properties.put("javax.persistence.jdbc.driver",
            "com.mysql.jdbc.GoogleDriver");
    properties.put("javax.persistence.jdbc.url",
            System.getProperty("cloudsql.url"));

    EntityManagerFactory emf = Persistence.createEntityManagerFactory(
            "Test", properties);

Could someone help me? Thanks

1 Answer 1

1

You need to put following into appengine-web.xml:

<use-google-connector-j>true</use-google-connector-j>
Sign up to request clarification or add additional context in comments.

2 Comments

make sure it's declared on deployed version too
I resolved by changing the version of hibernate. Now I am using 4.2.0.Final and it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.