I am new to JPA and Springboot. I checked and tried solutions from several posts here, however, could not really solve my issue.
When I try to use JPA to connect with my mysql database, it throws Unknown Database 'springsecurity'. I verified my username and password for the db.
I am using mysqlworkbench as rdbms.
application.properties :
spring.datasource.url=jdbc:mysql://localhost:3306/springsecuritysystem
spring.datasource.username=root
spring.datasource.password=password
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
Error thrown :
2021-11-11 23:39:21.993 WARN 72026 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1049, SQLState: 42000
2021-11-11 23:39:21.993 ERROR 72026 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : Unknown database 'springsecuritysystem'
2021-11-11 23:39:21.999 ERROR 72026 --- [ main] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.SQLGrammarException: Unable to open JDBC Connection for DDL execution
2021-11-11 23:39:22.000 WARN 72026 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.SQLGrammarException: Unable to open JDBC Connection for DDL execution
2021-11-11 23:39:22.001 INFO 72026 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
Tutorial followed : https://github.com/koushikkothagal/spring-security-jpa