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

eu não consigo conectar no banco MySQL 8, alguem poderia me ajudar?

Estou acompanhando as aulas e até adiantei as aulas pra baixar o projeto completo do professor, mas mesmo assim esta dando erro e eu não consigo cadastrar produtos no banco, acredito que seja porque no MySQL 8, não pode deixar a senha do root em branco e emsmo utiizando a senha cadastrada a aplicação não está conectando com o banco e da erro, alguem poderia me ajudar?

esse é o erro que da no console:

GRAVE: Servlet.service() for servlet [dispatcher] in context with path [/casadocodigo] threw exception [Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection] with root cause com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client

3 respostas

esse é o que da na pagina: Type Exception Report

Message Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863) javax.servlet.http.HttpServlet.service(HttpServlet.java:660) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) Root Cause

org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:430) org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)

solução!

Oi Fellipe,

Para usar o MySQL 8 você precisa alterar a versão da dependência no pom.xml:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.20</version>
</dependency>

E alterar a String de conexão com o banco na classe JPAConfiguration:

dataSource.setUrl("jdbc:mysql://localhost:3306/casadocodigo?serverTimezone=UTC&useSSL=false");

Veja se com isso para de dar o erro.

Deu certo, muito obrigado Rodrigo