Por favor, alguem pode me auxiliar. Já li e fiz todas as soluções que foram dadas para sanar o erro de Access denied, mas nada deu certo. Ao baixar o MariaDB, coloquei a porta 3309. O Maria DB esta em execução. Inseri o numero da porta correta no persistence, rodei no prompt de comando conforme aula e o erro continua.
ERRO: Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:833) at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:453) at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:38) ... 29 more
Persistence
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="contas">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>br.com.alura.jpa.modelo.Conta</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost: 3309/alura_jpa" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="pass" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>
Conta
package br.com.alura.jpa.modelo;
import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id;
@Entity public class Conta { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private Integer agencia; private Integer numero; private String titular; private Double saldo;
public Double getSaldo() {
return saldo;
}
public void setSaldo(Double saldo) {
this.saldo = saldo;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getAgencia() {
return agencia;
}
public void setAgencia(Integer agencia) {
this.agencia = agencia;
}
public Integer getNumero() {
return numero;
}
public void setNumero(Integer numero) {
this.numero = numero;
}
public String getTitular() {
return titular;
}
public void setTitular(String titular) {
this.titular = titular;
}
}
POM
<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 https://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.27.Final</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.23</version>
</dependency>
</dependencies>
</project>
TesteCriaTabelas
package br.com.alura.jpa.testes;
import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence;
public class TesteCriaTabelas {
public static void main(String[] args) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("contas");
EntityManager createEntityManager = emf.createEntityManager();
emf.close();
}
}