JDBC Tutorial


In order to avoid the disadvantages of Type-1 drivers, we have to deal with Type-4 drivers.

Disadvantages of Type-1:

  1. Since, it is developed in 'C' language; this type of driver is treated as platform dependent.
  2. These are a waste of memory space. Since, we are creating a DSN (Data Source Name) for each and every database connection and it leads to less performance.
  3. We are unable to develop 3-tier applications.

Advantages of Type-4:

  1. This driver gives affective performance for every jdbc application. Since, there is no DSN.
  2. Since, this driver is developed in java by database vendors, internally JVM need not to convert platform dependent to platform independent.

The only disadvantage of Type-4 is we are unable to develop 3-tier applications.

Type-4 drivers are supplied by Oracle Corporation by developing into java language. OracleDriver is the name of Type-4 driver which is released by Oracle Corporation in the form of classes111.jar

Abstract class

When we want to make use of Type-4 driver as a part of a java program, we must first set classpath for oracle driver by using the following:

set CLASSPATH=C:\oracle\ora92\jdbc\lib\classes111.jar;.;
Oracle data base connection

For example:

Class.forName ("oracle.jdbc.driver.OracleDriver");

In order to obtain the connection from oracle database we must follow the following syntax:

For example:

Connection con=DriverManager.getConnection ("jdbc : oracle : thin :@ localhost : 1521 : pskills", "scott", "tiger")

In order to obtain port number and service ID of oracle database we must look for tnsnames.ora which is found in C:\oracle\ora92\network\admin