Error when trying to connect R to PostgreSQL using RODBC - macos

I am trying to connect to R using RODBC. However, when I run
ch <- odbcConnect("rails_dev", uid="skline", pwd="d0gsleep")
I get this error:
In odbcDriverConnect("DSN=rails_dev;UID=skline;PWD=d0gsleep") :
[RODBC] ERROR: state IM002, code 0, message [iODBC][Driver Manager]Data source name not found and no default driver specified. Driver could not be loaded
Any thoughts? I am new to this and at a loss for what to do next... thank you so much in advance!'
Note I am using Mac OSX

EDIT: The answer below is outdated, as some of the mentioned packages aren't available on CRAN any longer. I leave it here for reference.
More recent info can be found in the following question:
How to connect R with PostgreSQL on OSX 10.10.2?
For connection to PostgreSQL on Mac, you can use the package RpgSQL. Be sure to read the installation notes, as your PostgreSQL installation has to be set up for using JDBC. This is by far the easiest way. If you install PostgreSQL, you fire up the Stack Builder at the end of the installation process to do so (see the installation guide). Alternatively, you can use the Stack Builder (included in the postgreSQL installation) after installation to add extra components. Under Database drivers you should find postgresql JDBC.
The rdbi package mentioned in the comments, is removed from CRAN and afaik not maintained any more.
If you really need to use ODBC, you need a driver for PostgreSQL, and it has to be known to the ODBC implementation on your computer. The driver Jim M. gave you is one option, another one is the drivers of Openlinksw or the "official" one on pgFoundry. Normally, you should be able to download an ODBC driver from Stack Builder like you do for a JDBC driver : under the heading database drivers you have a postgresql ODBC as well.
For the newest versions of OSX, you need to install your own odbc manager apparently. Next to the one Eelke mentioned in the comments, you have the one from Apple as well here. In this manager, you can specify the driver location etc, and set up the connection to PostgreSQL through ODBC. How to do this, is dependent on the manager you use and is explained in the help files. It's always interesting to read the relevant section in the FAQ of iODBC and the sections on ODBC on Mac.
On a sidenote : In R, You can check which DSNs can be found by using the command odbcDataSources() of the RODBC package. If Postgresql is not mentioned in there, you know you have to look at your setup first.

Depending on the database you want to connect to, Actual Technologies has drivers for Mac OSX for open source databases (MySQL, PostgreSQL), Oracle, as well as Microsoft Access, etc, and costs about $35. Setup in ODBC administrator is straightforward whether you want to create a connection for all users on the machine (System DSN) or for user-specific level as there is a wizard that will walk through basic steps.

Related

Unable to connect to Oracle DB by Tableau from windows10

I have installed tableau desktop version 2020.1.3 (with its license) and also its required drivers from here.
Now, according to what is considered in installation guides, what I am supposed to do as first step, would be just to open the tableau software and enter the needed connection information to connect to Oracle DB.
Although I done these steps in the said way, I get the following error:
An error occurred while communicating with the data source
Bad Connection: Tableau could not connect to the data source.
Error Code: 37CE01A3
No details available.
Can anyone help me with this error? Are there any settings or configurations that I did not attention to?
Thanks
By reading the related log file, I have found that the wrong is with Java version. So, I installed a higher version of Java, and everything went well. To me, available Java version was 1.7 that I change it to 1.8.

How to get MacOS Oracle ODBC client working with unixodbc?

