JDBC_odbc
-
Upload
athul-jayaram -
Category
Documents
-
view
217 -
download
0
Transcript of JDBC_odbc
-
8/19/2019 JDBC_odbc
1/14
What is JDBC Driver ?
JDBC drivers implement the defined interfaces in the JDBC API for
interacting with your database server
!or e"ample# using JDBC drivers enable you to open database connections
and to interact with it by sending $%& or database commands then receiving
results with Java
'he Java.sql pac(age that ships with JD) contains various classes with their
behaviours defined and their actual implementaions are done in third*partydrivers 'hird party vendors implements the java.sql.Driver interface in their
database driver
JDBC Drivers 'ypes+
JDBC driver implementations vary because of the wide variety of operating
systems and hardware platforms in which Java operates $un has divided the
implementation types into four categories# 'ypes ,# -# .# and /# which is
e"plained below+
'ype ,+ JDBC*0DBC Bridge Driver+
In a 'ype , driver# a JDBC bridge is used to access 0DBC drivers installed
on each client machine 1sing 0DBC re2uires configuring on your system a
Data $ource 3ame 4D$35 that represents the target database
When Java first came out# this was a useful driver because most databases
only supported 0DBC access but now this type of driver is recommended
only for e"perimental use or when no other alternative is available
-
8/19/2019 JDBC_odbc
2/14
'he JDBC*0DBC bridge that comes with JD) ,- is a good e"ample of this
(ind of driver
'ype -+ JDBC*3ative API+
In a 'ype - driver# JDBC API calls are converted into native C6C77 API
calls which are uni2ue to the database 'hese drivers typically provided bythe database vendors and used in the same manner as the JDBC*0DBC
Bridge# the vendor*specific driver must be installed on each client machine
If we change the Database we have to change the native API as it is specific
to a database and they are mostly obsolete now but you may reali8e some
speed increase with a 'ype - driver# because it eliminates 0DBC9s overhead
-
8/19/2019 JDBC_odbc
3/14
-
8/19/2019 JDBC_odbc
4/14
'he 0racle Call Interface 40CI5 driver is an e"ample of a 'ype - driver
'ype .+ JDBC*3et pure Java+
In a 'ype . driver# a three*tier approach is used to accessing databases 'he
JDBC clients use standard networ( soc(ets to communicate with anmiddleware application server 'he soc(et information is then translated by
the middleware application server into the call format re2uired by the
DB:$# and forwarded to the database server
'his (ind of driver is e"tremely fle"ible# since it re2uires no code installed
on the client and a single driver can actually provide access to multiple
databases
-
8/19/2019 JDBC_odbc
5/14
;ou can thin( of the application server as a JDBC
-
8/19/2019 JDBC_odbc
6/14
If you are accessing one type of database# such as 0racle# $ybase# or IB:#
the preferred driver type is /
If your Java application is accessing multiple types of databases at the same
time# type . is the preferred driver
'ype - drivers are useful in situations where a type . or type / driver is not
available yet for your database
'he type , driver is not considered a deployment*level driver and is
typically used for development and testing purposes only
JDBC Driver 'ypes
JDBC drivers are divided into four types or levels 'he different types of
dbc drivers are+
'ype ,+ JDBC*0DBC Bridge driver 4Bridge5
'ype -+ 3ative*API6partly Java driver 43ative5
'ype .+ AllJava63et*protocol driver 4:iddleware5'ype /+ All Java63ative*protocol driver 4Pure5
/ types of dbc drivers are elaborated in detail as shown below+
'ype , JDBC Driver
JDBC*0DBC Bridge driver
'he 'ype , driver translates all JDBC calls into 0DBC calls and sends them
to the 0DBC driver 0DBC is a generic API 'he JDBC*0DBC Bridgedriver is recommended only for e"perimental use or when no other
alternative is available
-
8/19/2019 JDBC_odbc
7/14
'ype ,+ JDBC*0DBC Bridge
Advantage
'he JDBC*0DBC Bridge allows access to almost any database# since the
database9s 0DBC drivers are already available
Disadvantages
, $ince the Bridge driver is not written fully in Java# 'ype , drivers are not
portable
- A performance issue is seen as a JDBC call goes through the bridge to the
0DBC driver# then to the database# and this applies even in the reverse
process 'hey are the slowest of all driver types
. 'he client system re2uires the 0DBC Installation to use the driver
/ 3ot good for the Web
'ype - JDBC Driver
3ative*API6partly Java driver
-
8/19/2019 JDBC_odbc
8/14
'he distinctive characteristic of type - dbc drivers are that 'ype - drivers
convert JDBC calls into database*specific calls ie this driver is specific to a
particular database $ome distinctive characteristic of type - dbc drivers are
shown below @"ample+ 0racle will have oracle native api
'ype -+ 3ative api6 Partly Java Driver
Advantage
'he distinctive characteristic of type - dbc drivers are that they are typically
offer better performance than the JDBC*0DBC Bridge as the layers of
communication 4tiers5 are less than that of 'ype
, and also it uses 3ative api which is Database specific
Disadvantage
, 3ative API must be installed in the Client $ystem and hence type -
drivers cannot be used for the Internet
- &i(e 'ype , drivers# its not written in Java &anguage which forms a portability issue
. If we change the Database we have to change the native api as it is
specific to a database
/ :ostly obsolete now
1sually not thread safe
-
8/19/2019 JDBC_odbc
9/14
'ype . JDBC Driver
All Java63et*protocol driver
'ype . database re2uests are passed through the networ( to the middle*tier
server 'he middle*tier then translates the re2uest to the database If themiddle*tier server can in turn use 'ype,# 'ype - or 'ype / drivers
'ype .+ All Java6 3et*Protocol Driver
Advantage
, 'his driver is server*based# so there is no need for any vendor database
library to be present on client machines
- 'his driver is fully written in Java and hence Portable It is suitable for the
web
. 'here are many opportunities to optimi8e portability# performance# and
scalability
/ 'he net protocol can be designed to ma(e the client JDBC driver verysmall and fast to load
'he type . driver typically provides support for features such as caching
4connections# 2uery results# and so on5# load balancing# and advanced
system administration such as logging and auditing
'his driver is very fle"ible allows access to multiple databases using one
driver
-
8/19/2019 JDBC_odbc
10/14
'hey are the most efficient amongst all driver types
Disadvantage
It re2uires another server application to install and maintain 'raversing the
recordset may ta(e longer# since the data comes through the bac(end server
'ype / JDBC Driver
3ative*protocol6all*Java driver
'he 'ype / uses ava networ(ing libraries to communicate directly with the
database server
'ype /+ 3ative*protocol6all*Java driver
Advantage
, 'he maor benefit of using a type / dbc drivers are that they are
completely written in Java to achieve platform independence and eliminate
deployment administration issues It is most suitable for the web
- 3umber of translation layers is very less ie type / JDBC drivers don9t
have to translate database re2uests to 0DBC or a native connectivityinterface or to pass the re2uest on to another server# performance is typically
2uite good
. ;ou dont need to install special software on the client or server !urther#
these drivers can be downloaded dynamically
-
8/19/2019 JDBC_odbc
11/14
Disadvantage
With type / drivers# the user needs a different driver for each database
'ype . driver * the 3etwor(*Protocol Driver
'he JDBC type . driver# also (nown as the networ(*protocol driver is a
database driver implementation which ma(es use of a middle*tier between
the calling program and the database 'he middle*tier 4application server5
converts JDBC calls directly or indirectly into the vendor*specificdatabase protocol
'his differs from the type / driver in that the protocol conversion logic
resides not at the client# but in the middle*tier Eowever# li(e type /
drivers# the type . driver is written entirely in Java
'he same driver can be used for multiple databases It depends on the
number of databases the middleware has been configured to support 'he
type . driver is platform*independent as the platform*related differences
are ta(en care by the middleware Also# ma(ing use of the middleware
provides additional advantages of security and firewall accessA net*protocol fully Java technology*enabled driver translates JDBC API
calls into a DB:$*independent net protocol which is then translated to a
DB:$ protocol by a server 'his net server middleware is able to connect
all of its Java technology*based clients to many different databases 'he
specific protocol used depends on the vendor In general# this is the most
fle"ible JDBC API alternative It is li(ely that all vendors of this solution
-
8/19/2019 JDBC_odbc
12/14
will provide products suitable for Intranet use In order for these products
to also support Internet access they must handle the additional
re2uirements for security# access through firewalls# etc# that the Web
imposes $everal vendors are adding JDBC technology*based drivers to
their e"isting database middleware products
'hese drivers use a networ(ing protocol and middleware to communicate
with a server 'he server then translates the protocol to DB:$ function
calls specific to DB:$
'ype . JDBC drivers are the most fle"ible JDBC solution because they do
not re2uire any native binary code on the client A 'ype . driver does not
need any client installation
!unctions+
, !ollows a three tier communication approach- Can interface to multiple databases * 3ot vendor specific
. 'he JDBC Client driver written in ava# communicates with a
middleware*net*server using a database independent protocol# and
then this net server translates this re2uest into database commands
for that database
/ 'hus the client driver to middleware communication is database
independent
Client *F JDBC Driver *F :iddleware*3et $erver *F Any Database
Advantages
, $ince the communication between client and the middleware server
is database independent# there is no need for the vendor db library
on the client machine Also the client to middleware need9nt be
changed for a new database
- 'he :iddleware $erver 4Can be a full fledged J-@@ Application
server5 can provide typical middleware services li(e caching
4connections# 2uery results# and so on5# load balancing# logging#
auditing etc
. eg for the above include dbc driver features in Weblogic
/ Can be used in internet since there is no client side software needed
At client side a single driver can handle any database4It wor(s
provided the middlware supports that databaseGG5
Disadvantages
-
8/19/2019 JDBC_odbc
13/14
, He2uires database*specific coding to be done in the middle tier
- An e"tra layer added may result in a time*bottlenec( But typically
this is overcome by providing efficient middleware
services described above
'ype / * the 3ative*Protocol Driver
'he JDBC type / driver# also (nown as the native*protocol driver is a
database driver implementation that converts JDBC calls directly into the
vendor*specific database protocol
'he type / driver is written completely in Java and is hence platform
independent It is installed inside the Java irtual :achine of the client It
provides better performance over the type , and - drivers as it does not
have the overhead of conversion of calls into 0DBC or database API calls1nli(e the type , and - drivers# it does not need associated software to
wor(
A native*protocol fully Java technology*enabled driver converts JDBC
technology calls into the networ( protocol used by DB:$s directly 'his
allows a direct call from the client machine to the DB:$ server and is a
practical solution for Intranet access $ince many of these protocols are
proprietary the database vendors themselves will be the primary source for
this style of driver $everal database vendors have these in progress
As the database protocol is vendor*specific# separate drivers# usually
vendor*supplied# need to be used to connect to the database
A 'ype / driver uses Java to implement a DB:$ vendor networ(ing
protocol $ince the protocols are usually proprietary# DB:$ vendors are
generally the only companies providing a 'ype / JDBC driver
'ype / drivers are all Java drivers 'his means that there is no client
installation or configuration Eowever# a 'ype / driver may not be suitablefor some applications if the underlying protocol does not handle issues
such as security and networ( connectivity well
'he IB: 'oolbo" for Java JDBC driver is a 'ype / JDBC driver#
indicating that the API is a pure Java networ(ing protocol driver
-
8/19/2019 JDBC_odbc
14/14
!unctions
, 'ype / drivers are entirely written in Java that communicate directly
with a vendor9s database through soc(et connections 3o translation
or middleware layers# are re2uired# improving performance- 'he driver converts JDBC calls into the vendor*specific database
protocol so that client applications can communicate directly with
the database server
. Completely implemented in Java to achieve platform independence
/ eg include the widely used 0racle thin driver * oracledbcdriver
0racleDriver which connect to dbc+oracle+thin 1H& format
Client :achine *F 3ative protocol JDBC Driver *F Database server
Advantages
'hese drivers don9t translate the re2uests into db re2uest to 0DBC or pass
it to client api for the db# nor do they need a middleware layer for re2uest
indirection 'hus the performance is considerably improved
Disadvantage
At client side# a separate driver is needed for each database