To connect to a database using Java, most of us use JDBC API.
We normally include driver like ojdbc14
(Intended for Java 1.4) in class path, and in pro
The "type" refers to how the driver implements the API. The four types are:
Type 1: JDBC-ODBC Bridge driver (Bridge)
Type 2: Native-API/partly Java driver (Native)
Type 3: AllJava/Net-protocol driver (Middleware)
Type 4: All Java/Native-protocol driver (Pure)
They will have different performance characteristics. See this link for a more detailed review.
+------+---------------------------------+-------------------------------------------------------------------------------------------+
| Type | Driver | Descripiton |
+------+---------------------------------+-------------------------------------------------------------------------------------------+
| 1 | JDBC-ODBC Bridge (bridge) | Translates all JDBC calls into ODBC calls. |
| 2 | Native API (native) | Translates all JDBC calls into native API database calls. (e.g: DLL on windows using JNI) |
| 3 | Network Protocol(middleware) | Translates all JDBC calls into database independent middleware specific calls. |
| 4 | Native Protocol(pure java thin) | Translates all JDBC calls directly into database calls. |
+------+---------------------------------+-------------------------------------------------------------------------------------------+
In simple terms
Type1:(JDBC-ODBC Bridge driver)
->it uses ODBC
->converts JDBC calls into ODBC calls
->its disadvantages are you need to install ODBC or you can say it depends on ODBC(given by microsoft)
->its performance is low because it converts JDBC calls into ODBC calls
Type2(Native API)
->uses client side libraries of database
->converts JDBC calls into native calls of the database Api
->gives better performance than JDBC-ODBC(Type1) because it does not depends or it does not use ODBC
Type3(Network Protocol)
->it uses Application Server(Middleware)
->server converts the jdbc calls into vendor specific database protocol
->Network support is required on client side
->Maintenance of Network Protocol driver becomes costly
Type4(Thin)
->interacts dierectly with database
->does not require any libraries
->written by database vendors ,hence they are best to use
you are using the jdbc interface from java.sql classes, so the type of driver will not have any logic impact in your code, it will only have runtime / deployment impact.
You are also using the ojdb14.jar from Oracle, probably with a "thin" jdbc configuration, which means you are using a type-4 driver configuration. With such a configuration, you will only need to deploy the JDBC jar file with your database accessing program.
The other options include a JDBC bridge, which really means an ODBC connection wrapped in JDBC clothing. This means you would have to configure your system for correct ODBC function, and then use a JAR file to access ODBC. Due to the extra "hop" of data through ODBC, one would expect it to be a bit slower than a type-4 access; however, there is a possibility that the ODBC is optimized to such a great extent for a particular situation, that the extra hop is negligible. As with most performance concerns, the truth is discovered by testing (in your environment).
The type-2 drivers again use a Java (JDBC) API; however, they bridge the calls into a C or C++ style shared library, which then handles the real connection. If the driver is optimized to be so fast that the JNI setup / tear down calls are negligible in cost, then perhaps it might outperform type-4 drivers.
Type 3 drivers basically proxy (or relay) the request to another network resource. That typically incurs an extra network hit, but again, that doesn't say much about actual performance.
Type 4 drivers are the ones you probably want to stick with. The Java program connects directly to the database, meaning that if there is a problem, it will be captured entirely within the JVM of the program making the connection (type 1, it's in the ODBC layer, type 2 it's in the native compiled code, type 3 it's in the remote network proxy).
Again none of this has to do with functionality; however, they all impact how to deploy, how to debug, and how to configure the database connection.
ojdbc14.jar
: Provides jdbc driver which will help you to connect to DB.
java.sql.*
: Provides you apis to query data in DB and needs a DB connection to do that which is where driver helps.
SO they have different roles to play and both are needed to talk to database.
Coming to type of drivers, well its different ways in which they interact with DB which classifies them but ultimately aim is same i.e. to connect to DB.
Types of drivers are explained in detail here: http://en.wikipedia.org/wiki/JDBC_driver