Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Erro de execução CriaTabelaConta

Recebo esse erro ao executar a classe CriaTabelaConta

mai 28, 2020 4:28:03 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
INFO: HHH000204: Processing PersistenceUnitInfo [name: alura]
mai 28, 2020 4:28:03 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.4.10.Final}
mai 28, 2020 4:28:03 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
mai 28, 2020 4:28:03 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
mai 28, 2020 4:28:03 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001005: using driver [com.mysql.cj.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/alura_jpa?useTimezone=true&serverTimezone=UTC]
mai 28, 2020 4:28:03 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001001: Connection properties: {password=****, user=root}
mai 28, 2020 4:28:03 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001003: Autocommit mode: false
mai 28, 2020 4:28:03 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init>
INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
mai 28, 2020 4:28:04 PM org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator initiateService
WARN: HHH000342: Could not obtain connection to query metadata : null
mai 28, 2020 4:28:04 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
mai 28, 2020 4:28:04 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 1698, SQLState: 28000
mai 28, 2020 4:28:04 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: Access denied for user 'root'@'localhost'

cópia dos arquivos

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
    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">
    <persistence-unit name="alura">
        <class>br.com.alura.jpa.modelo.Conta</class>
        <properties>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/alura_jpa?useTimezone=true&amp;serverTimezone=UTC" />
            <property name="javax.persistence.jdbc.user" value="root" />
            <property name="javax.persistence.jdbc.password" value="" />

            <property name="hibernate.hbm2ddl.auto" value="update"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
            <property name="hibernate.show_sql" value="false"/>
            <property name="hibernate.format_sql" value="true"/>
        </properties>
    </persistence-unit>
</persistence>

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>br.com.alura.jpa</groupId>
    <artifactId>projeto-jpa</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-agroal</artifactId>
            <version>5.4.10.Final</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.18</version>
        </dependency>

    </dependencies>
</project>
2 respostas
solução!

Opa Marco, tudo bem?

Então esse erro são da suas credencias de acesso ao banco, tem que confirmar quais são seu usuario e senha e ai é só alterar no persistence.xml:

<property name="javax.persistence.jdbc.user" value="seu_user" />
<property name="javax.persistence.jdbc.password" value="sua_senha" />

Caso você não consiga, pode mandar aqui mesmo que eu te ajudo!

Oi, Gabriel, obrigado pela ajuda.

Como eu não sabia como confirmar esses dados acabei alterando a senha através do terminal usando:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

Coloquei uma senha qualquer, alterei a senha no persistence.xml e funcionou