1

I am trying to generate codes from my mysql server 5.7.25 using Hibernate Tool in Eclipse, I already installed jboss plugin in the marketplace, but when I create a hibernate configuration I get 'Problems while reading database schema' when I view the tables. The crazy part is in my data source explorer I can easily connect to my mysql server.

My Mysql server is 5.7.25, driver is mysql-connector-java-5.1.47-bin.jar, hibernate version is 3.5 and I am using eclipse 2019-03

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.password">1234567890</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3307/db</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQL57Dialect</property>
    <property name="hibernate.default_schema">db</property>
    <property name="hbm2ddl.auto">update</property>
</session-factory>
</hibernate-configuration>

when I expand the Database option in my newly created Hibernate configuration, I experience the error below:

<Reading schema error: Getting database metadata>

see fullstack error

org.jboss.tools.hibernate.runtime.spi.HibernateException: Getting database metadata
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:139)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:107)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.readDatabaseSchema(LazyDatabaseSchemaWorkbenchAdapter.java:124)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.getChildren(LazyDatabaseSchemaWorkbenchAdapter.java:64)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:104)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:235)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3307/db
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.getConnection(AbstractMetaDataDialect.java:121)
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.getMetaData(AbstractMetaDataDialect.java:60)
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.caseForSearch(AbstractMetaDataDialect.java:163)
at org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect.getTables(JDBCMetaDataDialect.java:22)
at org.hibernate.cfg.reveng.JDBCReader.processTables(JDBCReader.java:476)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.tools.hibernate.runtime.common.Util.invokeMethod(Util.java:43)
at org.jboss.tools.hibernate.runtime.common.AbstractJDBCReaderFacade.readDatabaseSchema(AbstractJDBCReaderFacade.java:44)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:132)
... 7 more
Rico Sancho Abarro
  • 257
  • 2
  • 5
  • 12
  • Your dialect seems wrong. Should it not be `org.hibernate.dialect.MySQL57Dialect` – Osher Shuman Jun 24 '19 at 13:43
  • Also maybe try add to the config `true` to help you debug the issue – Osher Shuman Jun 24 '19 at 13:44
  • Thank you on pointing out my mistake with the dialect. Unfortunately, the error is still the same.. to make things clear, I will update my post and include the full stack error log – Rico Sancho Abarro Jun 24 '19 at 13:56
  • Did you change your MySQl default server port from 3306 to 3307? Based on your error though it seems like a driver issue. Either your driver is missing or maybe wrong versions? I am using `'mysql-connector-java', version: '5.1.44'` and `'hibernate-core', version: '5.2.12.Final'` – Osher Shuman Jun 24 '19 at 14:25
  • Yes you are corrent because I have 2 mysql servers installed in my machine.. 3306 for mysql 8 and 3307 for mysql 5.7 – Rico Sancho Abarro Jun 24 '19 at 14:29
  • I am using mysql-connector-java-5.1.47-bin.jar.. But this is only specified in the connection driver definition only.. And btw I am using the dependency spring-boot starter jpa.. Do I still need to specify the exact hibernate core version in my pom.xml even though I am using springboot jpa? – Rico Sancho Abarro Jun 24 '19 at 14:31
  • I haven't used spring boot so I cannot answer that. I specify my Hibernate core in gradle as well as the driver – Osher Shuman Jun 25 '19 at 05:56

1 Answers1

1

I was able to solve this issue by using version 4.3 in the hibernate configuration and hibernate code generation tool. Previously, I have used version 3.5 since 5.x has a pending bug in eclipse.

Rico Sancho Abarro
  • 257
  • 2
  • 5
  • 12