How Does OCI JDBC Application Communicate With Oracle Database Server
This post details out on what happens behind the scenes when an JDBC application using OCI driver communicates with the oracle database server.
A sample jdbc program looks like
import java.sql.*; class DatabaseAccess{ public static void main (String args []) throws Exception { Class.forName ("oracle.jdbc.OracleDriver"); Connection conn = DriverManager.getConnection ("jdbc:oracle:oci:@hostname:1521:service_name", "scott", "tiger"); .... .... } }
As you can see, the program uses the JDBC OCI driver (a type 2 JDBC driver) to create a database connection. The Oracle JDBC OCI driver converts the JDBC invocations to calls to OCI (Oracle Call Interface) which are then sent over by Oracle Net to the Oracle database server.
Oracle Call Interface is a set of low-level APIs used to interact with the Oracle Database. It’s packaged as a software (platform specific) which needs to be installed on the user’s machine in order to connect to the database.
Oracle Net is a component (software layer) of Oracle Net Services which establishes and maintains a network session from a client application to an Oracle Database server. Once the database connection is established, Oracle Net acts as the data courier for both the client application and the database server, exchanging messages between them. Oracle Net can perform this job because its installed on each computer in the network (i.e. both on the client and the server).
Oracle Net has two software components – Oracle Net Foundation Layer and Oracle Protocol Support.
In the adjacent diagram, Oracle Net Foundation Layer and Oracle Protocol Support form the session layer of the OSI model (Open Systems Interconnection model)
In the above jdbc program, the Oracle Net Foundation Layer receives the client application requests and resolves all generic computer level connectivity issues such as
- The location of the database server
- How many protocols are involved in the connection
- How to handle interrupts between the client and database server based on the capabilities of each.
This layer is responsible for establishing and maintaining the connection between the client application and the database server, as well as exchanging messages between them. It uses the Transparent Network Substrate (TNS) technology which enables peer-to-per application connectivity.
On the server side, the Oracle Net Foundation layer performs the same tasks as it does on the client side. It works with the listener to receive incoming connection requests.
Oracle Protocol Support layer is responsible for mapping the TNS functionality to industry-standard protocols used in the client/server connection. This layer supports the following network protocols:
- TCP/IP (IPv4 and IPv6)
- TCP/IP with SSL
- Named Pipes
- Sockets Direct Protocol (SDP)
If you use a thin driver (type 4 JDBC driver) to communicate to the database, the communication stack is slightly different. The thin driver establishes a direct connection to the Oracle database server over java sockets. The driver uses a java implementation of the Oracle Net Foundation layer called JavaNet.
Posted on July 31, 2011, in oracle-jdbc and tagged jdbc, oci, oracle, oracle-net. Bookmark the permalink. Leave a comment.
Leave a comment
Comments 0