Introduction
Let's have a look at the contents.
Contents
- Oracle Database Server
- Oracle Client
- Connect the Oracle Database Server
- Connect the Oracle Database server without Oracle client
- Developer Setup
- Code
- Server Deployment (Web server or Application Server)
- Conclusion
An Oracle database is an object-relational database management system produced and marketed by the Oracle Corporation. It supports heterogeneous data. We can stack our data here.
It has the following two main parts:
- Oracle Database Server
- Oracle Client
Oracle Database Server This is where your data is saved. A database server is the key to solving the problems of information management. In general, a server reliably manages a large amount of data in a multiuser environment so that many users can concurrently access the same data. All this is done while delivering high performance. A database server also prevents unauthorized access and provides efficient solutions for failure recovery.
Oracle Client
If you are connecting to an Oracle server from your application, then the Oracle clients help you to push and pull the data from the Oracle server database, in other words a piece of software that allows a remote computer to talk to Oracle. If you were to write a piece of software that communicates with the database, you would use the Oracle Client to facilitate that communication.
In other words, the Oracle client plays like a broker between your front-end application and the Oracle server database.
Connect the Oracle Database ServerThere are many ways to connect to an Oracle database server but it should use the Oracle client.
Here the
TNSNAMES.ora file plays the main role in the preceding scenario.
Connect to the Oracle Database Server without Oracle ClientThis tool is about connecting to the database server without installing the Oracle client.
- Download Oracle Data Access Components (ODAC) 11.2.0.1.2 - (xcopy version - ODAC112012Xcopy.zip). This component is available in the Oracle downloads.
- Copy OraOps11w.dll found in the odp.net4/b in directory.
- Copy oci.dll, orannzsbb11.dll and oraociicus11.dll found in the instantclient_11_2 directory.
- Copy the Oracle.DataAccess.dll found in the odp.net4/odp.net/bin/4 directory.
Developer Setup
Place the preceding DLLs into your application's executable path.
Place the Oracle.DataAccess.dll in the GAC as in the following:
- C:\> gacutil /i “<Application Path>\ Oracle.DataAccess.dll”
Be sure the assembly entry is available. (
C:\Windows\assembly)
Add the Oracle.DataAccess.dll to your project.
Create the connection string as in the following sample.
- user id=USERID;word=WORD;data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=IPorSERVERNAME) (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ValidSID)))
CodeImport the
Oracle.DataAccess.Client into your source file. Build the ADO.Net code based on the ODAC reference.
- using System;
- using Oracle.DataAccess.Client;
-
- namespace Sample
- {
- class Program
- {
- static void Main(string[] args)
- {
-
-
- string connectionString =
- "user id=USERID;word=WORD;" +
- "data source=(DESCRIPTION=(ADDRESS=" +
- "(PROTOCOL=tcp)(HOST=IPorSERVERNAME)" +
- "(PORT=1521))(CONNECT_DATA=" +
- "(SERVICE_NAME=ValidSID)))";
-
- using (OracleConnection connection =
- new OracleConnection())
- {
- connection.ConnectionString =
- connectionString;
-
- try
- {
- connection.Open();
- Console.WriteLine
- ("Connection Successful!");
- Console.ReadLine();
- }
- catch (OracleException ex)
- {
- Console.WriteLine(ex.ToString());
- Console.ReadLine();
- }
- }
- }
- }
- }
Server Deployment (Web server or Application Server)
- Place the Oracle.DataAccess.dll in the GAC.
- Deploy your application with the preceding supporting libraries.
Conclusion
Now you have connected to the Oracle database server without an Oracle client.