5.1,5.2 Introduction of Database
5.1,5.2 Introduction of Database
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
2. Three-tier model:
4.3 Drivers
Drivers like JDBC, JDBC-ODBC bridge etc which supports connection with various backends from different vendors
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.