Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oracle Descriptor Option #114

Closed
Krithika-Madhavan opened this issue Jan 25, 2023 · 2 comments
Closed

Oracle Descriptor Option #114

Krithika-Madhavan opened this issue Jan 25, 2023 · 2 comments

Comments

@Krithika-Madhavan
Copy link

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!!

@Michael-A-McMahon
Copy link
Member

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.

@Michael-A-McMahon
Copy link
Member

I'm closing this issue now. I hope it was resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants