Setting up an Oracle ODBC Driver and Data Source requires more steps than the Microsoft SQL Server database setup. This article explains the steps including tnsnames.ora configuration.
Connecting to an Oracle database via and ODBC driver requires the following steps:
- Install the ODAC (Oracle Data Access Components) or Oracle Client on the Workstation or Application Server.
- Setup the SQLNET and TNSNAMES files in the Client or ODAC home’s Admin directory.
- Use the ODBC Data Source configuration tools to create the ODBC Data Source.
The following blog shows the process involved for each of these steps to get you a working connection to an Oracle database.
Prerequisites: Java JRE or SDK 6 Update 27 or later. These are required by the Oracle Universal Installer to run the ODAC installation program.
Step 1 – Install the ODAC or Oracle Client
In this example we will be installing the ODAC client to complete an ODBC setup on a Windows 7 (64-bit) operating system. You can install the full administrative option of the Oracle Client to obtain the ODBC driver.
Download the ODAC112030_x64.zip file from Oracle’s web site:
Unzip the file to a location of your choosing.
Locate the Setup.exe file under the root directory of the extracted zip file’s directories.
Double-click to run the setup program.
In the ‘Oracle Universal Installer’, click the Next button.
In the ‘Select a Product to Install’ dialog, go with the default ‘Oracle Data Access Components for Oracle Client 188.8.131.52.0’ option.
In the ‘Install Location’ dialog, enter a path to install the ODAC home directory to in the ‘Oracle Base:’ field.
In the ‘Available Product Components’ dialog, go with the default options.
In the ‘Summary’ dialog, verify that the components you have selected for install include the ‘Oracle ODBC Driver for Instant Client 184.108.40.206.0’.
When the installation is complete, click ‘Exit’.
This concludes the steps for installing the ODBC drivers.
Step 2 – Setup the SQLNET and TNSNAMES files
Locate the SQLNET.ora and TNSNAMES.ora in the ‘samples’ directory of the newly installed Oracle client home directory. This is typically:
Where ‘johndoe’ is the windows user name.
Copy these two files into the ‘Admin’ directory above.
Open the ‘TNSNAMES.ora’ file in Notepad and enter your Oracle database details in the file.
Save your changes.
Note: the ‘SQLNET.ora’ generally doesn’t need to be changed.
Step 3 – Create the ODBC Data Source
In the Windows Start menu, click on the Data Sources (ODBC) icon that was created by the ODAC client install.
In the ‘User DSN’ tab of the ‘ODBC Data Source Administrator’ dialog, click Add.
In the ‘Create New Data Source’ dialog, select the ‘Oracle in OraClient 11g_home1’ driver.
In the ‘Oracle ODBC Driver Configuration’ dialog, enter the details of your data source.
Note: you should be able to select the TNS Service Name from the drop down list. This name will be that which you named in the TNSNAMES.ora file’s Alias = section.
Click ‘Test Connection’ to ensure your settings are all correct.
When prompted, enter the database login credentials.
Click OK to complete the process.
Folks who read this article also enjoyed: