0

I am attempting to connect my R instance to my company's Oracle database. I had issues installing ROracle due to being on version 3.3.6 of R, so I settled on RJDBC instead. I downloaded the JDBC driver in a jar file. And stored this as my jdbcDriver object. See below.

jdbcDriver =JDBC("oracle.jdbc.OracleDriver",classPath="C:/Users/user1/Downloads/ojdbc6.jar",identifier.quote="`")

I then attempted to make my connection to the database using some code I found online with dbConnect:

jdbcConnection =dbConnect(jdbcDriver, "jdbc:oracle:thin:@//HOSTNAME:Port/sid", "username","password")

I don't clearly understand what the second parameter in dbConnect is even after much reading online. I think I have some sort of syntax issue here-- I am confident that the Host Name, Port, SID, user name, and password are correct, though. After much tweaking of the second parameter, including getting rid of the ".com" that was previously in it, I got the following error:

Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], : java.sql.SQLException: Listener refused the connection with the following error: ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

I've done a tone of reading online and I think that maybe I should use something different because I have an SID, not a Service Name? I also am having trouble where the error first occurs? Is it the first line of the error code that I should be focusing on before I even look at the third?

I am thoroughly spun around the topic and would appreciate any insights. My end goal is really just to query Oracle through R.

Thanks!

thatjeffsmith
  • 20,522
  • 6
  • 37
  • 120
  • Yes, the *second parameter* is crutial. It is a [`database URL`](https://docs.oracle.com/en/database/oracle/oracle-database/19/jjdbc/data-sources-and-URLs.html#GUID-C4F2CA86-0F68-400C-95DA-30171C9FB8F0) and you will have to understand it. The good news is that if you manage to connect via SQL*Plus, after some reading of the link above you should be able to connect with JDBC. Good luck! – Marmite Bomber Mar 31 '20 at 22:31
  • 1
    After reading the details in that link, I finally go it to work!! Thanks a million!!! – Nikki Petzer Apr 01 '20 at 15:49

0 Answers0