Вы находитесь на странице: 1из 10

Type I driver

Driver Name Vendor Software JDBC ODBC driver Sun & Intersolv For ODBC: Microsft front/back office product supplies ODBC drivers for few DBs like ACCESS, Oracle, SQL Server, Excel, Visual Faxpro etc and for DBs like MySQL, Pointbase, Interbase, Sybase, Ingres and DB2 the ODBC driver software will be supplied by the DB vendors only For JDBC: JDK 1.1 & above (JDK 1.1.1 - 1.1.8, J2SDK 1.2.0 - J2SDK 1.5.0) C:\WINNT;C:\WINNT\System32;D:\J2SDK1.4.2_03\bin (Note: WINNT\System32 directory contains ODBC32.dll file) d:\j2sdk1.4.2_04\jre\lib\rt.jar sun.jdbc.odbc:JdbcOdbcDriver jdbc:odbc:mysqlDSN / jdbc:odbc:oracleDSN

Env Settings PATH




Number of layers and APIs: 4 Layers (JDBC App-> JDBCODBC Driver -> ODBC Driver-> DB)'
JAVA Requests Native Requests


Pros: Suitable on all Windows OS Easy to use and maintain

Cons: Doesn't work on non-Windows OS Compared with type II driver performance is little bit slow, but negligible Restricted to connect to only local or local N/W DB Number of layers and APIs: 3 APIs (JDBC API, ODBC API, SPI - Service Provider Interface) Partly Java & Partly native on client - Pure native API on server (Client/server won't come into picture because this driver is mostly used in standalone applications) No of Layers & API used

Creating MySQL DSN in 32 bit ODBC Drivers List

JDBC Program to access DB

import java.sql.*; public class Flight_Master { public static void main(String rags[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:mysqlDSN"); System.out.println("Connection Created as........"+con); System.out.println("Retreiving FlightDetails........"); Thread.currentThread().sleep(1000); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from flight_master"); while( rs.next()) { System.out.println(rs.getString(1)+"...."+rs.getString(2)+"...."+rs.get String(3)+"...."+rs.getString(4)); Thread.currentThread().sleep(500); } rs.close(); stmt.close(); con.close(); } catch(Exception e){e.printStackTrace();} }//main() }//class()

Create Table and Insert Records into the Table:

create table flight_master(flight_ID text,airlines_ID text,Sairport_ID text,Dairport_ID text); insert into flight_master values('IC_123','IA','VOHY','VEVZ'); insert into flight_master values('IC_124','IA','VEVZ','VOHY'); insert into flight_master values('IC_125','IA','VOHY','VOBG'); insert into flight_master values('IC_126','IA','VOBG','VOHY'); insert into flight_master values('DC_001','DA','VOHY','VIDP'); insert into flight_master values('DC_002','DA','VIDP','VOHY'); insert into flight_master values('AI_201','AI','VOHY','VABB'); insert into flight_master values('AI_202','AI','VABB','VOHY');

To Run JDBC Driver:

c:\> javac Flight_Master.java c:\> java Flight_Master Connection Created as........sun.jdbc.odbc.JdbcOdbcConnection@19f953d Retreiving FlightDetails............................................. IC_123....IA....VOHY....VEVZ IC_124....IA....VEVZ....VOHY IC_125....IA....VOHY....VOBG IC_126....IA....VOBG....VOHY DC_001....DA....VOHY....VIDP DC_002....DA....VIDP....VOHY AI_201....AI....VOHY....VABB AI_202....AI....VABB....VOHY

Type II driver
Driver Name Vendor Software Java-Native API driver Database (Ex: Oracle) Database (Ex: Oracle) Oracle Server installation on Server system Oracle client installation on Client system d:\Oracle\Ora81\bin d:\Oracle\Ora81\jdbc\lib\classes111.zip oracle.jdbc.driver.OracleDriver jdbc:oracle:oci8:@tnsname

Env Settings PATH CLASSPATH Driver URL



Request to Server Socket

Oracle CLI API

Request to Socket

JAVA Requests

Faster than all remaining 3 JDBC drivers Native Native N/W Portable to all OS Requests Requests

Native Request

Cons: Maintanance is costlier because fault finding is difficult to dealing with native libraries Suitable to all types of Java applications (Standalone, Web, Distributed, Enterprise and Integration) except Applets Recommended not to connect to remote DBs (reasons explained in the session)
Number of layers and APIs:

5 Layers (JDBC App-> Oracle Driver -> SQL * Net libraries (aka Oracle Client system native libraries/Socket program running on client system)-> TNSListener (ServerSocket running for Oracle on port number 1521) using oracle CLI-> DB) 4 APIs (JDBC API, CLI Client libraries, Socket API, CLI Server libraries) Partly Java & Partly native on client - Pure native API on server

Type III driver

Driver Name Vendor Software Java Net Driver Third party vendor like Intersolv (www.intersolv.com) IDS Server installation on DB server system IDS java libraries must be copied on to client system (jdk14drv.jar)

Env Settings PATH CLASSPATH Driver URL

D:\IDSServer\classes\jdk14drv.jar ids.sql.IDSDriver jdbc:ids://abc:12/conn?dsn='SysOracleDSN' (or) jdbc:ids://abc:12/conn?dsn='SysMySQLDSN'


Pros: This option is suitable when Type II & Type IV are not present Suitable to connect to WWW system databases also More suitable to Applets when they are connecting the DB because no native libraries need to be installed on client system

Cons: Relying on third party driver vendor This driver execution is slow when compared with Type I & II

Number of layers and APIs:

5 Layers (JDBC App-> IDS Driver class (uses Client Socket program)-> IDS Server (Server socket program)-> ODBC Software-> DB 4 APIs (JDBC API, IDS API uses Socket API, ODBC API, SPI) Purely Java on client - Pure native API on server

Type IV driver
Driver Name Vendor Software Java Native protocol driver DB (Oracle/MySQL) DB (Oracle/MySQL) Server software installation on server No client software installation is required on client system except required java libraries (classes111.zip)

Env Settings PATH CLASSPATH Driver URL

d:\Oracle\Ora81\jdbc\lib\classes111.zip oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:@host:1521:SID


Pros: Light weight driver, so that no DB native libraries need to be installed on client system Comes with DB installation

Cons: Slower in execution compared with Type II and Type I but faster than III Number of layers and APIs: 4 Layers (JDBC App, Oracle Driver (uses client socket API of java), TNSListener (Server socket program written in C language), DB) 3 APIs (JDBC API, Socket API, Oracle CLI) Purely Java on client - Pure native API on server