The Oracle data access component, ODAC, is the name of the applet used to access the Oracle database. We can programmatically invoke these components to accomplish access to the Oracle database on a computer that does not have Oracle database software installed.
Tools/Materials
Step 1. Download ODAC installation package
-
Download the ODAC installation package to the Oracle official website. Find the version you want on the Web page. What I have downloaded is:
64-bit Odac 11.2 Release 6 (11.2.0.4.0) Xcopy for Windows x64
The downloaded installation package is named:
Odac112040xcopy_64bit.zip
END
Step 2. Unzip
-
Unzip this zip package, unzip the files inside to a folder, I am unzip to D:\ODAC112040Xcopy_64bit, then open cmd, go to this folder.
There are 8 subfolders in this folder, namely:
Instantclient_11_2: This is the Oracle client, and all components are run on this client;
OLE DB: This is a component
asp: This is the Asp.net2 component
ASP.NET4: This is the ASP.NET4 component
ODP.NET4: This is the. NET4 component
ODP.NET20: This is the. NET2 component
ORAMTS: This is Oracle's MTS service
Network: This folder does not have a tube, it is used to store tnsnames.ora files, to be installed before use.
-
Here we need to figure out the dependencies between these components.
Instantclient_11_2 is the most basic.
OLE DB relies on instantclient_11_2
ASP. NET relies on instantclient_11_2 and odp.net20
ASP.NET4 relies on instantclient_11_2 and ODP.NET4
ODP.NET4 relies on instantclient_11_2
ODP.NET20 relies on instantclient_11_2
ORAMTS relies on instantclient_11_2
END
Step 3. Installing the ODAC Package
- Run the install.bat batch file in cmd: Enter "Install.bat all D:\OracleClient Odac" (without double quotes). Here are a few parameters to pay special attention to, here we passed three parameters, but can pass up to four.
-
First parameter: all. All represents the installation of all components and clients under the Odac112040xcopy_64bit folder. If you don't need so many components, just one, like the OLE DB component, you can install only the client and this OLE DB component as follows:
-
Install.bat OLE DB D:\OracleClient ODAC
- Second parameter: D:\OracleClient. This is the installation path, according to your actual situation specified, the path as far as possible not to have spaces and parentheses.
- The third parameter: ODAC. This is called the Oracle HOME name, this parameter can also be arbitrarily assigned a string, not necessarily "ODAC". This parameter is used to write to the registry. For example, when the above statement executes, it is written at the following location in the registry:
-
Hklm\software\oracle\key_odac
The ODAC behind this "Key_" is the "ODAC" that you passed in the argument.
- A fourth parameter. Usually only the first three parameters are sufficient, when installing the component will automatically install its dependent components, but if you only want to install the specified components, do not want to load the components it depends on, then the fourth parameter will be used. For example: When you install ASP, if you use only the first three parameters, it will automatically install the odp.net20 and instantclient_11_2 it depends on, but if you pass in the fourth parameter "false", the following:
-
Install.bat ASP. D:\OracleClient ODAC False
This will only install ASP. ODP.NET20 and Instantclient_11_2 are not installed.
END
Step 4. Setting environment variables
-
Oracle_home=d:\oracleclient
(Add an environment variable oracle_home, whose value is your installation path, for example I'm D:\OracleClient here)
-
Path=%oracle_home%;%o Racle_home%\bin;
(In the PATH environment variable, add the following two paths, separated by semicolons:
%oracle_home%;%o Racle_home%\bin;)
END
Step 5. Configure Tnsnames.ora files as needed
-
If you want to use components to access the ORACLE database, configure the Tnsnames.ora file as needed and store it in the%oracle_home%\network\admin directory.
My Tnsnames.ora file format is as follows, for reference:
ORA =
(DESCRIPTION =
(Address_list =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.26.231) (PORT = 1521))
)
(Connect_data =
(service_name = ora)
)
)
END
How to uninstall ODAC
-
Use CMD to enter the installation path to ODAC, and then run the Uninstall.bat batch file under that path. It is also important to note the use of parameters.
================================================
To uninstall all components, you can:
Uninstall.bat all ODAC
Or
Uninstall.bat All D:\OracleClient
================================================
To unload a specified component, you can:
Uninstall.bat OLE DB ODAC
Or
Uninstall.bat OLE DB D:\OracleClient
-
Remove the installation directory manually and delete the environment variables that you previously added.
END
Precautions
How to install Oracle Data Access Component ODAC