'Spring data R2DBC with H2 database Failed to obtain R2DBC Connection
I am developing a spring command line application where I connect to a db using data r2dbc.
For information, my application is written in Kotlin.
the pom file contains:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.7</version>
<relativePath></relativePath>
<!-- lookup parent from repository -->
</parent>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-r2dbc</artifactId>
</dependency>
<dependency>
<groupId>org.mariadb</groupId>
<artifactId>r2dbc-mariadb</artifactId>
<scope>runtime</scope>
</dependency>
(the full pom is the same pom as provided by https://start.spring.io/#!type=maven-project&language=kotlin&platformVersion=2.6.7&packaging=jar&jvmVersion=11&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=data-r2dbc + r2dbc-mariadb)
As it is a command line application I do not need to import the web starter.
In the code, an interface implementing ReactiveCrudRepository<T, ID> has been created.
the application.yml file contains:
spring:
r2dbc:
url: r2dbc:mariadb://localhost:3306/testdb
username: *****
password: *****
This application is working fine.
For test convenience, I would like to use a h2 db.
the following dependencies have been added to the pom file:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-h2</artifactId>
<scope>runtime</scope>
</dependency>
and the application.yml file modified to :
spring:
r2dbc:
url: r2dbc:h2:mem:///testdb
username: sa
password:
logging:
level:
root: DEBUG
But when running with H2 db, the following error appears
2022-05-12 10:47:52.935 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : should warm up 9 extra resources
2022-05-12 10:47:52.953 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 1/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.954 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 2/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.954 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 3/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.954 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 4/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.954 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 5/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.954 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 6/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.954 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 7/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.954 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 8/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.954 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 9/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.955 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : should warm up 9 extra resources
2022-05-12 10:47:52.956 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 1/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.956 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 2/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.956 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 3/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.956 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 4/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.956 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 5/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.956 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 6/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.956 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 7/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.957 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 8/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.957 DEBUG 27893 --- [atcher-worker-1] reactor.pool.SimpleDequePool : failed to warm up extra resource 9/9: io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
2022-05-12 10:47:52.961 ERROR 27893 --- [atcher-worker-1] c.s.n.o.m.c.a.i.r.c.h.ConnectionHandler : Internal Error
org.springframework.dao.DataAccessResourceFailureException: Failed to obtain R2DBC Connection; nested exception is io.r2dbc.spi.R2dbcNonTransientResourceException: [90046] [90046] URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:testdb" [90046-200]
at org.springframework.r2dbc.connection.ConnectionFactoryUtils.lambda$getConnection$0(ConnectionFactoryUtils.java:88) ~[spring-r2dbc-5.3.19.jar:5.3.19]
at reactor.core.publisher.Mono.lambda$onErrorMap$31(Mono.java:3733) ~[reactor-core-3.4.17.jar:3.4.17]
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94) ~[reactor-core-3.4.17.jar:3.4.17]
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:106) ~[reactor-core-3.4.17.jar:3.4.17]
at reactor.core.publisher.FluxRetry$RetrySubscriber.onError(FluxRetry.java:95) ~[reactor-core-3.4.17.jar:3.4.17]
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:172) ~[reactor-core-3.4.17.jar:3.4.17]
at reactor.pool.AbstractPool$Borrower.fail(AbstractPool.java:477) ~[reactor-pool-0.2.8.jar:0.2.8]
Any clue how to solve the problem?
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|