Odpaliłem Springowy przykład - projekt "PetClinic". Działa (z poziomu Intellij IDEA) - wszystko OK, do czasu gdy próbuje użyć MySQL zamiast bazy H2 (projekt dopuszcza obie).
Otrzymuję błąd (wyświetlany na stronie):
could not prepare statement; SQL [select distinct owner0_.id as id1_0_0_, pets1_.id as id1_1_1_, owner0_.first_name as first_na2_0_0_, owner0_.last_name as last_nam3_0_0_, owner0_.address as address4_0_0_, owner0_.city as city5_0_0_, owner0_.telephone as telephon6_0_0_, pets1_.name as name2_1_1_, pets1_.birth_date as birth_da3_1_1_, pets1_.owner_id as owner_id4_1_1_, pets1_.type_id as type_id5_1_1_, pets1_.owner_id as owner_id4_1_0__, pets1_.id as id1_1_0__ from owners owner0_ left outer join pets pets1_ on owner0_.id=pets1_.owner_id where owner0_.last_name like ?]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement
Bład w oknie IDE Intellij IDEA:
2019-10-08 00:03:52.197 WARN 1168 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: -5501, SQLState: 42501
2019-10-08 00:03:52.197 ERROR 1168 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : user lacks privilege or object not found: OWNERS in statement [select distinct owner0_.id as id1_0_0_, pets1_.id as id1_1_1_, owner0_.first_name as first_na2_0_0_, owner0_.last_name as last_nam3_0_0_, owner0_.address as address4_0_0_, owner0_.city as city5_0_0_, owner0_.telephone as telephon6_0_0_, pets1_.name as name2_1_1_, pets1_.birth_date as birth_da3_1_1_, pets1_.owner_id as owner_id4_1_1_, pets1_.type_id as type_id5_1_1_, pets1_.owner_id as owner_id4_1_0__, pets1_.id as id1_1_0__ from owners owner0_ left outer join pets pets1_ on owner0_.id=pets1_.owner_id where owner0_.last_name like ?]
2019-10-08 00:03:52.197 ERROR 1168 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not prepare statement; SQL [select distinct owner0_.id as id1_0_0_, pets1_.id as id1_1_1_, owner0_.first_name as first_na2_0_0_, owner0_.last_name as last_nam3_0_0_, owner0_.address as address4_0_0_, owner0_.city as city5_0_0_, owner0_.telephone as telephon6_0_0_, pets1_.name as name2_1_1_, pets1_.birth_date as birth_da3_1_1_, pets1_.owner_id as owner_id4_1_1_, pets1_.type_id as type_id5_1_1_, pets1_.owner_id as owner_id4_1_0__, pets1_.id as id1_1_0__ from owners owner0_ left outer join pets pets1_ on owner0_.id=pets1_.owner_id where owner0_.last_name like ?]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement] with root cause
Mój plik konfiguracyjny (application.properties):
# database init, supports mysql too
database=mysql
#spring.datasource.schema=classpath*:db/${database}/schema.sql
#spring.datasource.data=classpath*:db/${database}/data.sql
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/petclinic
jdbc.username=root
jdbc.password=*****************
init-db=false
# Web
spring.thymeleaf.mode=HTML
# JPA
spring.jpa.hibernate.ddl-auto=none
spring.jpa.open-in-view=true
# Hibernate will bootstrap in a separate thread while the rest of your application’s startup processing proceeds in parallel
spring.data.jpa.repositories.bootstrap-mode=deferred
# Internationalization
spring.messages.basename=messages/messages
# Actuator / Management
management.endpoints.web.base-path=/manage
management.endpoints.web.exposure.include=*
# Logging
logging.level.org.springframework=INFO
# logging.level.org.springframework.web=DEBUG
# logging.level.org.springframework.context.annotation=TRACE
# Maximum time static resources should be cached
spring.resources.cache.cachecontrol.max-age=12h
Strona projektu: https://spring-petclinic.github.io/