Mysql and postgresql switch

Overview

Apache Griffin uses EclipseLink as the default JPA implementation, which supports two kinds of database, mysql and postgresql. This document mainly describes the steps of how to switch mysql and postgresql as backend database.

Mysql database

Add mysql dependency

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>

Configure properties

  • configure application.properties

      spring.datasource.url = jdbc:mysql://localhost:3306/quartz?autoReconnect=true&useSSL=false
      spring.datasource.username = griffin
      spring.datasource.password = 123456
      spring.jpa.generate-ddl=true
      spring.datasource.driver-class-name = com.mysql.jdbc.Driver
      spring.jpa.show-sql = true
    

    If you use hibernate as your jpa implentation, you need also to add following configuration.

      spring.jpa.hibernate.ddl-auto = update
      spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
    
  • configure quartz.properties

    org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
    

Postgresql database

Add postgresql dependency

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
</dependency>

Configure properties

  • configure application.properties

      spring.datasource.url = jdbc:postgresql://localhost:5432/quartz?autoReconnect=true&useSSL=false
      spring.datasource.username = griffin
      spring.datasource.password = 123456
      spring.jpa.generate-ddl=true
      spring.datasource.driver-class-name = org.postgresql.Driver
      spring.jpa.show-sql = true
    

    If you use hibernate as your jpa implentation, you need also to add following configuration.

      spring.jpa.hibernate.ddl-auto = update
      spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
    
  • configure quartz.properties

    org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate