Java soft has specified 4 different ways of implementing the jdbc drivers. They are:
- Type I driver or JDBC-ODBC Bridge Driver
In these drivers "C" code will be used to call the "odbc" functions. In this case, for most of the
data base we need to install:
- Java classes
- Database specific client software
- Odbc driver for that database
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("jdbc:odbc:osdn","hr","hr");
-
Type II driver or JDBC-Native API Driver
The implementation of jdbc driver internally uses the native API specific to the database. In this case part
of code will be in java and another part of code will be in C/C++ language. If we need to use type II driver,
we need to install the jar files which contains the java code plus data base specific client software that
contains native API. In this case if there are more machines lot of time has to be spent in configuring
client software. The Oracle Call Interface (OCI) driver is an example of a Type 2 driver. A sample connection
code is given below:
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); Connection conn = DriverManager.getConnection("jdbc:oracle:oci8@xyz","hr","hr");
Note:- xyz is called as net service name and it will be internally used by the C/C++ code. -
Type IV driver or Pure java Driver:
The implementors of this driver, implements the whole code in java language. So, we need not use any additional
softwares like ODBC driver or data base client specific software. Oracle corp. has provided classes12.jar which
is a type IV driver. Configuring type IV driver is easy as we need to copy the above jar file to our classpath.
Class.forName("oracle.jdbc.driver.OracleDriver"); conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","hr","hr");
- Type III driver or JDBC-Net pure Java: Type III drivers are implemented completely in java, but these drivers will not be contacting the database server directly. The vendors of type III drivers apart from providing the jar files they provide a server which is known as "Net server". In this case the jdbc driver talks to a intermediate net server and the net server talks to the database. As there is an intermediate server the performance of these drivers will be less compared to type IV driver.
No comments:
Post a Comment