Monday, March 23, 2009

JDBC : oci(Type-2) Vs thin(Type-4)

Some main considerations that you must bear in mind when choosing which JDBC driver to use for your application or applet are:
If you are writing an applet, you must use the JDBC Thin driver. JDBC OCI-based driver classes cannot be downloaded to a Web browser, because they call native (C language) methods.


1> If you desire maximum portability, then choose the JDBC Thin driver. You can connect to an Oracle8 data server from either an application or an applet using the JDBC Thin driver.
2> If you are writing an application and need maximum performance, then choose the JDBC OCI driver.
3> If you are running in the Oracle database server using the Oracle 8.1.5 Java VM, then choose the JDBC Server driver.


Type 2 drivers are generally faster than type 4 drivers because they are directly executed by the computer's CPU.
The type 4 driver's are compiled into byte code and are executed on the Java Virtual Machine, which is then executed by the computer's CPU. The JVM adds an additional layer that affects its performance.
Because the OCI driver uses native code libraries, it executes faster than the thin driver.

There is a significant performance difference between the two drivers when stored procedures are used. The thin driver can take up to twice as long as the OCI driver to execute a stored procedure. Response time can deteriorate quickly if multiple stored procedures are called.

Use the OCI driver if performance is critical to your application or you make heavy use of stored procedures.