Difference betwixt Type 1, 2, iii as well as four JDBC Driver inwards Java?

One of the oldest Java interview query is what is the divergence betwixt dissimilar types of JDBC drivers e.g. what is the divergence betwixt type 1, type 2, type three or type iv drivers? Sometimes also asked equally how exercise yous conduct betwixt dissimilar JDBC driver? When to role type three over type iv driver etc. It's 2015 directly in addition to I dubiety anyone is using JDBC driver other than type iv for connecting to database, but let's encounter how to respond this query when yous confront it during the interview. The divergence betwixt dissimilar types of JDBC driver comes from the fact how they work, which is basically driven past times 2 factors, portability, in addition to performance. Type 1 JDBC driver is the poorest inwards damage of portability in addition to surgical physical care for piece type iv JDBC driver is highly portable in addition to gives the best performance. You volition larn to a greater extent than differences betwixt dissimilar JDBC drivers equally nosotros become along.

Since the database is really of import in addition to almost all Java application uses the database inwards closed to shape or other, it's of import to larn JDBC well. If yous are a beginner started to larn Java in addition to struggling with JDBC in addition to so I propose yous to receive got a expect at Practical Database Programming with Java By Ying Bai. It's i of the rarest book, which covers Java database connectivity well,



What is JDBC Driver inwards Java?

H5N1 driver is nix but software required to connect to a database from Java program. JDBC is but an API, which Java has designed in addition to onus to implement this API lies on dissimilar vendor because dissimilar database plant inwards a dissimilar way, they internally role dissimilar protocols.


So MySQL gives its ain implementation of JDBC, nosotros telephone phone it MySQL JDBC driver in addition to nosotros role it when nosotros desire to connect to MySQL database from Java program. Similarly Oracle, SQL SERVER, Sybase in addition to PostgreSQL has provided their ain implementation of JDBC API to connect them. Since Java programme uses JDBC API, they are portable across dissimilar database, all yous demand to exercise is modify the JDBC driver, which is but a JAR file if yous are using type iv JDBC driver.

By the way, migrating to database is non equally easy, particularly if yous are using whatever proprietary characteristic of database, but if yous ANSI SQL in addition to non using whatever database specific feature, its easy.


How many drivers are at that spot inwards JDBC?

There are full iv types of JDBC drivers exists inwards Java. They are known equally type 1, 2, 3, in addition to iv drivers. In companionship to empathize divergence betwixt dissimilar JDBC drivers, start in addition to most of import affair to empathize is why Java has so many types of JDBC drivers? Why non but one? the respond lies inwards portability in addition to performance. The start JDBC driver is known equally type 1 JDBC driver in addition to the most recent i is known equally type iv JDBC driver. There has been closed to beak virtually type five JDBC driver but I receive got non heard anything concrete virtually it from Oracle or whatever other reliable source. So, type iv JDBC driver is even so the latest one.

 One of the oldest Java interview query is what is the divergence betwixt dissimilar typ Difference betwixt Type 1, 2, three in addition to iv JDBC Driver inwards Java?

What is type 1 driver inwards JDBC?

This is the oldest JDBC driver, by in addition to large used to connect database similar MS Access from Microsoft Windows operating system. Type 1 JDBC driver genuinely interpret JDBC calls into ODBC (Object Database connectivity) calls, which inwards plough connects to database. Since it acts equally pair betwixt JDBC in addition to ODBC, it is also known equally JDBC ODBC pair driver. This driver had really piteous surgical physical care for because of several layers of translation which took house earlier your programme connects to database. It has also less portable because it relies on ODBC driver to connect to database which is platform dependent. It is directly obsolete in addition to alone used for evolution in addition to testing, I approximate Java vii fifty-fifty removed this driver from JDK.


What is type 2 driver inwards JDBC?

This was the instant JDBC driver introduced past times Java afterward Type 1, thence it known equally type 2. In this driver, surgical physical care for was improved past times reducing communication layer. Instead of talking to ODBC driver, JDBC driver direct talks to DB customer using native API. That's why its also known equally native API or partly Java driver. Since it required native API to connect to DB customer it is also less portable in addition to platform dependent. If native library e.g. ocijdbc11.dll, which is required to connect Oracle 11g database is non nowadays inwards customer machine in addition to so yous volition get java.lang.UnsatisfiedLinkError: no dll inwards java.library.path error.  Performance of type 2 driver is slightly ameliorate than type 1 JDBC driver.


