Coder Social home page Coder Social logo

Comments (3)

chrisknoll avatar chrisknoll commented on June 11, 2024

@schuemie ,
I was about to fix this myself, but saw some oddness that I am not sure was intentional or not:

In my own local tests with Oracle, using the following format of JDBC url for thin is:
jdbc:oracle:thin@//{host}:{port}/{service name}
In my env, I have oracle XE installed, it installed with a default service name of XE and I connect to it as follows:
jdbc:oracle:thin:@//127.0.1:1521/xe

I noticed in your code that you have a JDBC url configuration that looks like you'd use when connecting to a SID:
(see http://razorsql.com/docs/help_oracle.html for reference)
jdbc:oracle:thin:@{host}:{port}:{SID}

It looks like in your code you are trying it one way or the other way, but the 'other' way in the code does not look like it is using any recognizable format:

# Try using TNSName instead:
if (result == "try-error")
  result <- class(try(connection <- RJDBC::dbConnect(driver,
                                                     paste("jdbc:oracle:thin:@",
                                                           server,
                                                           sep = ""),
                                                     user,
                                                     password), silent = TRUE))[1]

I believe the 2 formats that we should try is:
jdbc:oracle:thin:@//localhost:1521/XE
jdbc:oracle:thin:@neptune.acme.com:1521:T10A

(note your current first try uses the second format, and the second try doesn't use any of the above)

I believe the second try should perform the following code:

    result <- class(try(connection <- RJDBC::dbConnect(driver, paste("jdbc:oracle:thin:@//",
                                                                     host,
                                                                     ":",
                                                                     port,
                                                                     "/",
                                                                     sid,
                                                                     sep = ""), user, password), silent = TRUE))[1]

I notied that when the function is called with a server of X/Y, you split the value into 2 parts:

    sid <- server
    if (grepl("/", server)) {
      parts <- unlist(strsplit(server, "/"))
      host <- parts[1]
      sid <- parts[2]

I'm not sure what specific use case this is. But it seems the only 2 formats that are available are with the @//host:port/ServiceName and @host:port:sid.

I'd make the above change myself, but i'm not sure if there was another use case for how you designed the above.

-Chris

from databaseconnector.

chrisknoll avatar chrisknoll commented on June 11, 2024

@schuemie , Doing more reading on this, and it seems that SIDs are not longer the preferred way to connect to an oracle server. We could decare that for oracle connections, that the oracle host must register the service name (which seems to default to the SID in single instance cases, but becomes sid1, sid2, sid3 in clustered environments under a service_name). Since service_name should work in both the single and clustered case, it seems that connecting to the service as a service_name should be the preferred default.

from databaseconnector.

chrisknoll avatar chrisknoll commented on June 11, 2024

Hi, @schuemie ,

Last comment for the night, I swear :)

I found this article:
http://razorsql.com/articles/oracle_jdbc_connect.html

Gives a third option that I think you are using:

jdbc:oracle:thin@<TNSNAME>

So I see what your second option was trying to accomplish: connecting via TNSNAME.

So, seems that oracle thin driver has 3 options that we might want to support:
SID:

jdbc:oracle:thin:@<host>:<port>:<sid>

Service Name (note the //):

jdbc:oracle:thin://@<host>:<port>/<service name>

TNSName: (no //, no host/port etc)

jdbc:oracle:thin:@<TNSName>

On the oci driver format side (I think that's a native driver mode)

jdbc:oracle:oci:@<database_name>

I have absolutely no idea what database name would refer to in this context.

Finally, I found this article on orafaq.com:
http://www.orafaq.com/wiki/JDBC

Seems like the jdbc:oracle:thin:@//{host}{:port}/SERVICE will accept either a SID or Service name. If that's the case, then that's the only JDBC format we need to support.

-Chris

from databaseconnector.

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.