[go: up one dir, main page]

0% found this document useful (0 votes)
75 views23 pages

JDBC 1

1) The document discusses Java Database Connectivity (JDBC) and how Java objects can connect to and interact with various database management systems (DBMS) like Oracle, Sybase, etc. 2) It introduces the concept of a JDBC driver which translates JDBC method calls into DBMS-specific SQL statements. This allows Java applications to work with different DBMS without rewriting the data access code. 3) The challenge was to develop a JDBC driver interface that is independent of the underlying DBMS. This led to the creation of the generic JDBC driver by Microsoft which translates JDBC calls into a format understood by the target DBMS.

Uploaded by

karanrjoshi2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views23 pages

JDBC 1

1) The document discusses Java Database Connectivity (JDBC) and how Java objects can connect to and interact with various database management systems (DBMS) like Oracle, Sybase, etc. 2) It introduces the concept of a JDBC driver which translates JDBC method calls into DBMS-specific SQL statements. This allows Java applications to work with different DBMS without rewriting the data access code. 3) The challenge was to develop a JDBC driver interface that is independent of the underlying DBMS. This led to the creation of the generic JDBC driver by Microsoft which translates JDBC calls into a format understood by the target DBMS.

Uploaded by

karanrjoshi2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

3pBC.

DDBC
Unt

AP2
Ttodwkon:
Evey J2EE appl'akan Saves rebuevens wamipulateo
a
iohmahan sloed in dataase wsing web servies
povded by a gzcE Conmponent

objec
to a
Jaua datt objeth haue methods that pena cnneekon
wanapeme yatem (osms) s dhen tnamit
database ldeet oala
inset veene,
modyy
memapes (queies)
a dotokase.
Šhoed in do dend
Connecha
- Iheoßms wse the Aae These mmmapes conin
bock to he oEE Conpmet. Comfonent/igomatim
by I JaEt
data vegueteol

used to nteroet uth ciaadat '


-Jaua data cjecs Ce 96ms.
2Ee Component by Ihu
Yehned do he

- JBMs o Sybase,nt
covnmercialy avasabl ! OYach,B62,
challege Sum an l9 905 : Sevelop a lay f jaa
popua
wwte high code that acenses all
ded
dauops to
Leslet ado DßMs's.
D6Ms
obshade: Lanupe balieA. Eoh
Les cala soed
uiten Cowuniak
o
code
in iti data hanes. je. banelaoleuel
miplt eed fo be to
veuuitten
uth ta oYacle data
aLLe a D82 dataase.
02

e gs8¢
met The challeyge wits the eahon
-To l336
by Sum Mitvosyolemy
ne.
The gRsc dhinen deuekpel
-th a Apeckeaton trat
isUl. nchonalty itaas
dierdeail JAsc duier
desev bed h da
tms wamuphes thidl paty verds aene Aum
at Coryneo to
en couraped to bud Jßc diveyThose
speciaos. wstat bud
Mrosyotems, nts,
neA.

Tok Gsc daivesathi podto


Couldl tayp
io Ika glauing
Jaua oppli cakon eket.
a Feßc dive do be a tamatd
fhe Apeifkaios veqed mesepesto
louw leuel opieay BMS Jo
drat covenked Re TABC APZ vee vea.
deuel memales undesto od by
propAammws Cald
wwe hiphlwel aua dat
Jua ate APT to
a Yauine
cajeta dened in t Tesc
that intere th he AMS. lous keuel
Conveut the Yauhing io
Jaa datt ojecs do the Jese diver
peicahon
weMape dhat onfy
S denal them to th Jose chive.
Youie ino lowleul
diver tamlateo the
The
Jsc
memaps that ane wnletood & pvocemed by thesns
wantuhunes haue to:
Creattd by ms
de8c dhires
pen o Gannecon bl Iha BMS JEE Gneyent. &

Hos cG) ramateow euiventi sQL Waleent;


dol
ti gatE Compoet
sent by
winto wessofes tet cam
be proceme, by ha
SsMs.
close

JOsL duVeA.
03

(d) Rehn iomalim Deh as mnesapes


