Failed to obtain R2DBC Connection Java Spring

Viewed 5601

I am getting following exeption connecting to Mssql Server.

> org.springframework.dao.DataAccessResourceFailureException: Failed to obtain R2DBC Connection; nested exception is java.net.UnknownHostException: failed to resolve '' after 10 queries 
    at org.springframework.r2dbc.connection.ConnectionFactoryUtils.lambda$getConnection$0(ConnectionFactoryUtils.java:88) ~[spring-r2dbc-5.3.2.jar:5.3.2]
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
    |_ checkpoint ⇢ Handler com.reactive.testreactive.controller.TestStreamController#findAll() [DispatcherHandler]
    |_ checkpoint ⇢ HTTP GET "/test" [ExceptionHandlingWebHandler]

I connected to JDBC with the same configuration in properties but having an issue while trying to connect to R2DBC. Happens on rest and not on starting an app.

   @Bean
public MssqlConnectionFactory connectionFactory() {
    return new MssqlConnectionFactory(MssqlConnectionConfiguration.builder()
            .host("host")
            .port(1433)
            .database("DataBase")
            .username("username")
            .password("password")
            .build());
}
1 Answers

Do you use absolutely the same configuration? Because if you are starting using R2DBC you should replace database URL: jdbc:postgresql://... -> r2dbc:postgresql://

Related