Reactive Relational Database Driver MySQL Implementation

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 ?
- CREATE DATABASE army_test DEFAULT CHARACTER SET utf8mb4 ;
- CREATE USER army_w@’localhost’ IDENTIFIED BY ‘army123’ ;
- GRANT ALL ON army_test.* TO army_w@’localhost’ ;
- GRANT XA_RECOVER_ADMIN ON *.* TO army_w@’localhost’;
- If meets MySQL 8.0.26 ,then INSTALL COMPONENT “file://component_query_attributes” ;
- mvn test
the persistence frameworks that use jdbd-spi :
- 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
Reactive Relational Database Driver MySQL Implementation
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 ?
the persistence frameworks that use jdbd-spi :
more jdbd-spi document see jdbd
How to start ?
Maven
Java code
@see io/jdbd/mysql/simple/HowToStartTests.java ,java class url
How to use native transport ?
maven
How to use unix domain socket ?
Properties config
@see io.jdbd.mysql.env.MySQLKey class
Core properties
more jdbd-spi document see jdbd