esrd thal onyoyto la
JBe bpecicahion to tha
gac dive.
(e) provioe Komota wanalement
vahns that Coomoto te

Jhe Jo1sc. duve makes FaEE Coponento daase inolependert


oxhrch Coplemento fosas philosvphy platen &dperdln

daiver to the MS
itout Validahon. e. ei i Ia
Yerpomly ka
8ms do twplenent cal Aatement
Cantained in te qe

-Jesc duien peeyicohin clames goßc duvens


ito fo

- goup' vehMR to
fh
ane a Jallouo:
>open Baaane Canmecho

O. ypel8c to08tc AriVe


was the Comymyto douwCe a aay to reate a
--MeroSot fist them They created the aoßc.
data base prgiam
Sns indegemont
Jaßc.

API.
-The gsLe do o8ße dive alho caled tha cBclOBc Bade
0 used do tamlate ßMSs
cals ba the JocApeetiahon

speute
coyoms do Apeyicahon
Jerff Coponet that
-Those vnemaes
e
taated
The oße
by the Jese to 08ßc dhve

Unodestood by the 9Ms.


into the menape Jemat
Nete: Avo mmpht
euha tramslaon
Grihal appiahon because the
nlçehvely impot peynce
02. ypez: faua Nakwe Code Aivea,
cooe
wses carses to genehate platon petie
Taua
cided
code Hhat s, code any undletood
JuNt ite F2EE Comyonevt
Cam

plon Code daiver APZ clares


platom dpeclic
soThe
Code.
ha
Panhaa
Ayad:
canes tA the gaua) ahve Cock dive
>th ArT
wanuochuelo
pleably oat took aüth anthe
03.

Most Commony used sc divea.

Thae JO6c emated Atatemert ae aated ino the

th 6MS.
B6M:
fammat vauved
Vegihed by

by dhe
eesies e hamlatesd nto the fomat Yegie
oAMS.
SAL quules do vot ned t be comvened to Jese
femated Systems.
-Adv: > rtert wa to Commnicte SQL ees to

JeBe Paages:

>
These înehde aa data caje cti tiat povde the

stteol in the MS. ava Sal s art the


cola
polyefotaino

JouaLnaL
(6)
daa \menage
Jauaoajey
ojecki ttrat inteat cith th Javo Nawug Biredoy
podg Tosa dat oeus that wanape
(JNOI)
nlepee
ose
Con necha poog, monpoher advamced
eahues
Type 1: JDBC-ODBC Bridge Driver

Local Computer

Java Ápplication DB
|

Vendor
Application Code Driver

Type1 ODBC
JDBC ODBC Bridge Driver Local
DBMS

Proprictary Vondor Notwork


Specific Protocol Communication

Database Server

Type 2: JDBC-Native API


Local Computer

Java Application DB Vendor Drivcr

Application Code

Local
DBMS
Typo 2- Nativo API

Propriotary Vendor Notviork


Specific Protocol Communication

Database Server
JDBC-Net pure Java
Type 3:
Middieware Sever
Local Computor

Java Application JDBC Type


1 Driver

Application Code
JDBC Typo 2 Drivor

Type 3 JDBC Type 4 Driver


JDBC-Net Pure Java

Notwork
Proprictary Vondor Communication
Specific Protocol

Database Server

Type 4: 100% Pure Java


Local Computor

Java Application

Application Codc

Type 4
100% Pure Java Loca!
DBMS

Proprictary Vondor Nctwork


Spccific Protoco! Communication

Database Server
06

A
Brtel Ovelvieu ha feßc ocesi

a
Jhis proces : dividdnto 5
Yhineni
diver
3 Conechng to tha otMs.
Creatne g a
execuhp stadenent
Processg data yehunol by hu MMs,
Teinabine the onnehon ut tta ons.
- the
&de dien must be toodeo heyole
tu f2€E omyoet
Conne do th %MS.
Con
Namec) method is wned to load theJDBe divea.
The
cla. to wo/k Ghline
, ute a
k9. Suppobe duloper
a tuants
T2EG Coonent that interats its MirostAces

coderat oods J4 ose Brd


