Code Monkey home page Code Monkey logo

jdbd-mysql's Introduction

Reactive Relational Database Driver MySQL Implementation

Sonatype Nexus (Snapshots) Maven Central Apache 2.0 Java support

This project contains the MySQL client protocol implementation of the JDBD SPI. This implementation is not intended to be used directly, but rather to be used as the backing implementation for a humane client library to delegate to.

How to run jdbd-mysql test use cases ?

  1. CREATE DATABASE army_test DEFAULT CHARACTER SET utf8mb4 ;
  2. CREATE USER army_w@'localhost' IDENTIFIED BY 'army123' ;
  3. GRANT ALL ON army_test.* TO army_w@'localhost' ;
  4. GRANT XA_RECOVER_ADMIN ON *.* TO army_w@'localhost';
  5. If meets MySQL 8.0.26 ,then INSTALL COMPONENT "file://component_query_attributes" ;
  6. mvn test

the persistence frameworks that use jdbd-spi :

  1. Army

more jdbd-spi document see jdbd

How to start ?

Maven

<dependency>
    <groupId>io.jdbd.mysql</groupId>
    <artifactId>jdbd-mysql</artifactId>
    <version>0.11.9</version><!-- jdbd-mysql maven version-->
</dependency>

Java code

@see io/jdbd/mysql/simple/HowToStartTests.java ,java class url

How to use native transport ?

maven

<dependencies>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-transport-native-kqueue</artifactId>
        <version>4.1.96.Final</version>
        <classifier>osx-x86_64</classifier>  <!-- here,just for mac os  -->
    </dependency>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-transport-native-unix-common</artifactId>
        <version>4.1.96.Final</version>
        <classifier>osx-x86_64</classifier>   <!-- here,just for mac os  -->
    </dependency>
</dependencies>

How to use unix domain socket ?

public class UnixDomainSocketTests {
    @Test
    public void unixDomainSocket() throws Exception {
        //  select @@Global.socket;  // default is  /tmp/mysql.sock
        final String mysqlSocketPath = "/tmp/mysql.sock";
        final String hostAddress = URLEncoder.encode(mysqlSocketPath, "utf-8");
        // hostAddress result is  /%2Ftmp%2Fmysql.sock
        final String url = "jdbd:mysql://%2Ftmp%2Fmysql.sock/army_test";

        final Map<String, Object> map = new HashMap<>();
        map.put(Driver.USER, "army_w");
        map.put(Driver.PASSWORD, "army123");
        // properties will override the properties of url.
        final DatabaseSessionFactory domainSocketSessionFactory;
        domainSocketSessionFactory = Driver.findDriver(url).forDeveloper(url, map);

        final ResultRow row;
        row = Mono.from(domainSocketSessionFactory.localSession())
                .flatMapMany(session -> Flux.from(session.executeQuery("SELECT current_timestamp AS now")))
                .blockLast();

        Assert.assertNotNull(row);
        Assert.assertNotNull(row.get(0, LocalDateTime.class));

    }
}

Properties config

@see io.jdbd.mysql.env.MySQLKey class

Core properties

name default description
factoryName unnamed DatabaseSessionFactory name
factoryTaskQueueSize 18 The task queue size of each session.
factoryWorkerCount 30 session factory netty worker count.
factorySelectCount same with factoryWorkerCount session factory netty select count if use java NIO,if native ignore.
connectionProvider ConnectionProvider::newConnection reactor netty ConnectionProvider
shutdownQuietPeriod 2 * 1000 milliseconds DatabaseSessionFactory's EventLoopGroup after n milliseconds shutdown, if you invoke DatabaseSessionFactory.close()
shutdownTimeout 15 * 1000 milliseconds DatabaseSessionFactory's EventLoopGroup shutdown timeout milliseconds,if you invoke DatabaseSessionFactory.close()
tcpKeepAlive false
tcpNoDelay true
connectTimeout 0 session connect timeout
sslMode PREFERRED ssl mode

more jdbd-spi document see jdbd

jdbd-mysql's People

Contributors

qinarmy-zoro avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

erkankesik

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.