com.github.mengzuozhu:db-exchange-es

数据库分批读写交互模板

License

License

GroupId

GroupId

com.github.mengzuozhu
ArtifactId

ArtifactId

db-exchange-es
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

数据库分批读写交互模板

Download db-exchange-es

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.mengzuozhu/db-exchange-es/ -->
<dependency>
    <groupId>com.github.mengzuozhu</groupId>
    <artifactId>db-exchange-es</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.mengzuozhu/db-exchange-es/
implementation 'com.github.mengzuozhu:db-exchange-es:1.0.1'
// https://jarcasting.com/artifacts/com.github.mengzuozhu/db-exchange-es/
implementation ("com.github.mengzuozhu:db-exchange-es:1.0.1")
'com.github.mengzuozhu:db-exchange-es:jar:1.0.1'
<dependency org="com.github.mengzuozhu" name="db-exchange-es" rev="1.0.1">
  <artifact name="db-exchange-es" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.mengzuozhu', module='db-exchange-es', version='1.0.1')
)
libraryDependencies += "com.github.mengzuozhu" % "db-exchange-es" % "1.0.1"
[com.github.mengzuozhu/db-exchange-es "1.0.1"]

Dependencies

compile (7)

Group / Artifact Type Version
com.github.mengzuozhu : db-exchange-core jar 1.0.1
org.elasticsearch : elasticsearch jar 7.9.2
org.elasticsearch.client : elasticsearch-rest-high-level-client jar 7.9.2
org.mockito : mockito-junit-jupiter jar 3.7.7
org.apache.commons : commons-lang3 jar 3.11
com.google.guava : guava jar 30.0-jre
org.projectlombok : lombok jar 1.18.12

test (2)

Group / Artifact Type Version
org.mockito : mockito-inline jar 3.7.7
org.junit.jupiter : junit-jupiter jar 5.7.0

Project Modules

There are no modules declared in this project.

db-exchange

Maven Central

数据库分批读写交互模板

功能

  • 封装数据分批流式读写模板
  • 封装mysql, es和mongo数据库的读写模板

模块

  • db-exchange-core:核心读写交互模板
  • db-exchange-mysql:封装mysql数据库读写
  • db-exchange-es:封装es数据库读写
  • db-exchange-mongo:封装mongo数据库读写
  • db-exchange-spring-jdbc:封装Spring JDBC读写

快速开始

  1. 添加db-exchange-mysql Maven引用

            <dependency>
                <groupId>com.github.mengzuozhu</groupId>
                <artifactId>db-exchange-mysql</artifactId>
                <version>1.0.1</version>
            </dependency>
  2. mysql读取示例

    public class ExchangeDemo {
    
        public static void main(String[] args) {
            String url = "jdbc:mysql://localhost:3306/test?characterEncoding=utf8&serverTimezone=Asia/Shanghai";
            DataSource dataSource = MysqlUtil.getDataSource(url, "root", "your mysql password");
            MysqlQuery query = MysqlQuery.builder()
                    .dataSource(dataSource)
                    .sql("SELECT * FROM user")
                    .batchSize(100)
                    .build();
            DataReader<Map<String, Object>> mysqlDataReader = new MysqlDataReader<>(query, new ResultSetToMap());
            ListDataCollector<Map<String, Object>> listDataCollector = new ListDataCollector<>();
            ExchangeTemplate.from(mysqlDataReader)
                    .execute(listDataCollector)
                    .await();
            // do something
            List<Map<String, Object>> result = listDataCollector.getResult();
        }
    }

Versions

Version
1.0.1