Code Monkey home page Code Monkey logo

db-exchange's Introduction

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();
        }
    }

db-exchange's People

Contributors

mengzuozhu avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

juneburning

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.