Question

I am trying to connect Hibernate from my local to a remote MySQL database.

Error message:

WARN : org.hibernate.engine.jdbc.internal.JdbcServicesImpl - HHH000342: Could not
obtain connection to query metadata : Access denied for user 'root'@'<ip>' (using 
password: YES)
ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate - HHH000319: Could not get database 
metadata

hibernate.cfg.xml

    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="connection.url">jdbc:mysql://vm-name-001:3306/dbname</property>
    <property name="connection.username">root</property>
    <property name="connection.password">password</property>

pom.xml

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate-version}</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.29</version>
    </dependency>

In the remote MySQL DB, I issued show grants for 'root'@'%'; and received:

...
| GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, EXECUTE ON `dbname`.* TO
 'root'@'%'
| GRANT ALL PRIVILEGES ON `dbname`.* TO 'root'@'%'
...

If I log into a different VM than the remote MySQL db, I can issue mysql -u root -h vm-name-001 -p and log into it.

My teamate is also saying that he can connect fine using Hibernate, although he is using a Tomcat server.

Edit- My teammate can also connect using a regular java application, outside of Tomcat.

What did I miss?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top