0% found this document useful (0 votes)
20 views

Java Theory .4. - Compressed

Java Information

Uploaded by

mcacollege2023
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
20 views

Java Theory .4. - Compressed

Java Information

Uploaded by

mcacollege2023
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 13
Assjgament: No- 4 OJ whot is Jpac | write steps to Connect ony — | Java opplication ith the datubase in_java wvsing jdbc eae a = | aati stonds for java dalobose Connectimitep+ ib 14a Jove fpt that ale _javer_qy2.a19— Lo jateroct with detobase - _praform S@l oferebionp 18 monipulote data - JDBC provides _o _stondard Interface for accessing acdetianal— datoposef {Pegardigs of the database management _s4sler Conms) being vsed+— es Import 9c pockopef = First, gou—need As. wimport the Joae Package inte your java Pojzony) these fockag tf—Or2 ty picatiiy incuded ih Lhe jor. $0 you don't need 10 dowmibad 07 _ ington then Separat we): ~ we si ss Load £ Register jog Driven = you need 10 ood J, reg ister tre _avere priate JnBe_driver fer tne datobose_4ou—07e ESL ngs pn LPstobish Cennecti0p - A Ptea tooding Me daiven i you_need to establish o_Connedior te Ane Jutohase using the “Daivenmanasta jet Gnnechionl) “metnod | Create Statement, - once tre Connection i3 _ [established sgou_Con create a Statement object fo | executing COL _querieP * There are mainiy 4.00 wre) lof staternents _StoLement' fox executing éomp\e SOL 4 Auer f— reporedstedment? i 2] rite 0 Jave._pesram. to create. an __appiicatior hich with perform Fonswing Operation on siudent: dota Cosing, JoB.c) i. insert ii) delete - + ln pone Java .Sqls ———fublic crass student database —|—_ Stoute ti Nal Siaing joge-VAr=" Jhbe' mya yl ——lecahost! 3306) 4ludentdb ts - —Stoule Sines swing Ustamamb="your-vse nome "5 ~-Sloric Sinai string asswokn = your Possword ~ ~ Pubic Storie void main Csiriny C3 0x5.) ne 1055 fox tome Ccommysq) sc eibhe Delve") t Connedlon Connection = oriveamonager+selConnectior {C108 coer, ostRuAme.Passworp dj ent -| SLa Lement_Staiernen os Loiiag -lnseatqueay = —} age) Vaives Ch john’, 2097 Slaiement execureupdate (inserioucry)} = conneiian create sialemenrt 075 |_System-aut. mintin C"inseot_opurationSuceess fu"). | Slaing-ddetecucay ="ni irre Fem siudemis wre id | Stolement+executeurcdare Cede ehemuery Jj System: out Miniin C peere oferation successfurs") jp | aotibGberinBt + Migs OF fa ne close C4 a _ Connect | J catch Cs@rexrertion | crossmat Sound txcertern ¢)_ _ f rintstacktrece (yj . _ {i ite oe Jay. oo _paere mp__to_create an appiicatian. 2 htch eit Pee foxy —Founiainy opication—e. in Student dota Costing, 108.c)i insert ii) delete a i Import Java -Sql.*j fubiic lass SiudeniDaiaha e Ape 4 - Las! aunt ‘amy sq) +) ———}- ——lcathosd ) of a State inet sii ng_ustamamE= “yoursvstanome” Sioric fines Laing PAsswokn = “youw -Ppossword."" Pu lie Storie veid main Cevingt3 oxgs) — tog A ___ | ©1055: fox tome C*tom.mysql Gabbe + Driver) } ——+_fomnectlon Connection = oriveamanager-gebConnectior | cineca Simin wtasestiaceeoaee ne | statement Sdoiement = connettion -treote statement CD j 1 Stolog -inéertqueay =" mseer two students Cid, oome, 19-6) _Vaives Ci" john’, 209" 7 | Slaiement + execurevpdate (inserimucey) ) | Ssstemsout. printinC* inseat_oteantiog Successfu.")) ____ Staing delete@usay =" “pttere From ciudenie were cl =") Ls -Out-Miniin C* peere oferaton SuccessFuar") jp Statement: ciose C) i Connection « close Cy? TL caren Csorexe eption | crassmatfoundixcertio 58) | _e: printstackTroce ¢) 5 i Bepisin Sav Rxceptiorn Ges meno’ with — St xomple - — . Seo €xcepria nis _o Subcioss “oF “tre ‘Jova.sai+ —___| ee | —p-handie_emnx that oce ——}-cladabase _ Lnoyqin_1.06.¢ - Hin. $@1_quevief- __ _ poses 7 ——}-Heae_are Same common metnods_ fended Ly | Sarr Prom cia 4 = uohile vo orldi ng ith S@L— iL_zeMesents a brood _—___—— Category of errors that _can_oc (o_dusing —datob ose -Oferations _, Such as commection— comexS,_ fy nox crc fx ception’ crass in java .srecau designe ol be 1. etfoxor Cade C)- Return tre vender = specific orrey | Code associated caitin the S@Lixcepian + This code [recites divin nat \ntaimasts rm obout the ocr Linck occurred! a a 24 | ~SelMessage C= Lelings—aslieg message clescaibing. dre Saifice pion thi ™. age _byeicany ravi dey ____ caiption—of tne ervey + kote C) = Return the Sa) State code Fox _ | bLne s@rexceptions [email protected] is 0 standardized eam Corie defined tng —SCL tondards P is eume ___| Poorabie _omoss different _datobas. e . e24_= __ import Jawa sqis* } __ fublic_ciass. _Geampies@rtxcertion 4 = Slotic Gnas Sting Jp8.c-vet_="tdbelmysgr tts L wwcaihest 13406 [none existent. db” 3 pS tekic final sting —USCRNAME? —Skotic final Stin 1g —Possworn p—Pubiic_ stale vol, tog Conne USERNAME, PA Ro) fore cinss. fname (tom oysq) Cj, jdhewnaen” 2 chien = Qaivecmonger .gelCennection CJOBC-uRLy x Sling ent= Connection - Creciesickement Cj} aleuery = “ecLect* Fram aon-exisieat-tokie * > Re. ne alinnl = Skotement rexecuteaucay Coqi@uccy) Catch Cs@\ Cx ception ot FySlem -ouk: Priatin C's@ Exception occurred! ")3 pSbem+ Out: Printin ("soi state M40. geigaistote()) yskem+ Out: printin ("fxr code." 4. gelorwrad eQ), Systemsout+ Pina “Message: 4 e-4¢etmessageC))} Catch Ccrassnict Phundexce ptias C: prinistacktmace CD} 4 Emany 4 x4 tee if (statement \* 90) seatement cose (> + IL Crommectiog |= Nun) tannection sciase CVE 4 catch CS@rexception ee ©. puntsiacierrace C) j j ee 2. ARBc Cova database Connectivity ) ts gy “eM —AP1 that enabies Jova—pacyroms to - lotero ck lth datoahasep: ; There Gere Fou types of Jobe diiverf = Tl C\nac - nse) Bridge driver = 2! Matlive ALP claivenn = SI Mebuurtk protece1 ceiver = SW thin dedven = . - Here ore resuisea-gettor ( id")3 ‘Blain name + xesuistss gelsein jy Coneme") 5 ae VOR EDUCATIONAL USE 5 y “OSyemindt: Pedotin. (ng 4 tid + | Oome t''+nome Catch Cea txcertion ce) 4 © painistack tx wrace (J; 4 Pinay dxf SIE if Gesuset t= nun § + Yesunse) + Ciose C9: if CStotemenk ! = oun) 4 Statement rose CQ) if Ceonnerton 1 = pu) 4 a zy 7 { COtChK Ce@t exception eC) q fainistacktrace (Vp = i f + y i 8 ' spe FOR EDUCATIONAL USE a WED [EL LEAL I = Explain tine use of = \Gj__the JjDBe statement— |__bJ Conapie Statement SJ_prePared statement: -AJ_jnac staiement - t‘ Staremeat' inter bace in _joac is — osed. to execute o Static Scol Siatemenl— | vetsen tye vesuit ib fooduce fs — tHE tis suitable Fox executing _simpre Sot j—feaief trot —ole—ne b contain foramesers- —___ 1+ ' Statement’ abect are created Using —pne—— ‘Creole ciotement C7’ method of a! Connerton’ | Object a fg" Statement Siotecnent = Co onectien CreateSiotemeny CD fe ‘Resuucet Fesuicet = Gratement -execuhre | — Dae tS ELEcT* C¥om tobi©.nome '), L. \ 4 = +! Conable Statement’ interface extends * | Prepared) Gtatement” iS usec to execure Stored praceduref or functianS im tine clatahosr. Jt tt Con aise execute clynamic 6@ 1 Starements + —§— - Callable siolement cCanablestatement = comnection:_preporerai C" Cau Procedure — come C1 2)5"V1 “Starement. Get tnt Ch Params) \. ment set Tor (2, Povaom2)7 FOR EDUCATIONAL USE. nu —|+' peeparedainionens? inigtare fxtenda= — c i Statement’ & is Used to execute Puaameterized SP —}+ i's more efficient anon! Stotement’ koakemeni’ for execuiny S01 ch'Pemeny PoreumneiceP £ . + “preparer Crotement! or d__vf'ng 1 < Obert are Creare ing ——tne__foefored staterment Cl meinad Of a _ © Connection’ ohject eqe CG ——|_PreperedSialement preperedstatement = —_|__Co nme ctian - Poe pave dStatement Cérvect * FRom table vame were Coimn dame = 72"); t sonst : i : a Resultse} resuitset = Prepare dftaternent + exe. of -L

You might also like