You are on page 1of 41
2ane june, QodL Noee SREE Stands for dava 2 Entospoise Editon whewe 9. StePers the version . SREE contains a lavgex set oF libwavtas compared to “PSE (oom) which Ie uced 4o pevecom Sand advance FuneHonaiities, * Need of gee : Se eee IEE is needed Pox tne simplification of web @pbhileatton development. Java ts used +o develop: stand alone applications. * Stand alone application : An application Which Is Sjostaicted op limited only +o @& posthreulay System is lenewn as stand alone applicator eqs Any dekstep application, ; * GAR File: Jay Means Joya Agchive (compress), . : Fils o File fosmat based on zip-file format which Is Used 46 compress Many Files ints one stagle Pile. Contents °F gaz pile: Pe, %* Need Poo gan File! Jap Ple is eeded” fo impovt tia pyoberttoe based on Hee SLQuyeMent . Standasd Poekage ey Foldes Stoucture 0%g / com Company | croegie Name Piqua Gara inbor Medule 2 @ Tn cage of Standasd package structure , Oe use dot) as @ Sepavater- etn cace ef standagd Felder Structure , 7° as sepox ates. f ik wer use’ Poekage o04- gspidess- yavApps public class student 7 vald study) 4 s av fin opHimiged sola FOr commonty e-oecusing sdesign pxeblems 1s Known as design Patean. eg: Mve avehiketuze Cmodel view conteollex) | These ave two dirresent categories of design pattern pores ent namely : (@ Cseatonal design pates (by Factory design Patesn (5) Caeattonal_desiy Tt Involves only Obyect C Foctoay design pakesn is always associated with tHace. dteresent types of logic : QD Dmplementation logic di Object ereation logic ! ' (i) Consumer/ UHligaton logic (DTmplementation logic : Tt is used the basic fundamental logic Which conta'ns | Ohly implementations according +40 Which an | implementation obgect has 40 be cpdated. ! Object Cseation logie + Trae ae era ee obyect according to the implementation logte. by using a Factory /helpea Method within +e factory class, CD Congumer/ UAUigaton late : HIS tue most ‘umportant logic which is used to qecoss 4ht Punctionalities fom the implementation § Obgeet - ' D D ' ' y 1 VeiQotets mans Re ,— Without vwelttn ' o Consumer /uHligatton Logic, we Cannot access tu PuncHonalites Package ovg-btm-litht App; Public class TubelghtTmpl implements Tswitch 7 JJ \nplementation logic @ ovevoide public vord sOn\) ¢ Sop(" Tubelight +usned on"); public wid sorFO Si Sop(“EESLight tuned OFF): ob STi ciao a a nn poskage o%g- btm light APP : public class Led Light Drmpl” tmplements Tswitch 7 4 Lmpierrantatien log ic @overvide public void sOnt) ¢ 60p(" Led Light quoned on"); s public void sOre () 7 SOp(” LedLight -fusned OFF yi S patkage 0%-bim ght APP - pubuic Class Light Factory i I dbgect creation 9 Co a — Package OBB) bey. LIBRA DP : canaries logte. \Mpovt Javaut}l Scanned ; | Bubl'c class Tact Public. statte void main ( Sting’ 42g.) 4 | Scanner se = new Scanner (systern-in); SOPC' Enter Lignt type ")/ String type = se-neatl)) i Eswltch so = Light Pactoy: gettightleyPe): IF (su |= null) ¢ sw. s0n(); 2 Sw SOPPL), YConaumer os utiligatton lagie 1 5 y Sik eee aa | Factory /Helpes Method: Ft is used to eveate ple MenoHon Objok. | Dote: (i) Whenever the Usey peovides +e implementation , { tian tw Same Usex has te oven cveate He | Object of implementation. | (GD Whenever tu Vendor poovides tue Implementation, 1 fan +e Same vender hos to even CHeqte He thyect of IMplementoHoh ,where Me uses IS espensible Only +0 Wsilte the concumes | ut{ligdtion logic . | Dal, 6, 2024 St ae '® Class loading : = leading Qa ela n os Class SOROS emanate *¥ Appitcation Petogsammi ng EnterPace CARL) 3 APIS Used few Tivey- Application communication pes ae Application can communicado Lolth anothes Applicat Kh tho help of Apr 4o achteve loase coupling Backbone op npr ie Abstoaction - Examples OP API Qv2 Apache POT, qarcel , IDBC , Serulote lore . | et \-e ' 5) AD} . 7 sa] 2 ain aephcatn duly.s ,2021 © COntente of APT $ The Contents of APT. axe interfaces, helpew class and Implementation clascos which is given’ ‘in the Pow oF Jas. file. k Gontenis of APT Ee CC —=< LULU = * IDRe Apr: 0) Joe , z WNDBO APE was given by Sun micsosyciems to achive adeki — CouptIAG by gava application and database sosve WEG APE contains intespaces, and holper claas in tho Foom ep jas pile BeMIDRC APT ic distibuied into 2 difowant packages & Namely vava-sq| and gavax-sql - Be Faw oF tne inverracas of spec APE ase Driver, be Connection, Statement, prepared Statement , Callablestekment pe ResultSet ote. * pe©IEGC APE Contains only one Helpey clae’in i+ by ‘Name me (Ulead Dives Manis. vs =» : » I5;Jur 209} wm * IDRC Doiver : ee Tees : ‘ : i) (iy JDBe detver Is an implementation of aDec APL. = Gd Tt contatns implemontet'en Classes in the Pexm of =» Vax File. wiuib bis always. specific 4o a paptvoulax Database » Sepver /vondor- : w WO Idec doivey axe Provided by Sespeotive Database @ —-Sewver / vendor. , ae ¥ Powt Nutmbow | Port number \s one which helps ho parHeular gorver. Poot number are always provided by govver Which axe unique. uc to got connected dha wospocH Ve Ovacla —»> Iso4 MySQL —» 9906 MsS8L —» 1433 Doby > 1527 July 14, 2094 peda aahnet e Diprevent daiver classes poovided by Sespectve database govvers 8 vandows : Java's4). Dover imploments ey saves apec APL pee Drives + L| Driver conjalns abstract) Gonnect O rs | Beeiecion Drives Manager ie inte lela len en ld 8 222222222 F class denen Implemante Java éq]- Driven eens ( eae 5 oes doiver ) ocean 5 TL @ovoroide, - ae —— Abetoact method - 4 r me ohy is IDGe Dever is an implemantaton of Adee APL 2 ** Sinee all the deiver clasces must mandate! y Implements gava:sql. Doiver interface which ls a bayt oF IDB APL, hanew IDGCdeiver fs an tm Plementaton OF JDBe APL. iD \s GECCCTTFTVIFTETILES m@® Joly .le,2091 2» tH dE derination of JDBC + Java, DataBase connechvity iS a specieicaton given "in tne Fosm SF abstoacton API 46 achieve loose Coupling. b/w a Java. Application and Datalase seyver. ® © Stere oF Ippe @ Theva owe 6 Steps Present in Ipec Which oste as Potlows> Deivey[ Diver clase 7 Since , + decveases he pesfarmane of an applicaton File Reades Pr = New FiloReades ("data-txer); eee eye properties in tuo. Poor of shtam data: txt An the Onstty syegourcas must be closed voltnin the Frnatly block” by using tF-eondion te avoid NullPo inter Et. Hole? py +ho interfaces of IDB APT ane coneHeved te be Costty @Bsourtes u09-3-+ IDRC Voly.50, 2001 (1) Load and Register: the Deiver: In hie Step, we have +e lead and wogister tne daivey Classes which is a past of IDRC dyives Which ave provided by the vespechve database semvers] vendor. Driver classes Can always be loaded & weg istexed jn too diphosent ways ? §@ Manually: : Ganding on ckgeet of daiver class and wogistering i with DoiverManagex” oy using a static metned called crogistes DaiverC) oh _ G) + static Connection get Connection ( Staing ual) | diy) 4 static ConnecHon go} Connecton(étoing 42), Pooperties into atD4y siatic Connection get Connection (Sting Wal , Sting uso, Stringy| Pass )/ wo gets @ Checked, 3 by uding above oversden method , | yy! excepHon: callud a BaLExc | | URL= “Hibe: mysq! #//lecalhast : 8306? Usen = 2o0t te Passtcord= | Connestien con = DeivesManages. get ConnecHion( “art); ral | VSlatlc factooy/Holpes Mehed)! Tnrerface pelpea oos / | Pant oF JDBCAPE Port oF JORCAPT i ! + 2 Impl}, Object *cen’ based oh Fespeckve “Us” Creates i stusns [gun CHORES SSS (Refusintype & Connection TmerPace )_ Whenever we use any oF the ovesleaded yaytnt oF getConnectiant > method, t thyouwds a checked extepHon Called S8LExcepHon - = DriverManager- getConnection ( “ gabe: mysql: Ye hos: U 9 2uvn-291 Doivnmanage Tris on inenpece which is a past of adc APT , which HeipGr ties css Contains +90 important state Methed namely , W Tegister Doluer ( ) i) getConnection (a code Package 07: btm. adbchpp ; Import — gava-eql. * = Wagposx Public class ‘IdbeDemo 4, bsum(steingt 1 azgs) 4 Connechon con = null: t9y fT Class-Jostvame(" com. Mysql - Idbe ‘Dalver np SOP" Paiver clase Joaded & Registered"); Con = DoivesManager . getConnection (" sde: mysql /! localhast = 880s 2 tex = snot Z Password = Pwd oy - Sop (" Connection establised with database sexvea"); earch ( ClacsNot Foundexception | SSLExcePHone) 7 @- point Stack Trace); Package. 09: btm. adbcApp ; 'MPovt aava-sqi.* ; Public class abe Domo 3 Psvm{ steingt 1 angs) 4 Connecton con = null; Statement stme = null; ae : Wye Class-forName(" com. mysql. adbe Diver de Sop(" Class Loaded & Registeed " es Con = DaiverManagax - getConnection ( Sopt "connection established with database”): _ Stmt = con. Create Statement (), SOP(" Platposm Created") Catch (Classtlet Found Exception | SSLEXcePHoh 2) i @: parntStackfoaced);: i Finally fe(stmt [= null) 4 id) Stmt- Closed) / £ 3 J heasen( sstexception 2) 29ae Q-point Stack Teacel) ; b ein * Specifications of ddbe i There aye B diffesent specifi'cat'on poasent Fox ddbe Namo" UG) A the Dever classes: must contain one state block jn H- ti) AN the Driver Classes must mandatovly implements Jova-8qi:Daiver interpace which is 2 port oF ddbo APL. Chi) AN the Doiver Segisteved vith DaiverManager Method called register Doivext ) mpothed - dlasses faust mandaterly be by using static dv} 80, 2021 ; ; a) Execute the SQL Quevies oF Sgt Statements ¢ DML — Sensert ; UPdate Delete Sar Suevies Deop , Rename , AeA Truncate oo DDL — Create , SEL stiemens DEL - select a : OPS Taeries os Sat statements , dipperent method poesene onecute Update and execute Suewl) AARHAAAAARRARRAR Tn omder to execu 1 ment Enierfare +o Statement, hPP? =» = ne ~ = » @ ~~ » » Cd CRRCHIeC) method is a, _genente method , Since, is Used 40 execute Qng type OF S8L Suceles OF SSL statements. Hence , the Setusintype for execute) metrrd is boolean. . - CxeeteL) method seturns , a boolean true value in case of DStL_and boolean “false” in case OF BML/ DDL. Eyntav: Stmt- exocuted’ genevic SSL Suery ) The outcome DmL is (0-1) integes value Which gives tne total no. of secosds affected in the database Sonvese. A suly 2021 execute Updater) ¢ + int executeUpdate (" Only DML”) 4 Specialized Me+ned aki) is a specialised Method, sine, t+ Syntax ! 1 Stmb- execute Update (Only DML Suey’) ! code 40 ingest data: ints the daiabse server by Using sialement jnierPace Package 009 -btm. Id bOA PE? Impoot Dava-3q1.* 7 om Public Class ddbeDemo j Psvm| stoingt J azgs) 4 ConnecHon eon = Null: Blalementc etme = Null Stving qxy = “Insest into btm-.student values( 4, Ritesh , 7643); 40y ¥ Class.fowname ("Com.mysql. gdbe- Deivey"): SOP" Class loaded and Rogisiexed "); Con= DaiverManager. get Connectton( vat); sop(’ Connecton established with databaseseaver’) Sime = CON. Create Statement(I/ c Sop" PlatPoom eweated ")? - egecute Update (gry); oe te Update. yocord fh the databse sonvey “Sing Siajement infer Paco Just change the line in previous as Package btm. ad beapp : IMPost Java. sql. +; Public alass AdbeDemo { Bevin Stn gL args) 4 Connection con = null; Statement stmt = null; \ Shing q¥y = “Update btm-student set id= 4 Where Name = ‘Suvesh’”; try t Class.foName(" Com: mysql. adbo-Doiver") + SOP(" Class loaded wRegisteved ) + Con = DviverManager.. gerConnection (4x1); Sto” Connection Established with databoaSeaver’, Stmt = Con: create Statement() >. Sop("Platfoom ceased" ); stmt executeUpdate (qxy )7 Sop(" Data updated”); execution 18) foctory helper method Urea tee tae eee ee Patme setPnt (4,2), Pstme. Set String (2, * Sam" Ms Pstmt-setDouble( 3, 66-46), Peime exe aueupdar C) Pstmi-set Dnt (11 3): ie bstmt- Set Stsing (2, " Domnic"); Pstme setDouble( 3, 65-43); Petmt- executeUpdate): Catch (Class Me} FounJexception | Slbaection & ea & parnt Stack Trace (), i Finally 4 ie( ptm |= null ) 4 bo. closec); Catch(SeLexception e) 5 4 O-bvint Strack Mace (); l@ (con {> nut) £ ty 4 on: Closet); Catch (S@LExcopHion @ ) 4 @- Pant Stack Trace); Steps fos Execution of adbe Pooqeck : | (D Open eclipse ib Java pousbective’ " (2) Open Navigator Mode . WB Rrght chek within Navigator mode and create @ Naw Java pyojact and mame it. BW) Rrght click on peogect and cvedte a new Pojdex called \tb and add “Dover. Jax and build a gava path to impoot te poopertes Prom the gose Pile. (SD Select sousce Poller and create a package | StouckhuwH ev . G)Select Application Name and egoate a class. Aug.40, 2094 ; # Code fo Petch all the vecosds From tt Cursor of bupros memovy by using gevrounc) oF vesuuset intePace . Pockage Op: asplders - FetchAPP; jmpovt qava-sql- * ; public etags FetchDemo } psum (steingl J args) 3 Connechon Con = mult: String name = ye qordteing (2); double perce = asgetDoublel sy; Sop("Td:"+ Id + "Nomes” + namer "Powe: "+ pore ) ; Eames Code 40 Fofch a porHeulatt stecovd fsiom the Cwisor os burfer enor uhere id = a package 0%q- dSpiders. FeichApp; import gava-eql-* ; public class FetchDemo 7. public state void main(steingl) a7gs) 7 Conneehion con = null: PoopaiedStatement pstmt = null; esultSet 7S = NUIl; Where id= p's i | CC _— ay SetTnt (4, id); * Peting PxeLUte Query ( ys %. Hee y ; ware Name = a gotString (sy) “Ie pore - 26-got Double(3); Sob( name bee oe pere ); Clse 4 orl No data Found" }id); Feaich Werden | SQLException ©) 5 : & Print Stack Feacer ) Finaty 5 + cas +© Peteh a path eulas second From 3! the cuysoy oy buFfey chee where Name =@? he volt ‘gemain Same but changes in queny | string eos = "Select * Fyom _bHo-student Where name- 2, pene Set Stsing Gai Name ): 8 = pstmt. MrecuteQueay( 9 ; _ it (08- De.) g evens ox bupfes Meomovy whee poe = P beim: set Double (.+, Powe ); ‘%8.= bstmt: execute Queay ( ), ie a. neat() ) ¢ int id = 38- geeEnt (4): String name = %8-getStriing (2) ; Sop( Id +" "+ name)? else ¢ SDP[" No Data Found For Peacentag + peac )+ ges Package 0g: btm. LoginApp ; Innpost Java- Sq): * | import gava- util Scanner 7 , class LoginValidation 7 String J GS) 4 siving 424 = "Solect * Prom btm.student Whese pose = ? *. X Login validatoen using Standoxd steps of ddbe : ¥ Code 4 etch a, portfeutase Syecord Paom the | : 1 ‘ 1 j 1 4 4 4 4 4 4 4 ! / 1 4 1 ! | —>——x— yi t | Class foodiame("eom: mysql: d4oe ‘Doives)s Con = Doivea Manages . getConnecH'on(uvl ) ; | PStint = con. propane Statement (424 ); ) Pstmt. sot String (4, Name); ) _ P8tme- set Stang (2, Password ); ' 28= Petr. excouteQuery(), ' 1 (9s. neato) ) 4 | String Username = BS. got Stang Gs | SoP (“Welcome :"+ username ae Fife ie tee colNum of \ dala in cunson oF , ' r ' else 3 \bupres memory SoP (“Invalid uses"): ce It fy ! Gitch [ClassotFindExcepton | squenw@ption ©) § Q- print Stackfeace (); Finally 1 ie( ts. t= Mull) 4 ty 4 %S-closec);

You might also like