Wednesday, December 11, 2019

Difference Betwixt Type 1, 2, Three As Well As Four Jdbc Driver Inwards Java?

One of the oldest Java interview inquiry is what is the departure betwixt unlike types of JDBC drivers e.g. what is the departure betwixt type 1, type 2, type iii or type four drivers? Sometimes also asked equally how practise y'all direct betwixt unlike JDBC driver? When to purpose type iii over type four driver etc. It's 2015 straight off in addition to I dubiety anyone is using JDBC driver other than type four for connecting to database, but let's come across how to answer this inquiry when y'all facial expression upward it during the interview. The departure betwixt unlike 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 price of portability in addition to functioning spell type four JDBC driver is highly portable in addition to gives the best performance. You volition larn to a greater extent than differences betwixt unlike JDBC drivers equally nosotros acquire along.

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



What is JDBC Driver inwards Java?

Influenza A virus subtype H5N1 driver is nil but software required to connect to a database from Java program. JDBC is only an API, which Java has designed in addition to onus to implement this API lies on unlike vendor because unlike database plant inwards a unlike way, they internally purpose unlike protocols.



So MySQL gives its ain implementation of JDBC, nosotros telephone band it MySQL JDBC driver in addition to nosotros purpose 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 unlike database, all y'all demand to practise is modify the JDBC driver, which is only a JAR file if y'all are using type four JDBC driver.

By the way, migrating to database is non equally easy, peculiarly if y'all are using whatever proprietary characteristic of database, but if y'all 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 four types of JDBC drivers exists inwards Java. They are known equally type 1, 2, 3, in addition to four drivers. In corporation to sympathise departure betwixt unlike JDBC drivers, commencement in addition to most of import matter to sympathise is why Java has so many types of JDBC drivers? Why non only one? the answer lies inwards portability in addition to performance. The commencement JDBC driver is known equally type 1 JDBC driver in addition to the most recent i is known equally type four JDBC driver. There has been approximately utter almost type v JDBC driver but I receive got non heard anything concrete almost it from Oracle or whatever other reliable source. So, type four JDBC driver is yet the latest one.

 One of the oldest Java interview inquiry is what is the departure betwixt unlike typ Difference betwixt Type 1, 2, iii in addition to four 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 twain betwixt JDBC in addition to ODBC, it is also known equally JDBC ODBC twain driver. This driver had really piteous functioning 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 straight off obsolete in addition to solely used for evolution in addition to testing, I guess Java seven fifty-fifty removed this driver from JDK.


What is type 2 driver inwards JDBC?

This was the mo JDBC driver introduced past times Java afterwards Type 1, therefore it known equally type 2. In this driver, functioning was improved past times reducing communication layer. Instead of talking to ODBC driver, JDBC driver straight 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 car in addition to so y'all volition get java.lang.UnsatisfiedLinkError: no dll inwards java.library.path error.  Performance of type 2 driver is slightly meliorate than type 1 JDBC driver.


What is type iii driver inwards JDBC?

This was the 3rd JDBC driver introduced past times Java, therefore known equally type 3. It was really unlike 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 iii tier approach i.e. client, server in addition to database. So y'all receive got a Java customer talking to a Java server in addition to Java Server talking to database. Java customer in addition to server utter to each other using internet protocol therefore 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 four JDBC driver?

This is the driver y'all 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 straight speaks to database using its native protocol. This driver includes all database telephone band inwards i JAR file, which makes it really tardily to use. All y'all demand to practise to connect a database from Java programme is to include JAR file of relevant JDBC driver. Because of low-cal 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 y'all tin flame purpose 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 amid all of them because database vendor liked this type in addition to all enhancement they brand they also port for type four 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 approximately pregnant departure betwixt them. Type 2 driver has meliorate functioning 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 acquire to database, type 2 JDBC driver straight connect to db customer using native library.


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

Main departure betwixt type 2 in addition to type iii JDBC driver is that equally opposed to type 2 driver, type iii is completely written inwards Java. Another departure which comes from this fact is that type iii 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 price of architecture, this was iii tier architecture in addition to uses internet protocol for customer server communication.


Difference betwixt type iii in addition to type four JDBC driver?

Main departure betwixt type iii in addition to type four JDBC driver was removal of iii tier architecture. Type four JDBC driver straight connect to database using their native protocol equally opposed to internet protocol used past times type iii driver. Though both type iii in addition to type four driver is written inwards Java. Another primal departure is ease of use, type four drivers only require i JAR file into classpath inwards corporation to connect to db. Performance of type four JDBC driver is also meliorate than type iii driver because of direct connectivity to database equally opposed to iii tier architecture of type iii driver.


When to purpose unlike types of JDBC driver?

You should ever purpose type four JDBC driver, at that spot is hardly whatever province of affairs when y'all demand to acquire to previous version of JDBC driver. Though, if y'all desire to connect to Oracle database using TNS lift using OCI client, y'all demand to purpose 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 car 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 almost difference betwixt type 1, 2, 3, in addition to type iii JDBC driver inwards Java. JDBC drivers are evolved inwards Java from less portable to most portable in addition to from depression functioning to high performance. Type 1 JDBC driver is the oldest spell type four JDBC driver is the latest. In existent world, y'all volition last by in addition to large probable using type four JDBC driver, which is bundled inwards a JAR file. Just brand certain to pose them into your Java application's classpath when y'all connect to database from Java program.

Further Learning
JSP, Servlets in addition to JDBC for Beginners: Build a Database App
Complete JDBC Programming Part 1 in addition to 2
Java Platform: Working alongside Databases Using JDBC

Recommended books to Learn Java Database Connectivity for beginners :

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

No comments:

Post a Comment