@@ -103,116 +103,14 @@ See [Getting Started](https://github.com/asyncer-io/r2dbc-mysql/wiki/getting-sta
103103
104104See [ r2dbc-pool] ( https://github.com/r2dbc/r2dbc-pool ) .
105105
106- ### Simple statement
106+ ### Usage
107107
108108``` java
109109connection. createStatement(" INSERT INTO `person` (`first_name`, `last_name`) VALUES ('who', 'how')" )
110110 .execute(); // return a Publisher include one Result
111111```
112112
113- ### Parametrized statement
114-
115- ``` java
116- connection. createStatement(" INSERT INTO `person` (`birth`, `nickname`, `show_name`) VALUES (?, ?name, ?name)" )
117- .bind(0 , LocalDateTime . of(2019 , 6 , 25 , 12 , 12 , 12 ))
118- .bind(" name" , " Some one" ) // Not one-to-one binding, call twice of native index-bindings, or call once of name-bindings.
119- .add()
120- .bind(0 , LocalDateTime . of(2009 , 6 , 25 , 12 , 12 , 12 ))
121- .bind(1 , " My Nickname" )
122- .bind(2 , " Naming show" )
123- .returnGeneratedValues(" generated_id" )
124- .execute(); // return a Publisher include two Results.
125- ```
126-
127- - All parameters must be bound before execute, even parameter is ` null ` (use ` bindNull ` to bind ` null ` ).
128- - It will be using client-preparing by default, see ` useServerPrepareStatement ` in configuration.
129- - In one-to-one binding, because native MySQL prepared statements use index-based parameters, * index-bindings* will have ** better** performance than * name-bindings* .
130-
131- ### Batch statement
132-
133- ``` java
134- connection. createBatch()
135- .add(" INSERT INTO `person` (`first_name`, `last_name`) VALUES ('who', 'how')" )
136- .add(" UPDATE `earth` SET `count` = `count` + 1 WHERE `id` = 'human'" )
137- .execute(); // return a Publisher include two Results.
138- ```
139-
140- > The last ` ; ` will be removed if and only if last statement contains ';', and statement has only whitespace follow the last ` ; ` .
141-
142- ### Transactions
143-
144- ``` java
145- connection. beginTransaction()
146- .then(Mono . from(connection. createStatement(" INSERT INTO `person` (`first_name`, `last_name`) VALUES ('who', 'how')" ). execute()))
147- .flatMap(Result :: getRowsUpdated)
148- .thenMany(connection. createStatement(" INSERT INTO `person` (`birth`, `nickname`, `show_name`) VALUES (?, ?name, ?name)" )
149- .bind(0 , LocalDateTime . of(2019 , 6 , 25 , 12 , 12 , 12 ))
150- .bind(" name" , " Some one" )
151- .add()
152- .bind(0 , LocalDateTime . of(2009 , 6 , 25 , 12 , 12 , 12 ))
153- .bind(1 , " My Nickname" )
154- .bind(2 , " Naming show" )
155- .returnGeneratedValues(" generated_id" )
156- .execute())
157- .flatMap(Result :: getRowsUpdated)
158- .then(connection. commitTransaction());
159- ```
160-
161- ## Data Type Mapping
162-
163- The default built-in ` Codec ` s reference table shows the type mapping between [ MySQL] [ m ] and Java data types:
164-
165- | MySQL Type | Unsigned | Support Data Type |
166- | ---| ---| ---|
167- | ` INT ` | ` UNSIGNED ` | [ ** ` Long ` ** ] [ java-Long-ref ] , [ ` BigInteger ` ] [ java-BigInteger-ref ] |
168- | ` INT ` | ` SIGNED ` | [ ** ` Integer ` ** ] [ java-Integer-ref ] , [ ` Long ` ] [ java-Long-ref ] , [ ` BigInteger ` ] [ java-BigInteger-ref ] |
169- | ` TINYINT ` | ` UNSIGNED ` | [ ** ` Short ` ** ] [ java-Short-ref ] , [ ` Integer ` ] [ java-Integer-ref ] , [ ` Long ` ] [ java-Long-ref ] , [ ` BigInteger ` ] [ java-BigInteger-ref ] , [ ` Boolean ` ] [ java-Boolean-ref ] (Size is 1) |
170- | ` TINYINT ` | ` SIGNED ` | [ ** ` Byte ` ** ] [ java-Byte-ref ] , [ ` Short ` ] [ java-Short-ref ] , [ ` Integer ` ] [ java-Integer-ref ] , [ ` Long ` ] [ java-Long-ref ] , [ ` BigInteger ` ] [ java-BigInteger-ref ] , [ ` Boolean ` ] [ java-Boolean-ref ] (Size is 1) |
171- | ` SMALLINT ` | ` UNSIGNED ` | [ ** ` Integer ` ** ] [ java-Integer-ref ] , [ ` Long ` ] [ java-Long-ref ] , [ ` BigInteger ` ] [ java-BigInteger-ref ] |
172- | ` SMALLINT ` | ` SIGNED ` | [ ** ` Short ` ** ] [ java-Short-ref ] , [ ` Integer ` ] [ java-Integer-ref ] , [ ` Long ` ] [ java-Long-ref ] , [ ` BigInteger ` ] [ java-BigInteger-ref ] |
173- | ` MEDIUMINT ` | ` SIGNED/UNSIGNED ` | [ ** ` Integer ` ** ] [ java-Integer-ref ] , [ ` Long ` ] [ java-Long-ref ] , [ ` BigInteger ` ] [ java-BigInteger-ref ] |
174- | ` BIGINT ` | ` UNSIGNED ` | [ ** ` BigInteger ` ** ] [ java-BigInteger-ref ] , [ ` Long ` ] [ java-Long-ref ] (Not check overflow) |
175- | ` BIGINT ` | ` SIGNED ` | [ ** ` Long ` ** ] [ java-Long-ref ] , [ ` BigInteger ` ] [ java-BigInteger-ref ] |
176- | ` FLOAT ` | ` SIGNED ` / ` UNSIGNED ` | [ ** ` Float ` ** ] [ java-Float-ref ] , [ ` BigDecimal ` ] [ java-BigDecimal-ref ] |
177- | ` DOUBLE ` | ` SIGNED ` / ` UNSIGNED ` | [ ** ` Double ` ** ] [ java-Double-ref ] , [ ` BigDecimal ` ] [ java-BigDecimal-ref ] |
178- | ` DECIMAL ` | ` SIGNED ` / ` UNSIGNED ` | [ ** ` BigDecimal ` ** ] [ java-BigDecimal-ref ] , [ ` Float ` ] [ java-Float-ref ] (Size less than 7), [ ` Double ` ] [ java-Double-ref ] (Size less than 16) |
179- | ` BIT ` | - | [ ** ` ByteBuffer ` ** ] [ java-ByteBuffer-ref ] , [ ` BitSet ` ] [ java-BitSet-ref ] , [ ` Boolean ` ] [ java-Boolean-ref ] (Size is 1), ` byte[] ` |
180- | ` DATETIME ` / ` TIMESTAMP ` | - | [ ** ` LocalDateTime ` ** ] [ java-LocalDateTime-ref ] , [ ` ZonedDateTime ` ] [ java-ZonedDateTime-ref ] , [ ` OffsetDateTime ` ] [ java-OffsetDateTime-ref ] , [ ` Instant ` ] [ java-Instant-ref ] |
181- | ` DATE ` | - | [ ** ` LocalDate ` ** ] [ java-LocalDate-ref ] |
182- | ` TIME ` | - | [ ** ` LocalTime ` ** ] [ java-LocalTime-ref ] , [ ` Duration ` ] [ java-Duration-ref ] , [ ` OffsetTime ` ] [ java-OffsetTime-ref ] |
183- | ` YEAR ` | - | [ ** ` Short ` ** ] [ java-Short-ref ] , [ ` Integer ` ] [ java-Integer-ref ] , [ ` Long ` ] [ java-Long-ref ] , [ ` BigInteger ` ] [ java-BigInteger-ref ] , [ ` Year ` ] [ java-Year-ref ] |
184- | ` VARCHAR ` / ` NVARCHAR ` | - | [ ** ` String ` ** ] [ java-String-ref ] |
185- | ` VARBINARY ` | - | [ ** ` ByteBuffer ` ** ] [ java-ByteBuffer-ref ] , ` Blob ` , ` byte[] ` |
186- | ` CHAR ` / ` NCHAR ` | - | [ ** ` String ` ** ] [ java-String-ref ] |
187- | ` ENUM ` | - | [ ** ` String ` ** ] [ java-String-ref ] , [ ` Enum<?> ` ] [ java-Enum-ref ] |
188- | ` SET ` | - | ** ` String[] ` ** , [ ` String ` ] [ java-String-ref ] , [ ` Set<String> ` ] [ java-Set-ref ] and [ ` Set<Enum<?>> ` ] [ java-Set-ref ] ([ ` Set<T> ` ] [ java-Set-ref ] need use [ ` ParameterizedType ` ] [ java-ParameterizedType-ref ] ) |
189- | ` BLOB ` s (` LONGBLOB ` , etc.) | - | [ ** ` ByteBuffer ` ** ] [ java-ByteBuffer-ref ] , ` Blob ` , ` byte[] ` |
190- | ` TEXT ` s (` LONGTEXT ` , etc.) | - | [ ** ` String ` ** ] [ java-String-ref ] , ` Clob ` |
191- | ` JSON ` | - | [ ** ` String ` ** ] [ java-String-ref ] , ` Clob ` |
192- | ` GEOMETRY ` | - | ** ` byte[] ` ** , ` Blob ` |
193-
194- ## Statements Logging/Debugging
195-
196- Use the ` io.asyncer.r2dbc.mysql.QUERY ` logger and the ` DEBUG ` log level to log statements and their bound
197- parameters (if it is prepared statement).
198-
199- For example, in ` logback.xml ` :
200-
201- ``` xml
202- <configuration >
203- <!-- ... -->
204- <logger name =" io.asyncer.r2dbc.mysql" level =" INFO" /> <!-- or DEBUG if necessary -->
205- <logger name =" io.asyncer.r2dbc.mysql.QUERY" level =" DEBUG" />
206- <!-- ... -->
207- </configuration >
208- ```
209-
210- Note that it will print the SQL statement and all parameters, so this may be a security risk. Don't use it
211- in an environment with sensitive data. It should be used for debugging purposes only.
212-
213- The log format may be different for server-preparing and client-preparing. This is because the actual
214- generated statements and commands are different in these two modes. For example, a server-preparing statement
215- has its statement ID that's generated by server, but client-preparing does not.
113+ See [ Usage] ( https://github.com/asyncer-io/r2dbc-mysql/wiki/usage ) wiki for more information.
216114
217115## Reporting Issues
218116
@@ -255,27 +153,3 @@ Thanks a lot for your support!
255153 projects.
256154
257155[ m ] : https://www.mysql.com
258- [ java-BigDecimal-ref ] : https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html
259- [ java-BigInteger-ref ] : https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html
260- [ java-BitSet-ref ] : https://docs.oracle.com/javase/8/docs/api/java/util/BitSet.html
261- [ java-Boolean-ref ] : https://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html
262- [ java-Byte-ref ] : https://docs.oracle.com/javase/8/docs/api/java/lang/Byte.html
263- [ java-ByteBuffer-ref ] : https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html
264- [ java-Double-ref ] : https://docs.oracle.com/javase/8/docs/api/java/lang/Double.html
265- [ java-Float-ref ] : https://docs.oracle.com/javase/8/docs/api/java/lang/Float.html
266- [ java-Integer-ref ] : https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html
267- [ java-Long-ref ] : https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html
268- [ java-LocalDateTime-ref ] : https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html
269- [ java-ZonedDateTime-ref ] : https://docs.oracle.com/javase/8/docs/api/java/time/ZonedDateTime.html
270- [ java-OffsetDateTime-ref ] : https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html
271- [ java-Instant-ref ] : https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html
272- [ java-LocalDate-ref ] : https://docs.oracle.com/javase/8/docs/api/java/time/LocalDate.html
273- [ java-Duration-ref ] : https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html
274- [ java-LocalTime-ref ] : https://docs.oracle.com/javase/8/docs/api/java/time/LocalTime.html
275- [ java-OffsetTime-ref ] : https://docs.oracle.com/javase/8/docs/api/java/time/OffsetTime.html
276- [ java-Year-ref ] : https://docs.oracle.com/javase/8/docs/api/java/time/Year.html
277- [ java-Short-ref ] : https://docs.oracle.com/javase/8/docs/api/java/lang/Short.html
278- [ java-Enum-ref ] : https://docs.oracle.com/javase/8/docs/api/java/lang/Enum.html
279- [ java-String-ref ] : https://docs.oracle.com/javase/8/docs/api/java/lang/String.html
280- [ java-Set-ref ] : https://docs.oracle.com/javase/8/docs/api/java/util/Set.html
281- [ java-ParameterizedType-ref ] : https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/ParameterizedType.html
0 commit comments