I created a new spring boot project using the IntelliJ Idea's spring initializer and checked the Web/Spring reactive Web
and the SQL/Spring data R2DBC
dependencies.
I also added the the dependency to the R2DBC implementation for MySQL
<dependency>
<groupId>dev.miku</groupId>
<artifactId>r2dbc-mysql</artifactId>
<version>0.8.2.RELEASE</version>
</dependency>
and the java connector
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
Asking the version of the MySQL server from a console with
select version();
I get
8.0.17
The connection factory configuration is like this:
@Configuration
@RequiredArgsConstructor
public class R2dbcConfig extends AbstractR2dbcConfiguration {
@Bean
public ConnectionFactory connectionFactory() {
ConnectionFactoryOptions conf = ConnectionFactoryOptions.builder()
.option(DRIVER, "mysql")
.option(HOST, "the.db.url")
.option(PORT, 33066612)
.option(USER, "myUserName")
.option(PASSWORD, "myPassword")
.option(DATABASE, "aDbName")
.build();
return ConnectionFactories.find(conf);
}
}
Nevertheless, when I run the application I get the following exception
reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.dao.DataAccessResourceFailureException: Failed to obtain R2DBC Connection; nested exception is io.r2dbc.spi.R2dbcNonTransientResourceException: [1193] Unknown system variable 'tx_isolation'
Caused by: org.springframework.dao.DataAccessResourceFailureException: Failed to obtain R2DBC Connection; nested exception is io.r2dbc.spi.R2dbcNonTransientResourceException: [1193] Unknown system variable 'tx_isolation'
Answers to similar questions instructed the asker to update the version of the mysql:mysql-connector-java
to 8.+
, and according to IntelliJ the versión resolved by maven is 8.0.26
.
Curiously, if I remove the connector dependency the result is exactly the same.
So, I debbuged the R2DBC implementation to find out what is happening and I discovered that during the handshake, the dev.miku.r2dbc.mysq.QueryFlow#initHandshake
method receives a HandshakeRequest
message whose headers tell that the server version is "5.5.30". And that causes the R2DBC implementation to use the old "tx_isolation" system variable name instead of the new "transaction_isolation".
Why? What am I missing?