• JDBC TYPE -2 Driver:
• What is JDBC Type-2 Driver?
• Ans: Type 2 Driver is a JDBC Driver that converts JDBC API calls to DB Driver Native API Calls.
• Fig: Type2Driver1.jpg
• This 2 tier architecture, because we have API calls is considered as layer but not tier. Here server is
a tier because it is not part of the client.
• Server means which gives the service. Here Database server is giving service like we are storing the
data, and retrieving the data.
• Is fast compares to the other type of drivers.
• It is database dependent (however this is not a big problem in most of the cases)
• This driver is partly implemented in java and partly in Native, thus this driver is unsafe to use
unless we are sure that the native implementation is bug free. As any bug in the native code could
crash the JVM.
• The Native libraries (i.e: the database client software) is need to be installed in t client machine.
• When to use this type-2 Driver?
• Is preferred to use in case if the database is
accessed from the server side (Middleware
server) application such as a web application
as show n in the below architecture:
• CASE 1:
• Fig: Type2Driver2.JPG
• CASE 2:
• In this example for suppose in a super market
there are several billing machines are available, in
each machine standalone software should be
installed and all the data should be stored in the
Database server, for this purpose Type 2 driver is
• Fig: Type2Driver3.JPG
• This type of drivers are named as part java, part native drivers.
• The JDBC OCI is a Type 2 driver from Oracle Corporation for
accessing the oracle database server.
• This JDBC Driver works with the OCI (Oracle Call Interface) Native
• The weblogicOCI is a Type-2 driver from BEA system (now this
company is merged into Oracle Corp) for accessing the Oracle DB
• This driver also works with the OCI native Driver.
• (For example you are a MCA Students (for example WEBLOGICOCI),
and each of student have a unique name or rollnumber( this type -2
• What is Type-4 Driver?
• A JDBC Driver that converts JDBC API calls to
Database Native Network calls is known as
• Fig: Type4Driver.JPG
• It contains 3 elements, 2 tier architecture and 3 layers.
• This is purely implemented in java, thus it is light weight (resource
consumption (ex: memory, time) is less) and portable.
• No need of DB client software to install in the client machine.
• This is platform independent thus this is the best suitable driver for
the web based application.
• This type of driver is database dependent.
• This type of driver has to implement the database network protocol
so is most likely expected from the database vendor.
Q: WHEN TO USE Type-4 Driver?
• Note: java performance is totally depends upon JRE.
• Ans: This type of driver is suitable in the client side
running applications such as desktop application access
DB , and applet.
• However this can be also used in the middleware
server running application but would be choice after
the type-2 driver.
• Fig: Type4Driver b.JPG
• This type of drivers referred as pure java drivers
Type 3 Driver
• A JDBC Driver that converts JDBC API calls into
DATABASE independent network calls is
referred as Type-3 Driver.
• Type-4 DRIVER is purely developed in java
language as part of this driver the java
networking code is provided to communicate
with database server.
Advantages of type 3 driver
• Most of times type-3 driver is used as part of
the applications which cares about the
• This type of JDBC Driver is implemented in 3
• Convenient and applicable to access the
database between the networks.
• The database server details such as location and
authentication details are not exposed to the client (java
• This has an opportunity of managing the db recourses such
as connection effectively by reusing them between the
clients improving the scalability and reducing the cost.
• Note: this can reduce the cost in case if the application is
multiuser and multi-threaded or multiple applications
accessing the same database.
• Type 3 Is database independent
• Type 3 is pure java driver thus lightweight and portable
• Supports conveniently working with distributed
• Having a middleware server and multiple
network calls finds costlier in some times (i.e
for the application.
• That are not seriously interested with the
above listed advantages.
When to use this type of driver?
• Ans: this is the first choice of any java
enterprise application. However in case if the
applications is really small and does not
matter the advantage of this driver then only
it looks for Type-2/4.
• (port means receiving the request, sends
response, it is just like a door)
• If you want to communicate with database
server we have only two ways to communicate
1. API calls or 2. Network calls:
• Note: Interface: there are 3 types of interfaces:
1. UI (User Interface)
3. Network Interface
• Here API Interface and Network Interface are
divided into 2 types: