Search code examples
javamysqlhibernatemavenxampp

Hibernate: "Reading schema error: Error while reading column meta data for mysql.user


PROBLEM

Hello everyone. I'm trying to do reverse engineering on my Maven project using Hibernate. But it keeps giving me this error message:

Reading schema error: Error while reading column meta data for mysql.user

Error message

Project Details

Project structure

Pom:

  <dependencies>
      
    <!-- https://mvnrepository.com/artifact/com.mysql/mysql-connector-j -->
    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
        <version>8.0.33</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core -->
    <dependency>
        <groupId>org.hibernate.orm</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>6.2.3.Final</version>
    </dependency>

  </dependencies>
</project>

Hibernate.cfg.xml:

<hibernate-configuration>
 <session-factory name="Conection">
  <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/busstation</property>
  <property name="hibernate.connection.username">root</property>
  <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
 </session-factory>
</hibernate-configuration>

Console configuration: Bus Station CC

MYSQL Database Script:

DROP DATABASE IF EXISTS BusStation;
CREATE DATABASE IF NOT EXISTS BusStation;
USE BusStation;

CREATE TABLE IF NOT EXISTS Bus(
    n INT PRIMARY KEY AUTO_INCREMENT,
    sits INT NOT NULL,
    plate CHAR(5) NULL
);

INSERT INTO Bus (sits, plate) VALUES(24, 'AAAAA');
INSERT INTO Bus (sits, plate) VALUES(28, 'AAAAB');
INSERT INTO Bus (sits, plate) VALUES(12, 'AAAAC');
INSERT INTO Bus (sits, plate) VALUES(48, 'AAAAD');

Thank you for your time.

I tried

  1. Changing the username or adding an incorrect password to see if it's just not letting it in. But it says Different Error, so I discarded it.
  2. Switching versions of the JDK from 17 to 1.4(jdk17) and such, same error.
  3. Switching the database to the default "test", same error.
  4. Switching versions of the "com.mysql" dependency, same error.

Solution

  • The Hibernate.cfg.xml lacked some necessary properties. It's fixed now.