What are the different types of drivers used in JDBC? Which driver is used mostly? Explain.

 DBC Drivers Types

JDBC driver implementations vary because of the wide variety of operating systems and hardware platforms in which Java operates. Sun has divided the implementation types into four categories, Types 1, 2, 3, and 4, which is explained below:

Type 1: JDBC-ODBC bridge driver

The JDBC-ODBC bridge driver uses the ODBC driver to connect to the database. The JDBC-ODBC bridge driver converts JDBC method calls into the ODBC function calls. This is now discouraged because of thin driver.



Using ODBC requires configuring on your system a Data Source Name (DSN) that represents the target database. When Java first came out, this was a useful driver because most databases only supported ODBC access but now this type of driver is recommended only for experimental use or when no other alternative is available.

Type 2: Native-API driver

The Native API driver uses the client-side libraries of the database. The driver converts JDBC method calls into native c/c++ calls of the database API, which are unique to the database Vendor-specific driver must be installed on each client machine. If we change the Database we have to change the native API as it is specific to a database and they are mostly obsolete now but we may realize some speed increase with a Type 2 driver, because it eliminates ODBC, overhead.



Type 3: Network Protocol driver

The Network Protocol driver uses middleware (application server) that converts JDBC calls directly or indirectly into the vendor-specific database protocol. It is fully written in java. 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.



Type 4: Thin driver

The thin driver converts JDBC calls directly into the vendor-specific database protocol. That is why it is known as a thin driver. It is fully written in Java language. 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; we don't need to install special software on the client or server. Further, these drivers can be downloaded dynamically.



                                             OR,

JDBC Drivers

JDBC drivers are client-side adapters (installed on the client machine, not on the server) that convert requests from Java programs to a protocol that the DBMS can understand. There are 4 types of JDBC drivers:

Type-1 driver or JDBC-ODBC bridge driver

Type-2 driver or Native-API driver

Type-3 driver or Network Protocol driver

Type-4 driver or Thin driver

Type-1 driver

  • Type-1 driver or 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.
  • As a common driver is used in order to interact with different databases, the data transferred through this driver is not so secured.
  • The ODBC bridge driver is needed to be installed in individual client machines.
  • Type-1 driver isn’t written in java, that’s why it isn’t a portable driver.
  • This driver software is built-in with JDK so no need to install separately.
  • It is a database-independent driver.

Type-2 driver

  • The Native API driver uses the client-side libraries of the database. This driver converts JDBC method calls into native calls of the database API. In order to interact with a different databases, this driver needs their local API, that’s why data transfer is much more secure as compared to type-1 driver.
  • Driver needs to be installed separately in individual client machines
  • The Vendor client library needs to be installed on client machine.
  • Type-2 driver isn’t written in java, that’s why it isn’t a portable driver
  • It is a database-dependent driver.

Type-3 driver

  • 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 for individual client-side installation.
  • Type-3 drivers are fully written in Java, hence they are portable drivers.
  • No client-side library is required because of the application server that can perform many tasks like auditing, load balancing, logging etc.
  • Network support is required on client machine.
  • Maintenance of Network Protocol driver becomes costly because it requires database-specific coding to be done in the middle tier.
  • Switch facility to switch over from one database to another database.

Type-4 driver

  • Type-4 driver is also called native protocol driver. This driver interacts directly with the database. It does not require any native database library, that is why it is also known as Thin Driver.
  • Does not require any native library and Middleware server, so no client-side or server-side installation.
  • It is fully written in Java language, hence they are portable drivers.

Which Driver to use When?

  • If you are accessing one type of database, such as Oracle, Sybase, or IBM, the preferred driver type is type-4.
  • If your Java application is accessing multiple types of databases at the same time, type 3 is the preferred driver.
  • Type 2 drivers are useful in situations, where a type 3 or type 4 driver is not available yet for your database.
  • The type 1 driver is not considered a deployment-level driver, and is typically used for development and testing purposes only.


Comments

Popular posts from this blog

Suppose that a data warehouse for Big-University consists of the following four dimensions: student, course, semester, and instructor, and two measures count and avg_grade. When at the lowest conceptual level (e.g., for a given student, course, semester, and instructor combination), the avg_grade measure stores the actual course grade of the student. At higher conceptual levels, avg_grade stores the average grade for the given combination. a) Draw a snowflake schema diagram for the data warehouse. b) Starting with the base cuboid [student, course, semester, instructor], what specific OLAP operations (e.g., roll-up from semester to year) should one perform in order to list the average grade of CS courses for each BigUniversity student. c) If each dimension has five levels (including all), such as “student < major < status < university < all”, how many cuboids will this cube contain (including the base and apex cuboids)?

Explain Parallel Efficiency of MapReduce.

Suppose that a data warehouse consists of the four dimensions; date, spectator, location, and game, and the two measures, count and charge, where charge is the fee that a spectator pays when watching a game on a given date. Spectators may be students, adults, or seniors, with each category having its own charge rate. a) Draw a star schema diagram for the data b) Starting with the base cuboid [date; spectator; location; game], what specific OLAP operations should perform in order to list the total charge paid by student spectators at GM Place in 2004?