title: Trouble accessing oracle database using R (odbc package)
body: <p>A colleague at work is having trouble using the odbc package function. I am trying to find help.</p>
  <p>He is using an oracle database using R instead of running our traditional SAS programs, but he has not been successful. We are trying to find out what is causing the error messages below. Can someone help?</p>
  <pre><code>Attempt 1:
  
  #Get the Oracle JDBC driver
  jdbcDriver =JDBC(&quot;oracle.jdbc.OracleDriver&quot;,
  classPath=&quot;C:/instantclient_19_10/ojdbc8.jar&quot;)
  
  Create connection string to the Database we want
  connect.string &lt;-
  glue(&quot;jdbc:oracle:thin:@//{host}:{port}/{sid}&quot;,
  host = &quot;stdbprd01.states.bls.gov&quot;,
  port = 1521,
  sid = &quot;lausonep&quot;)
  print(connect.string)
  #Establish connection to your database
  con &lt;- dbConnect(jdbcDriver,
  connect.string,
  user = &quot;username&quot;,
  password = rstudioapi::askForPassword(&quot;Database password&quot;))
  
  Error in .jcall(drv@jdrv, &quot;Ljava/sql/Connection;&quot;, &quot;connect&quot;, as.character(url)[1], :
  java.sql.SQLRecoverableException: Listener refused the connection with the following error:
  ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
  
  Attempt 2:
  
  library(odbc)
  
  con &lt;- DBI::dbConnect(odbc::odbc(),
  driver=&quot;Oracle in OraClient12Home1&quot;,
  database=&quot;lausprd&quot;,
  uid=&quot;aakre_n&quot;,
  pwd=&quot;!QAZ1qaz@WSX2wsx&quot;,
  host=&quot;stdbprd01.states.bls.gov&quot;,
  port=1521
  )
  
  Error: nanodbc/nanodbc.cpp:1021: IM006: [Oracle][ODBC][ORA]-12560: TNS:protocol adapter error
  [Microsoft][ODBC Driver Manager] Driver’s SQLSetConnectAttr failed
  </code></pre>