ke
die called
SYve
Sun. jdbc. odbe.jdbe.Odbc
is loaded by allig the clas.flomec)
he
diee
in tr lbuinf code sgnendi
faName(ungdbc.odbe- jlbcbdbcornne),
da
Name ) the driver
must canect to tkE SAMS Ug the
Lotiveamemggor. gut onnetn () mehod
Manep clas s the highert clans an the
Copdal The
taa. Sqyl fmen
Lotes.
meuo BnaneeU
|For Myy mnyj.jahc.. Brve).
("coms. +
clas ya Name /est?"
myjap i|loalbert
çetConneckm(jdbc:
SnveMamnge

Fo Oracded
Clan. fa Name/ovade. jdbc. dinea. 0aceafinen
The wManapen gelonnechan) wethnsd is pnsed the UAL

PMS.

Wame

Copoment
the aabane tat w
beingacne by te qéE
th SrveMamgagekonnechomc) method retng aa Conmeckiog
inteyae dhat s sed thoghout The pro cens do yYeleenie he
data lease. Copial Lettes
-The jaua.soy onechom ideyae is amothe membe tha
mamapes CommmicahRon behuean the ole
jaua sq poukage
tat
is the jauasl- Gonnectin nteyoe dhat end sateeut to
-ît
The wwe
The aivemanapengekonnechant method to Aoad
conmet to The custmemahon
the goscl 0a8c bafe
databane. Ariven Namne

risg urd aydbeiodbci Customenlyomahon d data bone


Nanne the

>Capital Lete
rtvade comechon ob
> Captalletes
nechion :
Aayl. Con
java.
imypot rienangpen,
java. hayl. BiveMamgej

impt java
. Dql. statamut;
a SeL Sktement,
Nesdt step àn to nend a
sel queny to
Ihe aBMS Ja poeoig
eny a deies AseL Commands dhat
nel oisto
CaYeet tha Bms to do Somelhing Aeh a do
rehn vous
d data to the TLEE Component. a
unedl to create
- The omect. create.satemet )malhod
js tren ed to execake 's
Captell siatenent chjet
objet. Thee Salent repom
Ltte Salememt
rehun
a Reultsetojeet tat Contivste
qe às usually ame[we
Yous
om he
BMI,sich
Yeguesked by the J2cE omponet
ystechis paned
to astrip ohjet
he queny's aspned method.
exeuteQueny )
odajecn
do the Slatement clobec
om the OBM,Ihe
neelhe Reultet is eceived
btalemment
Caded to dermivale the
metod ) rom the Custmen
ie Yous E Colunns
Retrieve al sikatewent objet
talale.
Gapiel
Sateme 2ata Reques

Renultset Rerulb Rorult set ojet


Caglal
co det * Hom Customens
Lettohs

ala Rsauent tab.Createsatenentt


Raquent ere ukequeg (aery)
Renults
DataRequent. clese
. Capitl lete
O9

Botes ao Retumeol by the RBMS