What is type three driver inwards JDBC?

This was the 3rd JDBC driver introduced past times Java, thence known equally type 3. It was really dissimilar than type 1 in addition to type 2 JDBC driver inwards feel that it was completely written inwards Java equally opposed to previous 2 drivers which were non written inwards Java. That's why this is also known equally all Java driver. This driver uses three tier approach i.e. client, server in addition to database. So yous receive got a Java customer talking to a Java server in addition to Java Server talking to database. Java customer in addition to server beak to each other using cyberspace protocol thence this type of JDBC driver is also known equally Net protocol JDBC driver. This driver never gained popularity because database vendor was reluctant to rewrite their existing native library which was mainly inwards C in addition to C++


What is type iv JDBC driver?

This is the driver yous are most probable using to connect to modern database similar Oracle, SQL Server, MySQL, SQLLite in addition to PostgreSQL. This driver is implemented inwards Java in addition to direct speaks to database using its native protocol. This driver includes all database telephone phone inwards i JAR file, which makes it really slow to use. All yous demand to exercise to connect a database from Java programme is to include JAR file of relevant JDBC driver. Because of lite weight, this is also known equally sparse JDBC driver. Since this driver is also written inwards pure Java, its portable across all platform, which agency yous tin role same JAR file to connect to MySQL fifty-fifty if your Java programme is running on Windows, Linux or Solaris. Performance of this type of JDBC driver is also best with all of them because database vendor liked this type in addition to all enhancement they brand they also port for type iv drivers.


Difference betwixt type 1 in addition to type 2 JDBC driver?

Though both type 1 in addition to type 2 drivers are non written inwards Java, at that spot was closed to pregnant divergence betwixt them. Type 2 driver has ameliorate surgical physical care for than type 1 driver because of less layer of communication in addition to translation. As opposed to type 1 JDBC driver, inwards which JDBC calls are translated into ODBC calls earlier they become to database, type 2 JDBC driver direct connect to db customer using native library.


Difference betwixt type 2 in addition to type three JDBC driver?

Main divergence betwixt type 2 in addition to type three JDBC driver is that equally opposed to type 2 driver, type three is completely written inwards Java. Another divergence which comes from this fact is that type three driver is to a greater extent than portable than type 1 in addition to type 2 drivers because it doesn't require whatever native library on customer side to connect to database. In damage of architecture, this was three tier architecture in addition to uses cyberspace protocol for customer server communication.


Difference betwixt type three in addition to type iv JDBC driver?

Main divergence betwixt type three in addition to type iv JDBC driver was removal of three tier architecture. Type iv JDBC driver direct connect to database using their native protocol equally opposed to cyberspace protocol used past times type three driver. Though both type three in addition to type iv driver is written inwards Java. Another primal divergence is ease of use, type iv drivers but require i JAR file into classpath inwards companionship to connect to db. Performance of type iv JDBC driver is also ameliorate than type three driver because of direct connectivity to database equally opposed to three tier architecture of type three driver.


When to role dissimilar types of JDBC driver?

You should e'er role type iv JDBC driver, at that spot is hardly whatever province of affairs when yous demand to become to previous version of JDBC driver. Though, if yous desire to connect to Oracle database using TNS elevate using OCI client, yous demand to role type 2 JDBC driver also known equally thick JDBC driver. That requires database native customer library e.g. ocijdbc11.dll and if that's non nowadays inwards the machine in addition to so your Java programme volition throw java.lang.unsatisfiedlinkerror no ocijdbc11 inwards java.library.path error at run time. 



That's all virtually difference betwixt type 1, 2, 3, in addition to type three JDBC driver inwards Java. JDBC drivers are evolved inwards Java from less portable to most portable in addition to from depression surgical physical care for to high performance. Type 1 JDBC driver is the oldest piece type iv JDBC driver is the latest. In existent world, yous volition endure by in addition to large probable using type iv JDBC driver, which is bundled inwards a JAR file. Just brand certain to lay them into your Java application's classpath when yous connect to database from Java program.

Recommended books to Learn Java Database Connectivity for beginners :

  • Core Java Volume 2 - Advanced characteristic ninth Edition By Cay S. Horstmann (check here)
  • Java: H5N1 Beginner's Guide past times Herbert Schildt (check here)
  • Practical Database Programming with Java By Ying Bai

Subscribe to receive free email updates:

0 Response to "Difference betwixt Type 1, 2, iii as well as four JDBC Driver inwards Java?"

Posting Komentar