Skip to main content

Switching Among Databases

There are small changes using different databases.

Sample

Specify 'data_service' attribute in Model File root node

data_service="mysql"

Here is an example:

<root alias_model_name="artworkfeed"
cfg_mask_china_mobile="false"

english_name="artwork feed"
data_service="mysql"
name="artworkfeed" org="doublechaintech">

Dependencies changes

build.gradle

runtimeOnly 'com.mysql:mysql-connector-j'

or using Maven

<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>

Change datasource parameters

application.properties

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://${DB_HOST}:3306/${DB_NAME}?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC&characterEncoding=utf8
spring.datasource.username=${DB_USER}
spring.datasource.password=${DB_PASSWORD}

Let the selected Spring Boot release manage the Connector/J version unless the project compatibility baseline requires an explicit override. Record and test that override rather than copying an old driver version from documentation.

Set credentials through environment or secret management; do not commit them.