Giter VIP home page Giter VIP logo

Comments (14)

Michael-A-McMahon avatar Michael-A-McMahon commented on August 24, 2024 1

Thanks, I'll test it out later today and update.

from oracle-r2dbc.

Michael-A-McMahon avatar Michael-A-McMahon commented on August 24, 2024 1

I've tried a few various tests, but haven't been able to reproduce the failure. Here's what I've tried:

import io.r2dbc.spi.Connection;
import io.r2dbc.spi.ConnectionFactories;
import io.r2dbc.spi.ConnectionFactory;
import io.r2dbc.spi.ConnectionFactoryOptions;
import oracle.r2dbc.OracleR2dbcOptions;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import static io.r2dbc.spi.ConnectionFactoryOptions.DRIVER;
import static io.r2dbc.spi.ConnectionFactoryOptions.PASSWORD;
import static io.r2dbc.spi.ConnectionFactoryOptions.PROTOCOL;
import static io.r2dbc.spi.ConnectionFactoryOptions.USER;

public class AddressList {


  public static void main(String[] args) {

    // TODO: Change these to your real host, port, and service name.
    String host = "TODO";
    int port = 1521;
    String serviceName = "TODO";

    String descriptor =
      "(DESCRIPTION=" +
        "(ADDRESS_LIST=" +
        "(ADDRESS=(PROTOCOL=TCP)(HOST=thishostdoesnotexist)(PORT=1521))" +
        "(ADDRESS=(PROTOCOL=TCP)(HOST=" + host + ")(PORT=" + port + ")))" +
        "(FAILOVER=on)" +
        "(LOAD_BALANCE=off)" +
        "(CONNECT_DATA=" +
        "(SERVER=DEDICATED)" +
        "(SERVICE_NAME=" + serviceName + ")))";

    // Test a plain Oracle R2DBC URL
    String plainUrl =
      "r2dbc:oracle://?oracle.r2dbc.descriptor=" + descriptor;
    testUrl(plainUrl);

    // Test an R2DBC Pool URL
    String poolUrl =
      "r2dbc:pool:oracle://?oracle.r2dbc.descriptor=" + descriptor;
    testUrl(poolUrl);

    // Test programmatically configured options without R2DBC Pool
    ConnectionFactoryOptions plainOptions =
      ConnectionFactoryOptions.builder()
        .option(DRIVER, "oracle")
        .option(OracleR2dbcOptions.DESCRIPTOR, descriptor)
        .build();
    testOptions(plainOptions);

    // Test programmatically configured options with R2DBC pool
    ConnectionFactoryOptions poolOptions =
      ConnectionFactoryOptions.builder()
        .option(DRIVER, "pool")
        .option(PROTOCOL, "oracle")
        .option(OracleR2dbcOptions.DESCRIPTOR, descriptor)
        .build();
    testOptions(poolOptions);

  }

  static void testUrl(String url) {
    System.out.println("Testing: " + url);

    ConnectionFactoryOptions parsedOptions =
      ConnectionFactoryOptions.parse(url);
    testOptions(parsedOptions);

    System.out.println("OK");
  }

  static void testOptions(ConnectionFactoryOptions options) {
    // TODO: Change "test" user/password to your own. Consider reading the
    //  values from a secure source, rather than hardcoding them in this file.
    options = options.mutate()
      .option(USER, "test")
      .option(PASSWORD, "test")
      .build();

    ConnectionFactory connectionFactory = ConnectionFactories.get(options);

    Flux.usingWhen(
        connectionFactory.create(),
        connection -> Mono.empty(),
        Connection::close)
      .blockFirst();
  }
}

Some theories I have:

  1. I wonder if that error message isn't lying? Perhaps a DATABASE option is being configured somewhere?
  2. Could any part of the DESCRIPTION=... contain something that needs to be percent encoded? https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding
  3. Are we using the same versions? I'm testing Oracle R2DBC 1.1.1, and R2DBC Pool 1.0.0.RELEASE

from oracle-r2dbc.

antoba avatar antoba commented on August 24, 2024 1

@Michael-A-McMahon it works ! We tried on Oracle RAC.
As far as I'm concerned you can close the issue.

Thank you very much for your support.

from oracle-r2dbc.

