Saturday, November 10, 2007

Java Interview Preparation Kit

Java Interview Preparation Kit - JDBC Part - 2.

Type-2 : Native API Partly JAVA Driver (Thick Driver) :

JDBC Database calls are translated into Vendor-specific API calls. The database will process the request and send the results back through API to JDBC Driver – this will translate the results to the JDBC standard and return them to the Java application.

The Vendor specific language API must be installed on every client that runs the JAVA application.

Architecture

This driver converts the JDBC call given by the Java application to a DB specific native call (i.e. to C or C++) using JNI (Java Native Interface).

Advantages :Faster than the other types of drivers due to native library participation in socket programing.

Disadvantage : DB spcifiic native client library has to be installed in the client machine.

3 Preferablly work in local network environment because network service name must be configured in client system

Where to use?

This type of drivers are suitable to be used in server side applications.

Not recommended to use with the applications using two tire model (i.e. client and database layer's) because in this type of model client used to interact with DB using the driver and in such a situation the client system sould have the DB native library.

Examples of this type of drivers

1. OCI 8 (Oracle Call Interface) for Oracle implemented by Oracle Corporation.

Setting environment to use this driver

4 Software: Oracle client software has to be installed in client machine

5 classpath  %ORACLE_HOME%\ora81\jdbc\lib\classes111.zip

6 path  %ORACLE_HOME%\ora81\bin

How to use this driver


 

 Driver class name  oracle.jdbc.driver.OracleDriver

1 Driver URL  jdbc:oracle:oci8:@TNSName

Note: TNS Names of Oracle is available in Oracle installed folder %ORACLE_HOME%\Ora81\network\admin\tnsnames.ora

2. Weblogic Jdriver for Oracle implemented by BEA Weblogic:

Setting environment to use this driver

7 Oracle client software has to be installed in client machine

8 weblogicoic dll's has to be set in the path

9 classpath  d:\bea\weblogic700\server\lib\weblogic.jar

10 path  %ORACLE_HOME%\ora81\bin;

d:\bea\weblogic700\server\bin\<subfolder><sub folder> is

o oci817_8 if you are using Oracle 8.1.x

o oci901_8 for Oracle 9.0.x

o oci920_8 for Oracle 9.2.x

How to use this driver


 

 Driver class name  weblogic.jdbc.oci.Driver


 

2 Driver URL  jdbc:weblogic:oracle:HostName

Type-3 Intermediate DataBase Access Server :

Type-3 Driver uses an Intermediate(middleware) database driver that has the ability to connect multiple JAVA clients to multiple database servers.

Client connect to the Databse server via an Intermediate server component (such as listener) that acts as a gateway for multple database servers.

Bea weblogic includes Type-3 Driver.

Architecture :

This type of drivers responsibility is to convert JDBC call to Net protocol (Middleware listener dependent) format and redirect the client request to Middleware Listener and middleware listener inturn uses type-1, type-2 or type-4 driver to interact with DB.

Advantages:

1 It allows the flexibility on the architecture of the application.

2 In absence of DB vendor supplied driver we can use this driver

3 Suitable for Applet clients to connect DB, because it uses Java libraries for communication between client and server.

Disadvantages:

1 From client to server communication this driver uses Java libraries, but from server to DB connectivity this driver uses native libraries, hence number of API conversion and layer of interactions increases to perform operations that leads to performance deficit.

2 Third party vendor dependent and this driver may not provide suitable driver for all DBs

Where to use?

1 Suitable for Applets when connecting to databases

Examples of this type of drivers:

1. IDS Server (Intersolv) driver available for most of the Databases

Setting environment to use this driver

11 Software: IDS software required to be downloaded from the following URL

[ http://www.idssoftware.com/idsserver.html -> Export Evaluation ]

12 classpath  C:\IDSServer\classes\jdk14drv.jar


 

13 path 

How to use this driver

Driver class name  ids.sql.IDSDriver


 

3 Driver URL  jdbc:ids://localhost:12/conn?dsn='IDSExamples'

Note: DSN Name must be created in ServerDSN

Type-4 Pure JAVA Driver (Thin driver) :


 

Type-4 Driver translates JDBC-API calls to direct network calls using vendor specific networking protocols by making direct server connections with the database.

Architecture

This type of driver converts the JDBC call to a DB defined native protocol.

Advantage

2 Type-4 driver are simple to deploy since there is No client native libraries required to be installed in client machine

3 Comes with most of the Databases

Disadvantages:

1 Slower in execution compared with other JDBC Driver due to Java libraries are used in socket communication with the DB

Where to use?

2 This type of drivers are sutable to be used with server side applications, client side application and Java Applets also.

Examples of this type of drivers

1) Thin driver for Oracle implemented by Oracle Corporation

Setting environment to use this driver

14 classpath  %ORACLE_HOME%\ora81\jdbc\lib\classes111.zip

How to use this driver

 Driver class name  oracle.jdbc.driver.OracleDriver


 

4 Driver URL  jdbc:oracle:thin:@HostName:<port no>:<SID>

<port no>  1521

<SID> -> ORCL

2) MySQL Jconnector for MySQL database


 

Setting environment to use this driver

15 classpath  C:\mysql\mysql-connector-java-3.0.8-stable\mysql-connector-java-3.0.8-stable-bin.jar