0

Hello everybody I am trying to connect my Spring boot App with Mysql but unfortunately it does not work. application.properties file:

spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=root
spring.datasource.password=*********
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.tomcat.max-active=1

# ===============================
# = JPA / HIBERNATE
# ===============================

# Use spring.jpa.properties.* for Hibernate native properties (the prefix is
# stripped before adding them to the entity manager).

# Show or not log for each sql query
spring.jpa.show-sql = true

# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
spring.jpa.hibernate.ddl-auto = update

# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

The errors that I am getting are the following:

2018-07-06 18:32:10.832  WARN 7180 --- [           main] o.a.tomcat.jdbc.pool.ConnectionPool      : maxIdle is larger than maxActive, setting maxIdle to: 1
Fri Jul 06 18:32:10 CEST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2018-07-06 18:32:11.093 ERROR 7180 --- [           main] o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.
java.sql.SQLException: Unknown system variable 'query_cache_size'
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) ~[mysql-connector-java-5.1.41.jar:5.1.41]
    at com.auth0.samples.bootfaces.Application.main(Application.java:21) [classes/:na]
2018-07-06 18:32:11.109  WARN 7180 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Unable to obtain Jdbc connection from DataSource
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-07-06 18:32:11.176 ERROR 7180 --- [           main] o.s.boot.SpringApplication               : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Unable to obtain Jdbc connection from DataSource
Caused by: org.flywaydb.core.api.FlywayException: Unable to obtain Jdbc connection from DataSource
    at org.flywaydb.core.internal.util.jdbc.JdbcUtils.openConnection(JdbcUtils.java:56) ~[flyway-core-3.2.1.jar:na]
pport.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    ... 18 common frames omitted
Caused by: java.sql.SQLException: Unknown system variable 'query_cache_size'
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) ~[mysql-connector-java-5.1.41.jar:5.1.41]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) ~[mysql-connector-java-5.1.41.jar:5.1.41]
Patrahi
  • 3
  • 1
  • 4
  • 1
    https://stackoverflow.com/questions/49984267/java-sql-sqlexception-unknown-system-variable-query-cache-size/49984380 – Anton N Jul 06 '18 at 17:36
  • It looks like an incompatibility between the client JDBC driver and the MySQL server. What version of MySQL server are you connecting to? What version of the `com.mysql.jdbc.Driver` are you using? If the server and client driver are compatible, then the last thing I would check is that this may be as simple as removing `spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect` from your properties although that is just speculation... – kevdoran Jul 06 '18 at 21:40
  • The version of MySQL server is 8.0.11. I deleted the spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect But still does not work in the POM file I did not mention version. This is what I have: mysql mysql-connector-java – Patrahi Jul 07 '18 at 07:06
  • Solved the answer is: query_cache_size was removed in MySQL 8. It works with JDBC driver 5.1.44. – Patrahi Jul 07 '18 at 07:20

0 Answers0