Presentation is loading. Please wait.

Presentation is loading. Please wait.

ODBC, OCCI and JDBC overview

Similar presentations


Presentation on theme: "ODBC, OCCI and JDBC overview"— Presentation transcript:

1 ODBC, OCCI and JDBC overview
Connection to Oracle ODBC, OCCI and JDBC overview

2 Outline: Oracle Call Interface (OCI) OCI Inhancement
Oracle C++ Call Interface (OCCI) Open Database Connectivity (ODBC) Java Database Connectivity (JDBC) Accessibility. Consistency of access across database servers. Thin & OCI Drivers Example: Connecting to Oracle Sample Database Application: front-end back-end example

3 Oracle Call Interface (OCI)
The primary means of accessing Oracle9i and Oracle 10g for that matter is via the Oracle Call Interface The Oracle Call Interface (OCI) is a C call interface to Oracle9i that gives developers the greatest degree of control over program execution and SQL processing Most other access methods, for example, ODBC and JDBC OCI driver, are all built on top of OCI.

4 OCI In Oracle9i, there have been a number of enhancements made to OCI, and higher level access methods, that increase developer productivity and application performance OCCI, an interface for C++ applications, now makes it easier for C++ developers to access the database and manipulate objects. JDBC enhancements improve efficiency and extend functionality for Java developers ODBC is developed by Microsoft

5 OCI Enhancements A number of enhancements to OCI improve performance and ease development of applications These enhancements include Cursors (scrollable) : used in Oracle to manage result sets from SQL operations Connection Pooling: applications can use connection pooling to make more efficient use of connections to the database

6 Oracle C++ Call Interface (OCCI)
OCCI is a high-performance and scalable API for C++ built on top of OCI The OCCI API is modeled after JDBC, and uses simple JDBC-like constructs. OCCI takes full advantage of advances in the latest C++ language standard OCCI has an extensive collection of easy-to-use C++ classes and templates,

7 Oracle C++ Call Interface (OCCI)
With an extensive collection of easy-to-use C++ classes and templates, OCCI enables a C++ program to: connect to a database execute SQL statements insert/update values in database tables retrieve results of a query execute stored procedures in the database and access the metadata of database schema objects

8 ODBC Open Database Connectivity is developed by Microsoft but used by most vendors. ODBC drivers are software products that form a database-specific link between the application and the database. ODBC drivers typically process the ODBC function calls at a low level They are responsible for moving SQL commands from the application to the database and moving results back from the database to the application.

9 ODBC The functions of the ODBC driver include
Establishing the connection Client-cursor management Translation of commands and data formats to suit a particular database Error-code management

10 ODBC It is fairly common to use ODBC between Access front-end and Oracle database. The ODBC driver that comes with Visual Basic 6 is in the file MSORCL32.DLL. Note also the disadvantages of ODBC: It is controlled by Microsoft (it is not an open standard), so MS may choose to change it to fit their liking. Worse yet, it adds two communication layers which slow down communication. Finally, some users have experienced that many ODBC implementations add considerable delay (up to 30 seconds) every time the client asks for a new transaction.

11 Java Database Connectivity(JDBC)
The Java DataBase Connectivity API is a set of classes allowing a straightforward and vendor-neutral access to database management systems. We will review the basic features of JDBC and their use with Oracle.

12 JDBC Overview Accessibility.
Consistency of access across database servers. Thin & OCI Drivers Example: Connecting to Oracle Sample Database Application: front-end back-end example

13 JDBC: Accessibility. JDBC provides a set of high-level classes that enable anyone acquainted with SQL and Java to write database applications. Considerations like networking and database protocols are transparent to the application programmer. These are handled by classes within JDBC drivers.

14 JDBC: Consistency of access across database servers.
To achieve this, JDBC specifications are agreed upon within the Java community--and each database vendor is then left to implement these specification to work with their product.

15 JDBC: Thin & OCI Drivers
Oracle provides two main types of drivers. The OCI driver. The ``thin'' driver.

16 JDBC: The OCI driver. The OCI (type 2) driver consists of java wrappers to the low-level Oracle Call Interface (OCI) libraries used by utilities like SQL*Plus to access the database server. The OCI driver offers potentially better performance that the thin driver. It however requires the OCI libraries to be installed on the local machine.

17 JDBC: The ``thin'' driver.
Also referred to as type 4 driver, the thin driver is a pure Java implementation of Oracle's networking protocol (Net8). Being self-contained, it may be used on any machine with--or without Oracle installed--or even distributed with application classes in an applet.

18 Example: Connecting to Oracle
We will review below how to access Oracle using both types of driver. First, we use the thin driver to connect to Oracle and execute an update statement. Note that the example below is only intended as an illustration. Try to understand the code.

19 Example: Connecting to Oracle
import java.io.*; import java.sql.*; public class OraThin { public static void main(String[ ] args{ try { Connection con=null; Class.forName("oracle.jdbc.driver.OracleDriver"); con=DriverManager.getConnection( "scott", "tiger"); Statement s=con.createStatement(); s.execute(" INSERT INTO BOOKS VALUES ( 'A Tale of Two Cities', 'William Shakespeare', , '5-JAN-1962' ) "); s.close(); con.close(); } catch(Exception e){ e.printStackTrace();}

20 Example: Connecting to Oracle
The package java.sql containing the JDBC classes is imported. The class OracleDriver, in the package oracle.jdbc.driver is dynamically loaded into the Java runtime using Class.forName(...). A connection is requested to the database corresponding to the connection URL with the statement DriverManager.getConnection(...). scott/tiger is an Oracle user/password. We use instances of the Connection and Statement classes to perform a database operation. The resources hold by these are released using their close() method.

21 Example: Connecting to Oracle
If we want use the OCI driver, the JDBC connection URL above needs to be altered. The only element now required is the service name of the database: database_name. The remainder is resolved using the local Oracle configuration file. DriverManager.getConnection( "scott","tiger");


Download ppt "ODBC, OCCI and JDBC overview"

Similar presentations


Ads by Google