I'm having a difficult time getting the Oracle 12.2.0.1.0-2 ODBC drivers and Instant Client (Basic Lite version) working with homebrew-installed unixODBC 2.3.5 under MacOS 10.12.6 (Sierra).
Extracting both of the Oracle ZIP files to /opt/ora12/instantclient_12_2, creating symlinks for libclntsh.dylib and libclntsh.dylib.12.1, then pointing odcb to the /opt/ora/12/instantclient_12_2/libsqora.lib gives a file not found error. While the path definitely exists and has good permissions, inspecting the dylib with otool -L shows that the #rpath directories are not finding the supporting libraries.
If I pull down the 12.2 sqlplus client, extract it to the same instantclient tree and run the binary, the CLI works fine. This seems to be some sort of dylib loading issue with odbc, but I'm not sure how to fix it. I've tried setting DYLIB_LIBRARY_PATH, copying all the libraries straight into /usr/local/lib, all to no effect.
I've not yet tried to pull out install_name_tool and hard coding search paths (getting further in the weeds than I've done before on MacOS) and I'm hoping something so drastic and non-portable isn't required. Is there a step to the install process I'm missing to get this working?
Thanks in advance!
After significant back and forth on the Oracle Community forums, the condensed solution is documented at this blog post: https://blogs.oracle.com/opal/installing-the-oracle-odbc-driver-on-macos?dd
In brief, the Oracle ODBC supplied odbc_update_ini.sh needs to be ran after first patching to change the reference from libsqora.so.12.1 to libsqora.dylib.12.1. Two libraries (libclntsh.dylib.12.1 and libclntshcore.dylib.12.1) then need to be symlinked into a library location on your PATH (I used /usr/local/lib).
With the above config (using the Basic client instead of Basic Lite, though Basic Lite should work) and the necessary tnsnames.ora black magic (TNS connection strings are covered in many other SO questions), I was able to connect both with command line isql and with my true goal, R's odbc and DBI using unixODBC.

Issue installing Oracle SQL Developer on my MacBookPro - Am I missing a component?

I had to recently re-install OS X on my MBP and am in the process of re-installing all of my apps. One app that worked just fine in the past, but is now giving me errors is Oracle SQL Developer and I can't for the life of me figure out what I am missing.
Here's what I have tried:
Downloaded and installed SQL Developer on my machine.
Downloaded the Instant Client related files - http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html (I installed all of the 64 bit related stuff on this page - Im on a 64 bit machine), combined it into one folder and moved it my /usr folder using this guide: installing Oracle Instantclient on Mac OS/X without setting environment variables?
I also installed this the JDK: http://www.oracle.com/technetwork/java/javase/downloads/index.html
I also set up my TNSNames.ora file and copied it to my /etc folder (This is required on a mac)
Here's my problem - If I attempt to connect to my Oracle instance using the above, it throws this error:
An error was encountered performing the requested operation:
no ocijdbc11 in java.library.path
Vendor code 0
This occurs whether I use basic or the TNS connection type.
So my question to my fellow developers is - Am I missing something in terms of the install above? I have tried googling for that particular error message and not found anything useful. At first glance, it seems like SQL Developer is looking for some file.
Thanks in advance for your answers!
EDIT - The version of SQL Developer that I am trying to install is 3.1.07 and I am trying to connect to an 11G instance.
Go to Tools > Preferences > Database > Advanced, and make sure Use OCI/Thick driver is un-checked.
Once done, try creating a connection and test. I also think you might be running an in-compatible version of Java in your newly installed OS X, so try installing JDK 1.6.0_11 or above, if the solution doesn't work.

Oracle ODBC dns connection

