spring boot jpa mysql example
Example 1: spring application properties mysql jpa
spring.datasource.url=jdbc:mysql://localhost:yourDatabase?serverTimezone=UTC
spring.datasource.username=${USERNAME}
spring.datasource.password=${PASSWORD}
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.logging.level.org.hibernate.SQL=debug
spring.jpa.show-sql=true
Example 2: mysql driver spring jpa application.properties
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/db_example
spring.datasource.username=springuser
spring.datasource.password=ThePasswordCopy
Example 3: jpql spring boot
@Query("SELECT u FROM User u WHERE u.status = :status and u.name = :name")User findUserByStatusAndNameNamedParams( @Param("status") Integer status, @Param("name") String name);