Monday 4 June 2012

Types of Drivers

To Deal with any database through our java program, first we must identify the specific JDBC Driver (oracle Driver) and that Driver must registered with DriverManagers class and whose fully Qualified name is 

java.sql.DriverManager. after registering the specific jdbc driver with the driver manager class bridge will be established between java program and specific database


Types of Drivers

JDBC Drivers are classified by sun micro system in four ways. in other words according to the Industry standards drivers in the database programming are classified into four ways. they are
  1. Type-1-->JDBC-ODBC Bridge Driver
  2. Type-II-->Native or Partly Java Drivers
  3. Type-III-->Intermediate Database Server Access/Net protocol Drivers
  4. Type-IV-->Pure Java Drivers or All Java Drivers
Type-I Driver


ODBC Drivers are developed by x-open company. X-Open company realizes the specification to the real industry for the development of ODBC Drivers. the specification of ODBC Drivers are developed by microsoft with the help of X-Open Company


Sun Microsystem developed a driver for all database vendors which will deal internally with odbc drivers the driver name which is developed by sun micro system is sun.jdbc.odbc.JdbcOdbcDriver
sun.jdbc.odbc is known as package name
JdbcOdbcDriver is known as class
by above diagram
1,2 a java application is developed with JDBC API 
3 java releated calls are converted into database related calls with the help JDBC ODBC Bridge
4,5 ODBC Layer and ODBC API taken the Database releted calls to the appropriated database
6,7 database results are obtained and given to ODBC API the form of database calls
8,9 JDBC ODBC Bridge will take database related calls and converted into java calls and handover into Java API
10. Java API gives the result back to java application

Limitations of Type-1 Driver: 
1.expensive no of calls are made to access the data from datase
2.type-1 Driver Implemented in c-language. so this is platform independent
3.if the client machine is not having proper ODBC Drivers then we are unable to use type-1 driver.


Type-II Driver:

The JDBC type 2 driver, also known as the Native-API driver is a database driver implementation that uses the client-side libraries of the database. The driver converts JDBC method calls into native calls of the database API.

Functions:
This type of driver converts JDBC calls into calls to the client API for that database.
  1. Client -> JDBC Driver -> Vendor Client DB Library -> Database
AdvantageBetter performance than Type 1 since no jdbc to odbc translation is needed.

Disadvantages
  1. The vendor client library needs to be installed on the client machine.
  2. Cannot be used in internet due the client side software needed.
  3. Not all databases give the client side library.
Type -III Driver

The JDBC type 3 driver, also known as the network-protocol driver is a database driver implementation which makes use of a middle-tier between the calling program and the database. The middle-tier (application server) converts JDBC calls directly or indirectly into the vendor-specific database protocol.
Functions:
  1. Follows a three tier communication approach.
  2. Can interface to multiple databases - Not vendor specific.
  3. The JDBC Client driver written in java, communicates with a middleware-net-server using a database independent  protocol, and then this net server translates this request into database commands for that database.
  4. Thus the client driver to middleware communication is database independent.
  5. Client -> JDBC Driver -> Middleware-Net Server -> Any Database
Advantages
  1. Since the communication between client and the middleware server is database independent, there is no need for the vendor db library on the client machine. Also the client to middleware need'nt be changed for a new database.
  2. The Middleware Server (Can be a full fledged J2EE Application server) can provide typical middleware services like caching (connections, query results, and so on), load balancing, logging, auditing etc..
  3. eg. for the above include jdbc driver features in Weblogic.
  4. Can be used in internet since there is no client side software needed.
  5. At client side a single driver can handle any database.(It works provided the middlware supports that database!!)
Disadvantages
  1. Requires database-specific coding to be done in the middle tier.
  2.  An extra layer added may result in a time-bottleneck. But typically this is overcome by providing efficient middleware

Type-IV Driver
Type -4 driver are known as all java drivers /pure java drivers/ thin drivers
sun micro system has developed/ realized JDBC API Specification to the industry. Most of the Database Vendors has developed their own Drivers According to the Specification of sun micro system in java language.

Advantages of type-IV Drivers
1. Purely Developed in java language so that we will get platform independence.
2. performance of type-iv drivers is more compared to type-i and type-II drivers 
3.to & pro calls between JDBC application and datbase are less hence we get fast communication
4. there is no necessity of creating DSN, Hence we get less communication calls.


No comments:

Post a Comment