Issue with Driver not found when using DBI

Recently ran into a problem when using DBI to connect:

Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Data source name not found and no default driver specified

Here is the ODBC info:
odbcinst -j
unixODBC 2.3.7
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8

Any help would be greatly appreciated. I am not experienced with RSTUDIO

Hello @spelunkee ,

please include the R-code with library statements that you used.
A google search on r dbi odbc connection string gave various results mentioning the package odbc.
Have you installed and used that package?

ODBC is isntalled, here is the command used:

con <- dbConnect(odbc::odbc(), "xxxxx", UID = 'uid', PWD = 'pwd')
Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Data source name not found and no default driver specified

output from this query to show installed drivers:
1 PostgreSQL Description ODBC for PostgreSQL
2 PostgreSQL Driver /usr/lib/
3 PostgreSQL Setup /usr/lib/
4 PostgreSQL Driver64 /usr/lib64/
5 PostgreSQL Setup64 /usr/lib64/
6 PostgreSQL FileUsage 1
7 MySQL Description ODBC for MySQL
8 MySQL Driver /usr/lib/
9 MySQL Setup /usr/lib/
10 MySQL Driver64 /usr/lib64/
11 MySQL Setup64 /usr/lib64/
12 MySQL FileUsage 1
13 FreeTDS Description Free Sybase & MS SQL Driver
14 FreeTDS Driver /usr/lib/
15 FreeTDS Setup /usr/lib/
16 FreeTDS Driver64 /usr/lib64/
17 FreeTDS Setup64 /usr/lib64/
18 FreeTDS Port 1433
19 MariaDB Description ODBC for MariaDB
20 MariaDB Driver /usr/lib/
21 MariaDB Driver64 /usr/lib64/
22 MariaDB FileUsage 1

Output from rpm -qa | grep oracle

it looks like the drivers are installed, I'm definitely missing something.

The error message says Data source name not found .
Are you sure that xxxxx is a valid ODBC resource ?
Do you have a utility on your Operating System to check if that is the case?

I used XXXX to mask the actual name of the datasource as well as removed pwd, etc... They are correct though and are used by other R | R-STUDIO | SHINY servers in my env.

It seems to me that the install cant see the drivers for some reason.

Three suggestions:

  • explicitly use library(DBI) and library(odbc) before the call to dbConnect.
    But maybe you already did this, but did not show all the relevant code :wink:
  • try to connect to another ODBC resource and see if this also fails
  • remove the DBI and odbc packages and reinstall them.
    Equivalent to switch off and on of the computer. It should not help, but sometimes it does.

Good luck!

I was able to remedy the issue. Looks like (as a result of being absent) odbc.ini and odbcinst.ini were misconfigured and looking for an older (11g) Oracle Instant Client. I verified the drivers version (12c) and its location (/ora1/app/oracle/product/12.2.0/dbhome_1/lib/ then proceeded to update both files to reflect the new version and location.

I think we can call that a solution! Thank you so much for your help Han

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.