My boss has asked me to set up a connection to our oracle Database (not local).
My first step was to download a oracle ODBC driver to use.
I downloaded and installed "ODBC Driver for Rdb, Release 3.3.2.0 64-bit (odbc3320_64.zip)".
I then decided to set up the DNS as I have done before using ODBC manager in windows 7.
Unfortunatly its not as easy as setting up a connection to a sql server.
Im wondering could some one walk me through the process or has anyone got a video link?
Many thanks
heres TNSPING result
Assuming that you are trying to connect to an Oracle database, not an Oracle RDB database (RDB is a database that Oracle the company acquired from DEC), and assuming that the Oracle database is a reasonably recent version, and assuming that you do not have a version of the Oracle client installed on your machine now, the simplest approach is likely to download and install the 11.2 Oracle client on your machine and to choose to install the Oracle ODBC driver as part of that installation.
If you look at the Oracle Database Software Downloads page, under Oracle Database 11g Release 2, there will be a set of links for both 32- and 64-bit Windows. Choose the "See All" option for whatever version of Windows you have. That should give you an option to download something called the "Oracle Database 11g Release 2 Client" which is going to be a ~600 MB download. Once you have that, run the installer and make sure to include the Oracle ODBC driver as part of the installation (you may need to do a custom install, I don't recall which of the client installation options includes an ODBC driver by default).

Cognos 8.3 failing to connect to data source. Why?

I have installed Cognos BI 8.3 on my machine, which has a Windows 7 OS 64-bit. In IBM's supported environment list for Cognos 8.3, Windows 7 is not listed. On top of that, it says the product will only integrate with 32-bit 3rd party libraries. So, you can already see that I'm already starting on a bad foot. But anyways, this is the machine I have and that is the software I got, so I decided to see if they would work together..
I installed Oracle 10g Express database also in my machine and Apache 2.2 server. Up to there no problems.
Before moving further, I copied ojdbc14.jar to cognos/.../webapps/p2pd/WEB-INF/lib and added the Oracle database in Cognos Configuration. Tested, passed.
With the database started, the Apache server started, and Cognos started, I was successfully able to start Cognos Connection on the computer. So, it looks like the OS is not an issue.
(You can see everything I did by following the steps on this site, which since two days ago seems to be down but I'm thinking will eventually come back up)
Then I decided to try the samples, so I tried to create a data source connection from Cognos to the Oracle database. So, in the admin config console (i.e. Administer Cognos Contents > Configuration), I decided to create a new Oracle data source. I put the credentials, but BAM.. testing fails.
Fail Message:
QE-DEF-0285 The logon failed.
QE-DEF-0323 The DSN(ODBC)/ServiceName is invalid. Either the DSN is missing or the host is inaccessible.
RQP-DEF-0068 Unable to connect to at least one database during a multi-database attach to 1 database(s) in:
testDateSourceConnection
UDA-SQL-0031 Unable to access the "testDataSourceConnection" database.
UDA-SQL-0532 Data Source is not accessible: "XE".
ORA-12154: TNS:could not resolve the connect identifier specified
RSV-SRV-0042 Trace back:
...
From what I have researched, it could be a number of things, but nothing seems to work. Here is what I tried:
Adding ODBC driver. Added the Oracle XE driver, even making sure it was done in the 32-bit ODBC manager (i.e. Windows\SysWOW64\odbcad32.exe). That didn't work.
Added ORACLE_HOME, LD_LIBRARY_PATH, and TNS_ADMIN to my environment variables.
tnsping'ed the XE database and it the ping returned ok.
There are no tnsnames.ora duplicates in the computer.
I tried and I am able to connect to the database via sqlplus. Did I mention that Cognos Config database test also passed?
Installed Oracle XE client. But didn't do much with it because the Oracle server is installed in the computer and also has a client component.
Has anyone come across this problem? I haven't been able to diagnose the problem or make even the slight progress for days. If you would like me to provide more information on any of the solutions I tried, please do ask. If you have a potential solution or, even better, if you have been able to solve this problem before, please let me know how!
Thanks!
One thing to keep in mind : certain portions of Cognos BI are implemented via Java and other portions are implemented via native C++ processes (the BI Bus processes)
Cognos connects to the content store database from the Java process using JDBC.
The BI Bus processes will connect to Oracle using a native oracle client.
So based on your description, I'd say that the problem area is in the native oracle client configuration (or the Cognos service's perspective of it).
You mentioned adding the ORACLE_HOME, LD_LIBRARY_PATH, and TNS_ADMIN environment variables in windows, and the fact that Oracle Utilities like SQLPlus and TNSPing are working for you.
When you added the environment variables, did you add them to the SYSTEM area for environment variables or the User area...?
If you're running Cognos as a service, its going to be a child process of SERVICES.EXE, which is run as system (this process is also not restarted unless you reboot the machine).
I'd try this :
make sure the above environment variables are defined for the SYSTEM user (in the system area, not the user area)
once you've done this, reboot the machine
See if you can create the database connection now.
If that doesn't work, I'd suggest doing a "run as" of SQLPlus or TNSPING as the SYSTEM user (and see if that works).
In order to use oracle as data source, you must install 32 bit client.
64 bit client will not work.
So if you installed oracle express 64 bit, and you don't want to uninstall it,
you can just install additional 32 bit client, and make sure to set it as your default home.

Resources