What is JDBC Driver?
JDBC drivers execute the characterized interfaces in the JDBC API, for associating with your database server.
For model, utilizing JDBC drivers empower you to open database associations and to interface with it by sending SQL or database directions at that point getting results with Java.
The Java.sql bundle that ships with JDK, contains different classes with their practices characterized and their genuine implementaions are done in outsider drivers. Outsider sellers executes the java.sql.Driver interface in their database driver.
JDBC Drivers Types
JDBC driver executions fluctuate due to the wide assortment of working frameworks and equipment stages in which Java works. Sun has isolated the execution types into four classes, Types 1, 2, 3, and 4, which is clarified beneath −
Type 1: JDBC-ODBC Bridge Driver
In a Type 1 driver, a JDBC connect is utilized to get to ODBC drivers introduced on every customer machine. Utilizing ODBC, requires arranging on your framework a Data Source Name (DSN) that speaks to the objective database.
When Java previously turned out, this was a helpful driver on the grounds that most databases just bolstered ODBC get to however at this point this kind of driver is suggested just for test use or when no other option is available.
The JDBC-ODBC Bridge that accompanies JDK 1.2 is a genuine case of this sort of driver.
Type 2: JDBC-Native API
In a Type 2 driver, JDBC API calls are changed over into local C/C++ API calls, which are novel to the database. These drivers are commonly given by the database merchants and utilized in indistinguishable way from the JDBC-ODBC Bridge. The merchant explicit driver must be introduced on every customer machine.
If we change the Database, we need to change the local API, as it is explicit to a database and they are for the most part out of date now, yet you may understand some speed increment with a Type 2 driver, since it wipes out ODBC's overhead.
The Oracle Call Interface (OCI) driver is a case of a Type 2 driver.
Type 3: JDBC-Net unadulterated Java
In a Type 3 driver, a three-level methodology is utilized to get to databases. The JDBC customers utilize standard system attachments to speak with a middleware application server. The attachment data is then deciphered by the middleware application server into the call group required by the DBMS, and sent to the database server.
This sort of driver is incredibly adaptable, since it requires no code introduced on the customer and a solitary driver can really give access to various databases.
You can think about the application server as a JDBC "intermediary," implying that it makes requires the customer application. Subsequently, you need some learning of the application server's arrangement so as to adequately utilize this driver type.
Your application server may utilize a Type 1, 2, or 4 driver to speak with the database, understanding the subtleties will demonstrate helpful.
Type 4: 100% Pure Java
In a Type 4 driver, an unadulterated Java-based driver discusses straightforwardly with the seller's database through attachment association. This is the most astounding execution driver accessible for the database and is generally given by the seller itself.
This sort of driver is amazingly adaptable, you don't have to introduce uncommon programming on the customer or server. Further, these drivers can be downloaded dynamically.
MySQL's Connector/J driver is a Type 4 driver. Due to the exclusive idea of their system conventions, database merchants for the most part supply type 4 drivers.
Which Driver ought to be Used?
If you are getting to one sort of database, for example, Oracle, Sybase, or IBM, the favored driver type is 4.
If your Java application is getting to various kinds of databases in the meantime, type 3 is the favored driver.
Type 2 drivers are helpful in circumstances, where a sort 3 or sort 4 driver isn't accessible yet for your database.
The type 1 driver isn't viewed as an organization level driver, and is commonly utilized for improvement and testing purposes only.