do
madhocs used
The aua. SsLiRenulktet oajech coint
tnterat uith dato that velameo by the Bßsto The
JREE Comonent
Row
[Firat
[Fi
Wnp Fst Nawne, LantName, priras ue -Succes
fabe-Falne.
bodtea Recado Reltoneto; CNo
Rows]

dat vehwned)
Splem. ow
pritln ("No
Yen
tke
else z Name
s Name
do
setjrig (Fist
(Fist.
FistName- Rerls. getsrinp
CatNomme Reuls.
+ +Lastnome
prinkrw FistNane
Nyotem. ou prut (printra);
} cstule (Renlb neytys
fist ame
&
cuotomnas
requeted
Jacc Component by Te SRM
-A
latnome fom
a table.
Tu veru vehned
oajet callid Reauto
oheody mpned to t5e
Reuset Keutsel y
Ast tine dtat
metthod
tieneto R
l ya
ta
-[he ponhonel at
poiter 'n
Renulse daloe
Called Thu ttat
1he Retse
a rehnwa boean vele
in
- A rue value
reumed
deast

Cawstn he odo dn da the do.. sie locp.


Tha Renulls objes in Ded to coty

- tha Reullset to a
glrip clajet.

cstole Conte neds to be Gopied E


the
ie ReJket vawe tron fe peted
method vehuns the
elilvinpt)
Coumn. method, alled
pOCeNS Cories unl the nku glatemment
Tis onolihonal apument do i uhile
s he
mlano
a fabe sih
Comedioy to Ihe 8Ms:
he closey
Tevmat 8Bms teminated by uiig the
Coechan [u
to
Gmonet
caject onee (te Ja€E
Dra

mehod Te oVedioy
auceming he AIMS. claes
fished comnehin automatall
- doring he datase Roultot ephity
Altagh better to clore the
a keutset, it Gmnechan.
the
behe cloing
9b.cooec); aa Roquet.clsec
1
objcc
Connecon fhataat.
Reuls. cldec;
Rerult ,t object.
Tronoation
Proeimg:
way
-A tyamacian invoe sevesal taaks.
Pmalogy: Tamsachion ata Super Maket.

O
Each item puhased mut be vegrtened.
mut be taled.
ihe tachon
3)
lhe custome st tender tie onnant the puehase.

Sueemjul Tramsachin:
3 eoch tank 'in conpleed Suceuly.
) Failedd Tranackon:
ne daak ilo.
Achonoe faidd tasko nt be reveYoed.
Cnblee
updatn

sQL daements
-A data base daoaios cisto a bet

succemly omplled.
soL otementmust be
Eah
Faled Taachon: dhat
> sQL sbtement tet exeuted seyully upto
point an The daacbn ut be Yolbok.
Commito:
Comleeo mhl the FeEE Comyanent
A
dotobane tawacton dot
Call he Commit ) method The conneckon oejeet.
prioY do Ihe Call to The Commity
Al saL statemet eneule
method Cam be oledbok.
none he AL statemen
one Committ) metnod is called
.
Can be vdled bok.
Lomitmhod
mu be alled repales y
the Ja ateet
was
a

Paut d a trando.chon not. Hnoe the Commit mhod


automahcally calle beause the Bms hos an auwo commit Jeahse
set to true.
that is by deault
Problem, How to Rroces a TVenoachon

stpi: Iwpat Raautred package


-Conmechan
conn iva Mayer

JRpo: opem a.
Conneon
auto omnet as Jahe deachvakion
slep+: set eatin
awo com it
yi Conn. sekAuoCommit (febe

bung eyo " Grseut twto éiployu'+


"Volus (o06, 20, 'Rstb', T)':
shwt, esecutaldatquuy); Gzeuled sephy

(oa, 22, sia', 'sinyh):


Values
cacuti Updati (quey): <Gcutd Sapaky
Jkt.
Conn.
Commit; &
Gny ommih
cooe
Sht.
Conn cobe

,vlled bek):
Com. follbik; |Rolzak the tansahan beedayiy
mthe screen.

ercep)!
Lyath (saLExepln
fylem.err. pratn ("excep
guilge:

mwhod ds aled
Nte SetAuto amity
Gorpleted
O3

nee fo be
tieh dont
may covinti wamytts, ome
-A tramsachan
vohelock tntve tasackions gads.
techiely
Nes ode Procering.
customes awnt tabe
updating the doen talble.
(0 Bmseng The dden into peleng
(D mahon email
cuotome a Cotr
(c) Sendi a
Suengul
> Not neceMay rolbak th entire tansahn,
do
Cohme to be
bakgne.
e dde
moe that
imatat Cam dent one tke evaid seveh Is
>It in notice be
Conymaton
- Stautom:
Savepois d bnts thet ae
Compoinent Can Conto tfe nuben
>
JE
led ba.
>oduted in gotc3. o
waske hat daines the tsk atuheh
T}s vitual a
The olback sbps.
heve Can be
mamy Savepinto
wse
in a tamsachan
>
Eah ave pimnt i îdenhe by a unqe
mithod to
Swe poit vame inthen Poe
do the yeloek)
Tke yolbak
bpeutyte point wttin the yanachn hee
às to stop.

to Tha
to be Yomovd is parsed
rat is
Saepont
Veleane Sve foint method.

Skpi: npsh vequived bkoge


sep2: RprSter Jodc daive
open a
canechas
Jep;
Sep4: set auto commit an false.
Conn Sethu ommit (Jalbe):
Skpsi smt 2 ann Greuteshtmant ):
hrithenkht
Jang
jaa.

edcephom las

usor
hio menae
o the ahal
Connecbon O4
Safabase,

Aoo base.stAutoComit
le):
"upoata customels set sheet Main yhee
T
'5
shee stNamme'Bo
heet't
fng uey,"updbt
"upoat Customus set sheet-'1o Maim

