Closed Krithika-Madhavan closed 1 year ago
You'll need to remove the space characters in the descriptor.
Here's some code I wrote to test this out. You can see after replace(" ", "")
, the descriptor URL does not result in an error.
import io.r2dbc.spi.ConnectionFactories;
import io.r2dbc.spi.ConnectionFactory;
public class DescriptorTest {
public static void main(String[] args) {
String descriptorUrl =
"r2dbc:oracle://?oracle.r2dbc.descriptor=(DESCRIPTION =" +
"(ADDRESS = " +
" (PROTOCOL = TCP)" +
"(HOST = hostname)(PORT = portnum))" +
" (CONNECT_DATA = " +
"(SERVER = DEDICATED)" +
" (SERVICE_NAME = servicename)))";
tryUrl(descriptorUrl);
descriptorUrl = descriptorUrl.replace(" ", "");
tryUrl(descriptorUrl);
}
static void tryUrl(String url) {
System.out.println("Trying:\n" + url);
try {
ConnectionFactory connectionFactory =
ConnectionFactories.get(url);
}
catch (Exception exception) {
System.out.println(exception.getMessage());
}
}
}
Compared to JDBC, R2DBC is more strict about the URL format. URLs must comply with RFC 3986. This is summarized in the R2DBC Specification here: https://r2dbc.io/spec/1.0.0.RELEASE/spec/html/#overview.connection.url With this specification, a space character may not appear in the query section of the URL (the section following the ? character).
Hope this helps.
I'm closing this issue now. I hope it was resolved.
Hi ,
I started using R2DBC recently and we have a descriptor in this Format,
(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = portnum)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = servicename)))
and When i tried connecting to R2DBC using this as below
r2dbc:oracle://?oracle.r2dbc.descriptor=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = portnum)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = servicename)))
My Spring app starts failing with Illegal Character error.
Can you please help providing a sample connection string for this use case or else any solution that will help.
Thanks in Advance!!