如何从 Hibernate 配置工具修复 'Problems while reading database schema'

How to fix 'Problems while reading database schema' from Hibernate Configuration tool

我正在尝试使用 Eclipse 中的 Hibernate 工具从我的 mysql 服务器 5.7.25 生成代码,我已经在市场上安装了 jboss 插件,但是当我创建一个休眠配置时,我得到'Problems while reading database schema' 当我查看表格时。疯狂的部分是在我的数据源浏览器中,我可以轻松连接到我的 mysql 服务器。

我的Mysql服务器是5.7.25,驱动是mysql-connector-java-5.1.47-bin.jar,休眠版本是3.5,我是使用日食 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>

当我在新创建的 Hibernate 配置中展开数据库选项时,遇到以下错误:

<Reading schema error: Getting database metadata>

查看全栈错误

org.jboss.tools.hibernate.runtime.spi.HibernateException: Getting database metadata
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.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.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.execute(LazyDatabaseSchemaWorkbenchAdapter.java:132)
... 7 more

我能够通过在休眠配置和休眠代码生成工具中使用 4.3 版来解决这个问题。以前,我使用的是 3.5 版,因为 5.x 在 eclipse 中有一个未决的错误。