ohene AstName Tim

Satkequeti tabane. Creat stadenevt


fiaepoint.
Save pont tabase. setSavepontlp set tka nihali
oteloint Sata Reqont 2 atalooe. Crea alesbtt pesrhion
dejet
ata
Aeah eseute update
Cuey);
2otobae.Commito; Comit
Satakequesti. eleclosec);
Sata lgute. );
.
Satbase YeleaseBe Pont (

Salalaae- clone;

Satabose. rdlbaek (s): tS


>Cath (JaLErcephos evd) i
Uystenn.
syslem.
e.
enit(a):
pnt (' voll bakk
eva"
+
ewa? Memape
();

aguage );)
$yptemy. exit (4);

statememti
(h) bath
-To conwbine sdL statements to a trannatn id to badeh togetne
these ptateent ino a
Al tomsechin then eneute te entive
taachn.
Call Cleanlialtht)
, as doy as you cal t befe caliig eecutetahy

amho thedafabase tat cm wocuee a


uetamhad Peyemane
botleneck.

sbtemetin
upate the bath
Rehee the update Gunt edh
update tat escutid Sustlly beethis cephto

mecerly, ehums am
al Comads edeed Stalement
Cowns fo Re enpechve updatr)
Waere

> a
Sulbcas sQLErcelion

exeute Plopuy yetun


ateko to
a
Yelt et,
t C
ezecute Bate )
hus SeL Gxetion

the elemeto + the any a dolened aoeip to The


dden n
shich cammando ee adoleo to The
SBL bath.
Cephon
>A descviphon tke evrd.-9etmenae ideny evvd
> Th
sking doject Caniuto S alphamemev'c Od an Xlo Pen Code to
clasetes- getsaLstate.
i mpenethon npeaie , mp
The
be tRe
ahal ev Code velsmad by
undi dat Snee- getEi Code

L repleseds he data base to urwch a


Canneon obied i Gonneceo

>
dtemine he
uben Youws
thot eoeh saL dtolemen updated.
Ycus comt be deteinedl
3 onen ocwned duing update.
Creatiotet o6

2otbese. set AuoCommit (fedoe);


Mauin het"+
TOy uupolate cuntmens sheet 's
i+

update customes t heets ho Main seel


igeye
FstName lTimn;
Ushee
:
gatsRguent: takase. creatastement
Aatalquutk. adolsateh (auey
Datakequekt. acbbath (uey) No. seL
Setakequet. executo Kath
C updaeoz wene eeutol
it Qato Shtements hat
bae Commit; Suuengy
atakguestt. close); cade
|Seta Rogueskz. cse; Wopen
slot.
cose C); rehumasdpt
Qetabae.

tath (Baloh pdota Ezephan ero); mehod


fhe

Syten. a. pfinth (' Mendayge

+
t e. get Menafe

el Eracode
( o):

0):
erd Gots he e
ano
umben eAcephim
ithThe

hecallingstomt
out. print(updaled C): by No
uk,
St)
SQLCXcephin soyl err; bakhoherthan

ytem prindm ("SAleva t; -Hhak

yla seygelvent tephon


phian
cdoTke net aepton hjeetin chain
0

enetyaasbleol
Kenmove o the
Aota Yemove
sten
allth Jelechey
Requst.cleonBath method
asled. ant
yan
haeneto
cath(eoth tipdatoEceptibn err Chocse Yemove.

Syten ou prn funable to clesn he baleh'

ed getmemggec)

hets The gev ivesevd


handled by tha diiver

You might also like