Michael-A-McMahon avatar Michael-A-McMahon commented on August 24, 2024

Hi, @antoba. Oracle R2DBC supports (DESCRIPTION=... style URLs that can include an ADDRESS_LIST element:
https://github.com/oracle/oracle-r2dbc#configuring-an-oracle-net-descriptor

Would that work for you, or are you looking for something different?

from oracle-r2dbc.

dataatma avatar dataatma commented on August 24, 2024

Running into the same issue. @Michael-A-McMahon Can you give an example connection string? It does not seem to honor
whatever option tried. composeJdbcUrl method in OracleReactiveJdbcAdapter.java supports only one host.

from oracle-r2dbc.

Michael-A-McMahon avatar Michael-A-McMahon commented on August 24, 2024

The r2dbc: URL should look like this:
r2dbc:oracle://?oracle.r2dbc.descriptor=(DESCRIPTION=...)

If that doesn't work, if you to share the URL you have, then I can test it. If you share a URL, it would be good to strip out any real values, like a real host name. Just use a place holder instead of real values.

from oracle-r2dbc.

dataatma avatar dataatma commented on August 24, 2024

@Michael-A-McMahon Here is an example that we tried. r2dbc:oracle:thin://?oracle.r2dbc.descriptor=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=a_host)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=b_host)(PORT=1521)))(FAILOVER=on)(LOAD_BALANCE=off)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=service_name)))
The error that we get is
[org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryConfigurations$PoolConfiguration$PooledConnectionFactoryConfiguration.class]: Failed to instantiate [io.r2dbc.pool.ConnectionPool]: Factory method 'connectionFactory' threw exception with message: oracle.r2dbc.descriptor Option has been specified with potentially conflicting Options: [Option{name='database', sensitive=false}]

from oracle-r2dbc.

Michael-A-McMahon avatar Michael-A-McMahon commented on August 24, 2024

I think it can work if you remove the ":thin" component at the beginning. Oracle R2DBC is not supposed to recognized that.

But there error message is awful; It provides no indication of what the problem is. At the very least, I will fix that.

from oracle-r2dbc.

dataatma avatar dataatma commented on August 24, 2024

I think we tried that but will give it a try.
This is what finally worked however we are sure its just picking one host and there is no way to specify the failover
r2dbc:oracle:thin:@tcps://a_host:1521,b_host:1521/service_name

from oracle-r2dbc.

dataatma avatar dataatma commented on August 24, 2024

Confirm that ":thin" has no effect. Same error as before

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.r2dbc.pool.ConnectionPool]: Factory method 'connectionFactory' threw exception with message: oracle.r2dbc.descriptor Option has been specified with potentially conflicting Options: [Option{name='database', sensitive=false}]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:171) ~[spring-beans-6.0.8.jar!/:6.0.8]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) ~[spring-beans-6.0.8.jar!/:6.0.8]
... 69 common frames omitted
Caused by: java.lang.IllegalArgumentException: oracle.r2dbc.descriptor Option has been specified with potentially conflicting Options: [Option{name='database', sensitive=false}]

from oracle-r2dbc.

antoba avatar antoba commented on August 24, 2024

Hi, @antoba. Oracle R2DBC supports (DESCRIPTION=... style URLs that can include an ADDRESS_LIST element: https://github.com/oracle/oracle-r2dbc#configuring-an-oracle-net-descriptor

Would that work for you, or are you looking for something different?

Well, I didn't know it accepted this syntax, I'll try and eventually let you know if it works in my environment

thanks a lot for now. !

from oracle-r2dbc.

dataatma avatar dataatma commented on August 24, 2024

@Michael-A-McMahon Found the issue and the error indeed is correct. This is in our app properties. spring.r2dbc.name=${DB_SCHEMA} - Once we removed this, the (DESCRIPTION= style worked. Thanks a lot!

from oracle-r2dbc.

Michael-A-McMahon avatar Michael-A-McMahon commented on August 24, 2024

@dataatma: Glad to hear it.
@antoba: I'll leave the issue open for while, hoping things work for you as well.

from oracle-r2dbc.

Michael-A-McMahon avatar Michael-A-McMahon commented on August 24, 2024

Glad to hear it!

from oracle-r2dbc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.