Error viewing tables of database with hibernate tools

Hi all,

i’m totally new to Hibernate and tried out some tutorials. Basically this worked fine, except reverse engineering with the hibernate tools. I set up a new Java project and created hibernate configuration file and console configuration. When i come to the point to view the tables of my database errors are thrown.
image

Since days i’m struggling with this error and could’nt find any solution.
The connection seems to work, as the availabe schemas/catalogs are shown. But what is confusing me, is why there seems to be no configured schema/catalog. Although i tried configuring them in my config file.
Also i expected my existing databases as schemas, not as catalogs. But i don’t know if this is relevant.
I would really appreciate some help!

I’m working with:
Eclipse Neon.3 Release (4.6.3)
JBoss Tools 4.4.4.Final
MySQL 8.0.11

<?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 name="">
  <property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property>
  <property name="hibernate.connection.password"></property>
  <property name="hibernate.connection.url">jdbc:mysql://localhost/?useUnicode=true&amp;useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC</property>
  <property name="hibernate.connection.username">root</property>
  <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
  <property name="hibernate.default_catalog">hiber</property>
 </session-factory>
</hibernate-configuration>

!ENTRY org.hibernate.eclipse.console 4 4 2018-05-07 19:12:22.007
!MESSAGE Problems while reading database schema
!SUBENTRY 1 org.hibernate.eclipse.console 4 150 2018-05-07 19:12:22.007
!MESSAGE org.jboss.tools.hibernate.runtime.spi.HibernateException: Could not get list of tables from database. Probably a JDBC driver problem. 
Configured schema:null
Configured catalog:null
Available schemas:
Available catalogs:
  hiber
  information_schema
  mysql
  performance_schema
  sys
  testscheme

!STACK 0
org.jboss.tools.hibernate.runtime.spi.HibernateException: Could not get list of tables from database. Probably a JDBC driver problem. 
Configured schema:null
Configured catalog:null
Available schemas:
Available catalogs:
  hiber
  information_schema
  mysql
  performance_schema
  sys
  testscheme

	at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:141)
	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:231)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'HAVING TABLE_TYPE IN ('TABLE','VIEW',null,null,null) ORDER BY TABLE_TYPE, TABLE_' at line 1
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:118)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:960)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1019)
	at com.mysql.cj.jdbc.DatabaseMetaDataUsingInfoSchema.executeMetadataQuery(DatabaseMetaDataUsingInfoSchema.java:62)
	at com.mysql.cj.jdbc.DatabaseMetaDataUsingInfoSchema.getTables(DatabaseMetaDataUsingInfoSchema.java:835)
	at org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect.getTables(JDBCMetaDataDialect.java:27)
	at org.hibernate.cfg.reveng.TableProcessor.processTables(TableProcessor.java:39)
	at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:58)
	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:32)
	at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:132)
	... 7 more
!SUBENTRY 2 org.hibernate.eclipse.console 4 150 2018-05-07 19:12:22.007
!MESSAGE org.jboss.tools.hibernate.runtime.spi.HibernateException: Could not get list of tables from database. Probably a JDBC driver problem. 
Configured schema:null
Configured catalog:null
Available schemas:
Available catalogs:
  hiber
  information_schema
  mysql
  performance_schema
  sys
  testscheme

!STACK 0
org.jboss.tools.hibernate.runtime.spi.HibernateException: Could not get list of tables from database. Probably a JDBC driver problem. 
Configured schema:null
Configured catalog:null
Available schemas:
Available catalogs:
  hiber
  information_schema
  mysql
  performance_schema
  sys
  testscheme

	at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:141)
	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:231)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'HAVING TABLE_TYPE IN ('TABLE','VIEW',null,null,null) ORDER BY TABLE_TYPE, TABLE_' at line 1
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:118)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:960)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1019)
	at com.mysql.cj.jdbc.DatabaseMetaDataUsingInfoSchema.executeMetadataQuery(DatabaseMetaDataUsingInfoSchema.java:62)
	at com.mysql.cj.jdbc.DatabaseMetaDataUsingInfoSchema.getTables(DatabaseMetaDataUsingInfoSchema.java:835)
	at org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect.getTables(JDBCMetaDataDialect.java:27)
	at org.hibernate.cfg.reveng.TableProcessor.processTables(TableProcessor.java:39)
	at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:58)
	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:32)
	at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:132)
	... 7 more
!SUBENTRY 2 org.hibernate.eclipse.console 4 150 2018-05-07 19:12:22.007
!MESSAGE java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'HAVING TABLE_TYPE IN ('TABLE','VIEW',null,null,null) ORDER BY TABLE_TYPE, TABLE_' at line 1
!STACK 0
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'HAVING TABLE_TYPE IN ('TABLE','VIEW',null,null,null) ORDER BY TABLE_TYPE, TABLE_' at line 1
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:118)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:960)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1019)
	at com.mysql.cj.jdbc.DatabaseMetaDataUsingInfoSchema.executeMetadataQuery(DatabaseMetaDataUsingInfoSchema.java:62)
	at com.mysql.cj.jdbc.DatabaseMetaDataUsingInfoSchema.getTables(DatabaseMetaDataUsingInfoSchema.java:835)
	at org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect.getTables(JDBCMetaDataDialect.java:27)
	at org.hibernate.cfg.reveng.TableProcessor.processTables(TableProcessor.java:39)
	at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:58)
	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:32)
	at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:132)
	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:231)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

org.hibernate.dialect.MySQLDialect is really old. Try with ``org.hibernate.dialect.MySQL57Dialect` and see if it works.

Also check the version of the MySQL server and make sure it’s supported by Hibernate Tools.

Thanks for your response Vlad.
I’m wondering why org.hibernate.dialect.MySQL57Dialect is not listed in the dropdown.
I just edited the configuration manually, but no changes.

Still i’m really confused about
Configured schema:null Configured catalog:null
in my stacktrace.

I had a look for some compatibility information, but could’nt find any. Maybe i try going back to Community Server 5.7.

Do you have any other hints?

Thanks in advance for your help!
Marc

Tried to downgrade to MySQL Community Server 5.7.22, and finally it works!
Really frustrating to lose so much time just by picking an incompatible version.

Thanks for you help!

1 Like

@Phone4 @vlad how I can check that MySQL server and hibernate tools are compatibles, please?

if your OS is linux base then you can mysqld --version
but if OS is window then you can start windows button and type mysql
it will show you like MYSQL 5.5 or MYSQL 8.0
and for me I have this problem too.I use spring boot 2.1.11.RELEASE
that mysql-connector-java version embed is 8.0.18.
I try

  1. I change mysql-connector-jave to Version 5.x.x

    mysql
    mysql-connector-java
    5.1.47

    2.I change my hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?> com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/authresource xxxxxxxxxxxx root org.hibernate.dialect.MySQL5InnoDBDialect

and something I not sure about database name may don’t have “-”

image

Thanks Lokesh, Its very helpful. I just came to know that, we can use hibernate to connect IM database like any other RDBMS by this tutorial.
I have a couple of questions here.
#1. Do we need to install HSql DB separetly? How ? (Some info links would be helpful :))
#2. If i want to use this HSQL data base(or any other IM db) for my Junits, Do i need to dump all my database objects and testdata into this database? Or any other way i can use existing DB as IM DB?