• 首页
  • 产品中心
    • 数式Oinone四大产品

      低代码开发平台无代码开发平台集成开发平台AI大模型开发
    • 数式Oinone体系能力

      用户与组织权限管理文件管理消息中心国际化业务审计
    • 数式Oinone核心产品特性

      低无一体面向软件公司场景无限制应用级扩容可分可合
  • 服务中心
    • 客户服务

      预约演示方案咨询私有部署找人定制
    • 开发者

      问答下载
    • Oinone学院

      社区学习

    《精讲面向软件公司的低代码平台——以Oinone为例》

  • 合作伙伴
    渠道申请伙伴名录专家库
  • 关于数式
0571-88757863

Data Operation:Oinone External Data Source Connection Solution


Ⅰ、Scenario Description

In practical business scenarios, there is often a need to connect to external data sources for data acquisition. Common approaches include:

  1. Recommended: Use the platform's data connector to connect to external data sources for data operations.
  2. Connect to data sources in project code, i.e., operate external data source data through programming.

This article focuses on the approach of operating external data sources via programming.

Ⅱ、Overall Solution

  • Oinone manages external data sources by configuring them in yml.
  • The backend performs data operations (CRUD) through Mapper.
  • When calling Mapper interfaces, specify the external data source.

Ⅲ、Detailed Steps

(Ⅰ)Data Source Configuration (application.yml)

The configuration is similar to normal data sources:

out_ds_name(alias_for_external_ds):
  driverClassName: com.mysql.cj.jdbc.Driver
  type: com.alibaba.druid.pool.DruidDataSource
  # Local environment configuration
  url: jdbc:mysql://ip(host):port/database_schema?useSSL=false&allowPublicKeyRetrieval=true&useServerPrepStmts=true&cachePrepStmts=true&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&autoReconnect=true&allowMultiQueries=true
  username: username
  password: password
  initialSize: 5
  maxActive: 200
  minIdle: 5
  maxWait: 60000
  timeBetweenEvictionRunsMillis: 60000
  testWhileIdle: true
  testOnBorrow: false
  testOnReturn: false
  poolPreparedStatements: true
  asyncInit: true

(Ⅱ)Additional Configurations for External Data Sources

To restrict table structure creation for external data sources, configure:

persistence:
  global:
    auto-create-database: true
    auto-create-table: true
  ds:
    out_ds_name(alias_for_external_ds):
      # Disable database creation
      auto-create-database: false
      # Disable table creation
      auto-create-table: false

(Ⅲ)Backend Mapper Development

  • SQL Mapper follows the same syntax as native MyBatis/MyBatis-Plus with no special restrictions.
  • Mapper and SQL can be written in the same file or separated into two files.

(Ⅳ)Calling Mapper in Service/Action

  • The startup Application's @MapperScan must scan the corresponding package.
  • Invoke the Mapper like a normal bean, with the only difference being using DsHintApi to specify the data source:
@Autowired
private ScheduleItemMapper scheduleItemMapper;

public saveData(Object data) {
    ScheduleQuery scheduleQuery = new ScheduleQuery();
    //scheduleQuery.setActionName();
    try (DsHintApi dsHint = DsHintApi.use("external_ds_name")) {
        List<ScheduleItem> scheduleItems = scheduleItemMapper.selectListForSerial(scheduleQuery);
        // Business logic
    }
}
Edit this page
Last Updated:1/15/26, 4:02 AM
Prev
Data Operation:Usage of IWrapper, QueryWrapper, and LambdaQueryWrapper
Next
Data Operation:Database and Table Sharding with Custom Sharding Rules
默认页脚
Copyright © 2026 Mr.Hope