0% found this document useful (0 votes)
23 views10 pages

5.1,5.2 Introduction of Database

Ajp

Uploaded by

nihalpatil0021
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views10 pages

5.1,5.2 Introduction of Database

Ajp

Uploaded by

nihalpatil0021
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Chapter 5

Interacting with database Marks-10

Unit Outcome-
1. Choose JDBC or ODBC depending on the given application
2. Explain function of the given tire of JDBC architecture for two tier/three tier models
3. Use relevant type of JDBC Driver for the specified environment
4. Elaborate steps with example to establish connectivity with the specified database
Introduction of JDBC,ODBC

JDBC API

The JDBC API is comprised of two packages:


• Java.sql
• Javax.sql
4.2 JDBC Architecture

1. Application- It is a java applet or a servlet which communicates with a data source.


2. The JDBC API- The JDBC API allows Java programs to execute SQL statements and retrieve results.
3. DriverManager- It plays an important role in the JDBC architecture. It uses some database-specific drivers to
effectively connect enterprise applications to databases.
4. JDBC drivers- To communicate with a data source through JDBC, you need a JDBC driver that intelligently
communicates with the respective data source.
Types of JDBC Architecture
1. Two-tier model:

2. Three-tier model:
4.3 Drivers
Drivers like JDBC, JDBC-ODBC bridge etc which supports connection with various backends from different vendors

-There are 4 types of JDBC drivers:


1.Type-1 JDBC-ODBC bridge driver
2.Type-2 Native-API driver (partially java driver)
3.Type-3 Network Protocol driver (Middleware)
4.Type-4 Thin driver (pure java driver)
1. Type-1 JDBC-ODBC bridge driver-
The JDBC-ODBC bridge driver uses ODBC driver to connect to the database.

The JDBC-ODBC bridge driver converts JDBC method calls into the ODBC function calls. Type-1 driver is also called
Universal driver because it can be used to connect to any of the databases.
Example- The JDBC-ODBC Bridge that comes with JDK 1.2 is a good example of this kind of driver.

Advantages:
-easy to use.
-can be easily connected to any database.
Disadvantages:
- Performance degraded because JDBC method call is converted into the ODBC function calls.
-The ODBC driver needs to be installed on the client machine.
2. Type-2 Native-API driver (partially java driver)-
In a Type 2 driver, JDBC API calls are converted into native C/C++ API calls, which are unique to the database.
These drivers are typically provided by the database vendors and used in the same manner as the JDBC-ODBC Bridge. The
vendor-specific driver must be installed on each client machine.
Example- The Oracle Call Interface (OCI) driver is an example of a Type 2 driver.

Advantage:
-performance upgraded than JDBC-ODBC bridge driver.
Disadvantage:
-The Native driver needs to be installed on the each client machine.
-The Vendor client library needs to be installed on client machine.
3. Network Protocol driver (Middleware)
The Network Protocol driver uses middleware (application server) that converts JDBC calls directly
The Network Protocol driver uses middleware (application server) that converts JDBC calls directly or indirectly into
the vendor-specific database protocol. Here all the database connectivity drivers are present in a single server, hence
no need of individual client-side installation.
This kind of driver is extremely flexible, since it requires no code installed on the client and a single driver
can actually provide access to multiple databases.
Advantage:
-No client side library is required because of application server that can perform many tasks like auditing,
load balancing, logging etc.

Disadvantages:
-Network support is required on client machine.
-Requires database-specific coding to be done in the middle tier.
-Maintenance of Network Protocol driver becomes costly because it requires database- specific coding to
be done in the middle tier.
4. Type-4 Thin driver (100% pure java driver)
The thin driver converts JDBC calls directly into the vendor-specific database protocol. It does not require
any native database library, that is why it is also known as Thin Driver.
This is the highest performance driver available for the database and is usually provided by the vendor itself.
This kind of driver is extremely flexible, you don't need to install special software on the client or server. Further, these
drivers can be downloaded dynamically.
Example- MySQL's Connector/J driver is a Type 4 driver.

Advantage:
-Better performance than all other drivers.
-No software is required at client side or server side.
Disadvantage:
-Drivers depends on the Database.

You might also like