Spring boot2框架适配国产达梦8数据库、国产瀚高数据库

最近项目涉及国产芯片、国产操作系统、国产数据库,总之全套国产化,选型用统信产品序列。就涉及开发框架适配国产数据库的问题:

1、spring boot2框架适配国产达梦8数据库或者瀚高数据库

pom.xml引入dm8的依赖:

java 复制代码
 <!--  达梦数据库驱动  -->
        <dependency>
            <groupId>com.dameng</groupId>
            <artifactId>DmJdbcDriver18</artifactId>
            <version>8.1.2.141</version>
        </dependency>
java 复制代码
  <!--  瀚高数据库驱动  -->
        <!-- https://mvnrepository.com/artifact/com.highgo/HgdbJdbc -->
        <dependency>
            <groupId>com.highgo</groupId>
            <artifactId>HgdbJdbc</artifactId>
            <version>6.2.4</version>
        </dependency>

2、application-dev.yml配置 druid数据源

java 复制代码
# 数据源
spring:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
#      driver-class-name: com.mysql.cj.jdbc.Driver
#      username: ${MYSQL_USER:root}
#      password: ${MYSQL_PWD:root}
#      url: jdbc:mysql://${MYSQL_HOST:pigx-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pigx_json_flow}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true
#      validation-query: SELECT 1
#      driver-class-name: dm.jdbc.driver.DmDriver
#      username: SYSDBA
#      password: C##qlywadmin2023
#      url: jdbc:dm://127.0.0.1:5236?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
      driver-class-name: com.highgo.jdbc.Driver
      username: highgo
      password: Password@123
      url: jdbc:highgo://localhost:5866/highgo
      validation-query: SELECT 1
      time-between-eviction-runs-millis: 18800
      stat-view-servlet:
        enabled: true
        allow: ""
        url-pattern: /druid/*
      filter:
        stat:
          enabled: true
          log-slow-sql: true
          slow-sql-millis: 10000
          merge-sql: false
      test-while-idle: true
  #        wall:
#          config:
#            multi-statement-allow: true

3、mybatis适配

需要注意的是mysql数据库里的name、level、type等关键字在mapper.xml里是带单引号的,到达梦8或者瀚高数据库里时要去掉。另外瀚高数据库的模糊查询需要用 ::text指明字段类型,否则会报错;按id查询返回一条记录时要用 resultType 指明实体类型,否则回报返回多条错误。

java 复制代码
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultType="com.xh.lesson.entity.SysDept">
    select 
    <include refid="Base_Column_List" />
    from COMPANY_FRAME.sys_dept
    where id = #{id,jdbcType=VARCHAR}
  </select>
java 复制代码
  <update id="updateRelationCode">
    UPDATE COMPANY_FRAME.sys_dept
    set relation_code=replace(relation_code,#{oldStr}::text,#{newStr}::text)
    where relation_code LIKE CONCAT(#{relationCode}::text,'%')
  </update>

注意了以上3点,基本就避坑了,好了,更新完毕,欢迎一键三连,关注我的微信号 获取更多资讯~

相关推荐
wifi___1 小时前
SpringBoot自动装配原理
java·spring boot·后端
Small-Young1 小时前
数据库乐观锁深度解析:MySQL、PostgreSQL 实战 + Spring Boot 集成指南
数据库·spring boot·mysql·postgresql·乐观锁·并发控制
瀚高PG实验室2 小时前
瀚高数据库运行日志(错误日志)查看与分析方法
数据库·postgresql·瀚高数据库
她的男孩2 小时前
租户 A 的验证码,却用了租户 B 的 AccessKey:Forge Admin 修跨租户短信串发
java·spring boot·saas
小蒜学长3 小时前
基于SpringBoot+Vue的云南地区扶贫助农系统的设计与实现(代码+数据库+LW)
java·vue.js·spring boot·后端·乡村振兴
瀚高PG实验室3 小时前
HGHAC集群版本升级
数据库·postgresql·瀚高数据库
RuoyiOffice3 小时前
Hyper-V+Kubernetes 搭建实战:保留 Windows,构建三节点 Linux 容器集群
linux·spring boot·kubernetes·containerd·hyper-v·微服务部署·ruoyi office
骑着蜗牛撵大象3273 小时前
Spring Boot 4.1 + Spring AI 2.0:RAG 供文、图谱供关系、MCP 供工具的 Java Agent 平台
java·spring boot·spring·微服务·知识图谱·rag·mcp
java_nnnn3 小时前
Spring Boot 配置文件详解:从基础语法到 YAML 配置
spring boot·后端·github
CoderYanger3 小时前
Java EE 进阶:6.SpringBoot 配置文件(第二弹)
java·spring boot·spring·面试·职场和发展·java-ee·程序员创富