Ao final da aula 2 sobre o cadastro de produtos eu consegui fazer a conexao com o banco de dados por alguns instantes, mas após reiniciar o servidor, eu tive a exceção mostrada abaixo. Inicialmente eu tive o problema usando o MySQL 8.0, mas tambem tentei com o 5.6.e o 5.7 apresentando. omesmo problema.
Ainda, tentei adicionar as seguintes propriedades ao DriverManagerDataSource para ver se eu teria algum sucesso
Properties connectioProperties = new Properties();
connectioProperties.setProperty("maxActive","10");
connectioProperties.setProperty("maxIdle","5");
connectioProperties.setProperty("validationQuery","/* ping */");
connectioProperties.setProperty("timeBetweenEvictionRunsMillis","60000");
connectioProperties.setProperty("minEvictableIdleTimeMillis","60000");
dataSource.setConnectionProperties(connectioProperties);
E novamente nada. Passei um bom tempo pesquisando como poderia resolver o problema mas não consegui achar nada que desse algum resultado. Por favor, me ajudem; eu já não sei mais o que devo fazer.
25-Dec-2018 21:49:53.235 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log 1 Spring WebApplicationInitializers detected on classpath
25-Dec-2018 21:49:53.364 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Initializing Spring DispatcherServlet 'dispatcher'
25-Dec-2018 21:50:06.040 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in org.casadocodigo.loja.conf.JpaConfiguration: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745)
...
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:402)
... 61 more
Caused by: org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:115)
...
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...
Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2914)
at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:559)
... 102 more
25-Dec-2018 21:50:06.041 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.loadOnStartup Servlet [dispatcher] in web application [/casadocodigo_war_exploded] threw load() exception
java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2914)
...
25-Dec-2018 21:50:06.319 INFO [http-nio-8080-exec-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring DispatcherServlet 'dispatcher'