25
JDBC type 2 driver http://rajjdbc.blogspot.in/

2 jdbc drivers

Embed Size (px)

DESCRIPTION

http://rajjdbc.blogspot.in/

Citation preview

Page 1: 2 jdbc drivers

http://rajjdbc.blogspot.in/

JDBC type 2 driver

Page 2: 2 jdbc drivers

http://rajjdbc.blogspot.in/

Page 3: 2 jdbc drivers

http://rajjdbc.blogspot.in/

• JDBC TYPE -2 Driver:• What is JDBC Type-2 Driver?• Ans: Type 2 Driver is a JDBC Driver that converts JDBC API calls to DB Driver Native API Calls.• Architecture: • Fig: Type2Driver1.jpg• This 2 tier architecture, because we have API calls is considered as layer but not tier. Here server

is a tier because it is not part of the client.• Server means which gives the service. Here Database server is giving service like we are storing

the data, and retrieving the data.• Advantages:• Is fast compares to the other type of drivers.• Disadvantages:• It is database dependent (however this is not a big problem in most of the cases)• This driver is partly implemented in java and partly in Native, thus this driver is unsafe to use

unless we are sure that the native implementation is bug free. As any bug in the native code could crash the JVM.

• The Native libraries (i.e: the database client software) is need to be installed in t client machine.

Page 4: 2 jdbc drivers

http://rajjdbc.blogspot.in/

• When to use this type-2 Driver?• Ans:• Is preferred to use in case if the database is

accessed from the server side (Middleware server) application such as a web application as show n in the below architecture:

• CASE 1:• Fig: Type2Driver2.JPG

Page 5: 2 jdbc drivers

http://rajjdbc.blogspot.in/

Fig Type2Driver2.jpg

Page 6: 2 jdbc drivers

http://rajjdbc.blogspot.in/

• CASE 2:• In this example for suppose in a super market

there are several billing machines are available, in each machine standalone software should be installed and all the data should be stored in the Database server, for this purpose Type 2 driver is not recommended.

• • Fig: Type2Driver3.JPG

Page 7: 2 jdbc drivers

http://rajjdbc.blogspot.in/

Fig: Type2Driver3.JPG

Page 8: 2 jdbc drivers

http://rajjdbc.blogspot.in/

• This type of drivers are named as part java, part native drivers.• Example:• The JDBC OCI is a Type 2 driver from Oracle Corporation for accessing

the oracle database server.• This JDBC Driver works with the OCI (Oracle Call Interface) Native

Driver.• The weblogicOCI is a Type-2 driver from BEA system (now this

company is merged into Oracle Corp) for accessing the Oracle DB server.

• This driver also works with the OCI native Driver.• (For example you are a MCA Students (for example WEBLOGICOCI),

and each of student have a unique name or rollnumber( this type -2 driver).

Page 9: 2 jdbc drivers

http://rajjdbc.blogspot.in/

TYPE-4 DRIVER

• What is Type-4 Driver?• Ans:• A JDBC Driver that converts JDBC API calls to

Database Native Network calls is known as JDBC-4 DRIVER.

• Fig: Type4Driver.JPG

Page 10: 2 jdbc drivers

http://rajjdbc.blogspot.in/

Page 11: 2 jdbc drivers

http://rajjdbc.blogspot.in/

• It contains 3 elements, 2 tier architecture and 3 layers.• Advantages:• This is purely implemented in java, thus it is light weight (resource

consumption (ex: memory, time) is less) and portable.• No need of DB client software to install in the client machine.• This is platform independent thus this is the best suitable driver

for the web based application.• Disadvantages: • This type of driver is database dependent.• This type of driver has to implement the database network

protocol so is most likely expected from the database vendor.•

Page 12: 2 jdbc drivers

http://rajjdbc.blogspot.in/

Page 13: 2 jdbc drivers

http://rajjdbc.blogspot.in/

Q: WHEN TO USE Type-4 Driver?

• Note: java performance is totally depends upon JRE.• Ans: This type of driver is suitable in the client side

running applications such as desktop application access DB , and applet.

• However this can be also used in the middleware server running application but would be choice after the type-2 driver.

• Example:• Fig: Type4Driver b.JPG• This type of drivers referred as pure java drivers

Page 14: 2 jdbc drivers

http://rajjdbc.blogspot.in/

Page 15: 2 jdbc drivers

http://rajjdbc.blogspot.in/

Type 3 Driver

• A JDBC Driver that converts JDBC API calls into DATABASE independent network calls is referred as Type-3 Driver.

• Type-4 DRIVER is purely developed in java language as part of this driver the java networking code is provided to communicate with database server.

Page 16: 2 jdbc drivers

http://rajjdbc.blogspot.in/

Page 17: 2 jdbc drivers

http://rajjdbc.blogspot.in/

Advantages of type 3 driver

• Most of times type-3 driver is used as part of the applications which cares about the security.

• This type of JDBC Driver is implemented in 3 tier architecture

• Convenient and applicable to access the database between the networks.

Page 18: 2 jdbc drivers

http://rajjdbc.blogspot.in/

Page 19: 2 jdbc drivers

http://rajjdbc.blogspot.in/

• The database server details such as location and authentication details are not exposed to the client (java application)

• This has an opportunity of managing the db recourses such as connection effectively by reusing them between the clients improving the scalability and reducing the cost.

• Note: this can reduce the cost in case if the application is multiuser and multi-threaded or multiple applications accessing the same database.

• Type 3 Is database independent• Type 3 is pure java driver thus lightweight and portable• Supports conveniently working with distributed transaction.

Page 20: 2 jdbc drivers

http://rajjdbc.blogspot.in/

Disadvantages:

• Having a middleware server and multiple network calls finds costlier in some times (i.e for the application.

• That are not seriously interested with the above listed advantages.

Page 21: 2 jdbc drivers

http://rajjdbc.blogspot.in/

When to use this type of driver?

• Ans: this is the first choice of any java enterprise application. However in case if the applications is really small and does not matter the advantage of this driver then only it looks for Type-2/4.

• (port means receiving the request, sends response, it is just like a door)

Page 22: 2 jdbc drivers

http://rajjdbc.blogspot.in/

• Note:• If you want to communicate with database

server we have only two ways to communicate 1. API calls or 2. Network calls:

Page 23: 2 jdbc drivers

http://rajjdbc.blogspot.in/

Fig: InterfaceDriver.JPG

Page 24: 2 jdbc drivers

http://rajjdbc.blogspot.in/

• • Note: Interface: there are 3 types of interfaces: 1. UI (User Interface)2. API3. Network Interface• Here API Interface and Network Interface are

divided into 2 types:I. Independent II. Dependent.

Page 25: 2 jdbc drivers

http://rajjdbc.blogspot.in/