I'm currently developing a login and registration feature for my application, and I'm trying to connect to my MySQL database. However, I'm facing an issue where the application reports that the database is empty, even though I've confirmed that it contains dummy data.
Details:
Database Name: nutzer Table Name: users (not USERS) I've followed the necessary steps to set up the database connection and configured my JPA settings using Hibernate.
Error Message: [Tabelle "USERS" nicht gefunden (diese Datenbank ist leer)]
What I've Tried:
- Double-checked the table name and ensured it is defined as users.
- Verified that the database contains data using MySQL Workbench.
- Reviewed the JPA configuration for any potential issues.
Question: What could be causing the application to not recognize the existing data in the users table? Any suggestions on how to resolve this issue would be greatly appreciated!
package de.likeherotozero;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name = "users", schema = "nutzer")
public class EmissionsData {
@Id
private Long id;
private String country;
private double value;
// Getters and Setters
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public double getValue() {
return value;
}
public void setValue(double value) {
this.value = value;
}
}
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="my-persistence-unit">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>de.likeherotozero.User</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/nutzer"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="myCorrectPassword is here"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL8Dialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>
mysql -p -e "show tables from nutzer"
at the command line says what?mysql -p -e "select count(*) from nutzer.users"
Note also that unless you are logged in to that terminal as 'root' (I hope not) then you have a different user configured in JPA