You are on page 1of 66
Advjer course (eforeadjovn= Weise user /vstor} ‘Baten code: NAIA icine court ater advjava © Website Developer) naleeetll= taiancgercadtaeedl Aan ‘pre requise = care java cope + Common sence 8 Group: natarazjvaarene(orvate group) ‘uration = 100 sesson (Single et) bepth 50essions(twostots) “Sure-ceves erentation ‘Male topes: 3. JDBC Mise SS interview and sysom tes ontentation 2 Serve, se “> Forfreshersandfor experienced people 3. lspeMise ri) 2. nl Projects + se 5: HTML Java serie ose Fresher: core java + advjavavoracl ¥CRT spring framework 1+ experience: Fresher Toples hibernate +9P Tools (10+) Paes 2sexperieene «14 topes + webservices 2:/Ae/se i 2otopics + springmicroserices + angular /angula fe /resctS + devops optional) © Since we can use ovat develop diferent ypes of Applications ke standalone Apes, websites, tile Apps, Dstibuted Apps ard tc. Sa we can cll lava as programming sult. Instead of ust caling it as programming lanogucpe 3 important modules of Java Programming suite 1)ISE module (lve Standard Edition) 2)s€E module {Java EnterorieEtion/ Jakarta Enterprise Eton) 5) ME moll [Java Nt ation) JE module ‘itis base module for other modules in java. Maruti Sut = IRisinstallable s/w asjdh Gave development hit} J=> Suit Prtol ene {standard module to work with java in our competer |-sh (stanla ‘ewe should instal thismodulebaded Jaks/w asrufelmum —— |—>val sf nour computer ia oder to start our with using ava Isai ‘= atest version: Javad / js ore Jove tops (important) S stable version: ovat i ——— =e. oops ‘xcpetion handing Callectione Mult Threading String handing Jeva8 features > Ths module is mainlygven to standalone Apps and Aeplets. "> The App thats specific tone compare and only one ser feduser) a9 time to operate the app ic called Standalone App. ‘note: Te person who operatesin App scaled called ender tke bank employee, Denk customer, ebrote ister and ete >General these Agas run rom cod prompt. eg: dass with main} method without weg AWT/Swings. ‘TestApplcationjave ble lass Testpplcation, publ stati oid mating rae ) ) ‘edsjavacTestaplcation java ‘emabjavaTestapplication GUN Appleton / iestions (GUI: Graphical User nterace) “2 These ate graphical apps and wer iendly apps “> hut/sing Frame ps ace called stanalone GU! Applications -Sthete App can be executed trom Command promptor trom Desktop ‘6g: Calelatr App, class with malo) method having Awt/Swing sport ‘Antivir and te ‘Aut/Swing bored tava Gut App public clas Arithmeticapp extends jovacswingsramel ble static vod malnstring ares : Hesod> jac hathmetichgp ove Tema> java dethercde Biaieesies bol |-ice wheat ganas uw rame/Swng AOD {a} language Learning (Coredavs) —(Ukeraw material» wheat powderice power) (0) Technologies/AP1S Learning (Adv java) Uke semifinshed products) (c) Frameworks Learning Spring, hibernate, webservices) [tke lly Sic poets) "> Mage! noodles, Baba nodes. = Applet sa comple java cas that can sent over the network as java based web page. = Applets are GU. ut they are not desktop Appe/GUI App eco they can be ‘sent over the networkas ava based webpage. SE module shaving two parts Part)» Language (Entre core Jv concepts) [--soops,exception handing, collections /multiveading Applets, ‘Aut/Sing, Sting handling. 1/0 Streams, Reflection APY Networking andete. (ost) Technologies at pig tples adja) T=>1D8C,JNDI,RMifoutdoted) and ete. JOBC:: Java Database connectivity “rw: ava Naming Ad Directory interface RMI: Remote Method Invocation cur nao atten | aoe He eT tecage oo) {Coezmeiae oar Reiac arene pees 10" There ae no official terminologle standalone apps tnresume Programming languages = Java [Dood webiste) ‘Java technologies: JDBC nd, Servlet sp, Jive frameworks Spring hibernate, webservices ‘web technologies: ns, jae sip and et Databases srerclempsgl led core java, ave Isp > ova server pages C4, V8,P 8, 02K and et. alternate toJSE mods to develop standalon’ Apps. but their Apps _mePlatiorm(03) dependent Apps.where as It module pps are platform independent Ap: ‘VB: Vewl Basic 8: Pome Bulder ‘2k: Developer 2000/24) ‘Why did u choose Jove to enter nt software Industry? ‘= Java platformyOS Independent Inwindows OS > max 7 MiereProcesors at time to Imporve speed lava ie secuted Improve the the speed "= we cana only bytecode lass to lens to de the source cde jv) ‘We can encrypt lat ies to stop decompiltion on thowe fe Applets donot bring virus to our computer. Java complied gWes class form Java (Javae> builtin with jk) “2 some tampersls code while sending over the nf Jove decompiler gives Jove roms (we need tonal seperately) then that las will ao execute a ecieving side. ‘Decompiler =>Jhvals Open source ‘1 Decompiler “otis not only fre, song withthe installation we wl ge the source code. ‘>We can start using java fr Projects development with out any license > we ead sore code to understand Internal andto even reste ‘terates to existing softwares. note JEE is nota instalble software . tis set of technologies like servietjpejb and etc. acting s/w specifications providing set of rulesand guidelines to develop webServer (lke Tomcat) fr Applialton server (like weblog) softwares, ine ere ieee in ee mein bar eect reece (developer) + wabServer/ Application JEE_module (Full of rules and guietines) roftwares to develope (Developed based 18: foliations ike websiies developed based on a Tomat webserver) (BEA systems/OracleCorp) Rn (apache) JEE module i giving only Technologies ke serviet sp, EI, JMS , Java Mall JPA, STA, ba JARS ane etc. {IB ~-sEnterprise Java Beans (outdated) sp > Java Server Pages IMS ->lava Messaging Service STA» Java Traneaetion APL JAAS —>Java Authentication and Authorization Service JPA-~> Jaya Persistence AP Sting JEE modile ane its webserver/ Application server s)ws ,we can develop Enterpige Apps Ike webApplications and Distribued Apps/Remoting Apes Enterprise Applications Struts, Spring hiberante and etc. are frameworks tnt not part of Java modules USE.JEE They need to be arranged seperately. WebApplications 2.Dstributed Applications (Websites) (Remoting Applications) Web applications/ Websites >It sa client server app (two-ter App) where cllent Is browser and server isa software ‘App having ability to take browser generated requests, processing the requests and sending ‘the output back to brovser as response. areshit.com —hyd.com Machine (Clint Machi) _—IMachinel0 (Server Machine) browser (web let) _=> we can use Serviet,jsp Technologies of JEE module and html javaseript,css like web {ecinoogies to gather todeveion websites (web applications i Jove Distributed App /Remoting App The application who logics/services can be eccessed from diferent types of remote clients is called Distributed Applistion. Vanrreaned Aerie Google, Phonepe ,payIM ef: Bonk App, Amazon Shopping Application and etc. browser {Client} - website fontent (servlet 387 ———— ne} (pho) ATM AMachine(client2) ‘Machine 10 (Server Machine asp.net —ractve Server pages (ae L 1ome page for hyper text processing, Z (pre-processing) usec ton 4 aE aga) In Distributed Application env... Both client end server rath software Aopieatons the servies/metheds of Jwilinteractve voi Server hop willbe called rom client software Apps ke Response system) mobile Apps, ATM apps, webSites and etc. IvRshw RMI (outdated) , EB (outdated) CORBA (outdated) webservices (latest) ta devleope Distributed Apps © We can RMI (outdated), EB (outdated) ,CORBA (outdated) ‘and webservices latest) tedevieope Distributed Apps. ‘CORBA:: Common ORB Request broker Architecture (ORM :: Object Request broker vwhat isthe diference b/w web application and distributed App? web application Distributed App (a) Here client App is always browser s/w (0) Here Client app is programmable s/w ‘app developed in ett Languages/Technologies (b) this appruns based request -repsponse model _|b) Itruns based on method invocations/clls bbecor browser gives therequest web application | bcoz Client Apps are programmable s/w ‘and web eplicaton sendsresponse tothe browser | Apps calling Invoking the b,metiods of Server App, (@) tis Thin Client (Browser) Fat Server App (website) c) i Fot Cent and Fat Server App (4) we call rvletjsp technologies and (6) We can use. RM,EIB,CORBA (TEchnologies) Struts, JSF, Spring MVC frameworks to develop ‘Webservices [frameworks to devieope ‘web applications these Distributed Aplications {6} eg s:nareshi.com «) Banking Apps, Google Pay,PhonePe ayTM and Paypal and ete. ‘An Enterprise App can be a web applicalton or distributed app or combination ofboth Generally [Enterprise Apps are n-tier Application..(Multtier App) “ecommerce App with Card payment | ise paypal Pathway oles web ite (Siac.com = Paymentproker} — in hayes) AL (tipefleyer2) visa, ast} tleri/layerd ‘browser giving request flipkart.com Is 2s web application, ‘=rfipkart App allowing Browser /105 Mobile Aipp/ Andried Mobile Appi lke Pasitetea Wenced J8€ Technologes tke servetp.M, = ECommerce Apps talking to Paypall /PathWay/BillDesk App Is also Jevemel and ete. and also by using ove Fremeworks ‘distributed App. lke springhiberate webservices and ete" Adevelop java bases entergrise Applications Payment broker Apps like pay pall aking to Payment gateway apps ike er ‘orse Ape Visa/master/masterio alos comes under distributed App development. Similary Payment geteways Apps talking to Bank Apps also comes under lstetbited App development. => The above E-comerce App with Card Payment setup is en enterprise App where one ‘web application and multiple cstibuted Apps are invovied .. as nor Application. JME (Java Micro Edition) => Itis installable s/w as makes/w (md Latest varion te 3. ‘=> Itisgiven todevelop Micro Apps and Mobile Apps +The App that ie small in size and can be attached with varlous of types devices like eletrical, mechanical, automobile and ete.devices to make them thinking and taking decision ae called mobile development kit) are micro Apps... hese ave useful in Artificial Inteligence{Al) and Embedded system programming. chips added to washing machines, chips addac driver les cars| Supperts Al, Embedded System chips added to Robots and etc, programming = The Apps that can run in mobile devices are called Mobile Apps. ‘e€: Mobile PhoneBook, Mobile Games, Mabile Music Player and ee. SIME;s outdated .becor of alternates... ene Ty pe erieieirre aat— e TOS asin Operating Seton Tobuld exer inion low EE ls a oe sever neha See ie aie ‘Tonewaocounes (song wth sphgboot bean, ie eerie oom Deven PREM ype Tos 10) Oracle course + HTML Hava script +€55 Conclusion Java Moduleqimportant) JSE module JEE module + java framweworks ime ute useful to develoy useful develop enterprise A modu Standalone ‘ape ° 7 pps wsefalto develop we webapps A —— — GUI Apps/Desktop Apps ‘mobile apps 0 Apps CUIApps/ConsoleApps Every S/w Project will have two Domain names (a) Functional domain name ~> Will be decided based on the functionalaties of the project eg:: banking domain, insurance domain , tele communication domain and etc... (b) Technical domain name ->will be decided based on the technology in which the project is developed java, php, snet,, phyton , ++ and eta JSE module useful to develoe desktop gaming , office automation, retail, networking and etc... domain projects... JEE module technologies and Java frameworks can be used to develop Banking, Insurance , Financial Services (BFSI), billing, Health Care, Travelling, inventory , e-commece and etc. domain projects e-education, social networking and etc. JME module was used ..to develop telecommunications, Mobile Gaming, Al and etc.. domain projects... Note:: JDBC, Hibernate are not there to develop complete java apps... different types Apps can use JDBC,Hibernate to make thier Apps talking DB s/w.. and to manipulate DB table records... Explain what is software vendor, software services company and Client Organization? software vendor The company who creates and releases software to the market is called is software vendor company IBM,Microsoft , Applet, Oracle corp ,Apache , Google and etc.. Software services Com} => These companies use the software released by the software vendor companies and develops software projects for client Orgnanizations based their requirements.. eg: Infosys, wipro, accenture, CTS, Verizon, TCS and etc.. notes: IBM, Google and etc. companies will act as both Software vendor and software services company. for example IBM India develops software projects by gathering requirements from client organizations... where IBIV-USA acts pure software vendor company Client Organization It is the organization who give their requirements to s/w service company to develop software projects .. gi State Govts, central govt, Apsrte, TSRTC, SBI, AirBus,, Indian Railway, CitiBank, Amex and ete. ‘Some Big Client organizations running their own software companies UHG, WellsFergo JP Morgen andete.. ‘Whatis the difference b/w Software product and software service Project? =>Software products are projects the are developed by software company and kept on open market for multiple client organizations to test and purchase... gi: Tally, Ms-Office , Winzip, Anti-Virus s/w , Adode Photoshop aned etc... ‘=>Software service Project /software project are developed software service comapanies cexclusily for one client organization by gathering requirements from that client organization.. eg: CitibBank developed by POLARIS ‘Amex Project developed by CTS AirBus project developed by Verizon andetc.. Different types of software companies {2) Prodcut based Companies —>Develope release software product to the market Druva,, Microsoft, UHG, Wellsfargo and etc... {(b] services companies ~> Developes software projects for client organizations by gathering requis them.. (c) Vendor Company “> creates and release softwares... eg: MicroSoft, google, IBM, Apache ,Oracle corp and etc... (d) Solution Provider compani es > Provides hardware or software solutions to improve the exisiting business or to create new domain of business... ‘eg: RedBus, DropBox, Accenture , facebook and etc... Zoom Link: https://nareshit.z00m.us/meeting/register/tUUkcuippjMuHNOaeSWEUI7GX- RXOxs_molQ Password: 274140 (Sun Day 11 em) CaseStudyl natarazjavaarena@gmail.com ditference bfw Whatis the sane Boel and constructor? Ans) stati block class level onetime executing black where as constructor Is object level one-time enceuting block When IVM loads the ava class. the stati block of the cass will e executed only for time. In the entire App execution the JVM Loads the given class only for 1 time.. So static block executes only for 1 time. we use static block to intialize static variable. we place onl ecution logis, in static block .. like established connection with Db s/w only for 1 time irrepspective of no.of objects that are created. static { JVM executes constructor for each object creation...we place logic to initialize non-static Variables in the constructor ... if we create multiple objects for java class... the constructor executes for multiple times... we place object level one time execution logic in the constructor, for example if want to see every object should use seperate connection to interact with Db s/w. then better to write logic in the constructor.. (){ software setup :: jdk any version (1.84), editplus / notepad++ {mn One java file we can place mulitple class definitation... when we compile this file ‘multiple .class files will be generated on 1 per each class definitation basis. => In One java file (source file) only one class can be taken as public class .. In this situation public class name and java file name must match.. Es\Advjava |-—>basics int a; //defaultis 0 | ——>Testapp.java int a=0; //0is initial value of “a” note:: Only java compiler generaed 0-param constructor is called default constructor. but the programmer placed 0-param constructor can not called as default constructor In one computer we can see multiple jyms execution simultaenously.. and different 7 jivms can have different versions. (commoner |-—>It is static method of predefined class java.lang.Class (class name it selt Class) |—> This method makes underlying JVM to load the given java class. Peace rita eterna cease class i.e only static block of loaded class will execute... not the constructor |--> if the given class is not to load then it throws ClassNotFoundException.. (checked Exception) which should be either catch and handle or should be declared ‘to be thrown using "throws" clause... eg: Class forName("Demo"); ‘we should pass fully qualifed Class.forName("java.util.Date"); | class name here .. (class name with package Mresaepien name] (ese t Uste ec eer] Systam vt. Tas state ble , 1 Cpwamsserdtned construct , not the dell constrstor abe rest shtemout int Test 0 por bee’ ? fies News t Atte ste Sytem gin Bema se es srfemcet pin nacre rtm iain cae poe cette t state Sytem out peo Testy tate Bae Pabst vei min string er threw septon{ “Saemout panna of main] thd Testeran Tel en Settee as fomanaoe eee cheiemamet ome k hen tnve dos rot support pointers why desi vows WulPotertxeston? ——_ luna the diforence tw Sytemupri} and sytemetr prin? Spam aut groan of main) math); ain meted leet pera oc ‘est parm block snd aman mathe ‘The JVM attempts to load the java class inthe following the situations {a} When we class to "java" too! having main(-) method to begin the execution cnd> java TestApp {b) In the Process of instantiationlobject creat not already loaded. ‘Test tL=new Test(); (6) when we cal static method on the class name n) JVM loads the class itis, String sString.valueOf{10}; ‘Thread t=Thread.currentThread(); cis torNamet"") (4) When we pass certain class name as the argument value of Class forName(-) method con _—< | Nifpate"), (Here we are explicitly asking UN to load the certain forNamel-] makesivn tload the sive Mavenstltte” class dynamically at runtime (6) ttwe take clas/interface/annotation/enum name asthe parameter type or return type method... then they wll be loaded automatically. public String sayHello(StringButfer username}{ andete.. notes: while loading any class..the jvm also loads all the classes of inheritence hierarchy belonging that class. java,eng.Object () ‘extends cenit 4S ito A xt Can we develope Java App with main|-) method? ‘Ans) => Upto java6 possible using static block => Injava7 not possible = Inde leveloping java app with out (-)is bad pratice.. Not recomanded to do... We learning only as the FAQ. 8/9/10 possible using static block but ‘our App should be develop as javatx application. => Not possible from Javai1 onwords.. ‘upto java 6 java App with out main(-) method DemoApo.i public class Demoapp{ statie{ int a=10; ‘Systom.out.printin( “square val a9} SSCL: _rerminatos the current the process/App d emd> set path= C:\Program Files\Java\jd. cmd> java version 80\bin; ‘emd> javac Demofpp.java ad cemd> java Demoapp Success) Java app with out main(} method in java? Demoappi public class DemoAppt statiel int 2-20; System.out.printin{"square value::"+a*a); Sete AHLCL _seeminates the current the process/App , ‘emd>set path=C:\Program Files\Java\jak1.7.0_80\bin ‘emd>java version ‘emd>javac DemoApp java (success) ‘emd>java Demopp (error) Error: Main method not found in class DemoApp, please define the main method as: public static vold main(stringf] args) 110emoApp java publicebstract class DemaApp extends jav "pre delned abstract class staticl having ahetrart methods int a-10; ‘System.out-printin(*squat ‘Systemexit(0); Ufstatic block Wietass ‘mdpset path=C:\Program Files\Java\ idk} emd>java-versi ‘emd> javae DemoApp java (success) cend> java DemoApp (sucesss) output ‘square vlaue : {it ean java9/10 also) There is no javafx in jdk before java8 version. Developing java App with out main(,) from java 11 onwords Not possible .. becoz javafx is removed from jdk from java nwords... ‘JJomoApp.java publicabstract clacs_DemaApp extends javatx.application.application 4 ——"predehined abstract lass statict ‘having abstract methods int a=10; ‘System.out.printin|" square :"+a*« ‘System.exit(0); Vistaticblock Vjetase emd>set path=C:\Program Files\lava\jsk-11.0.3\bin (wean ateo.use emdpjava version javei2/33/14/.) ‘amd >javac DempApy DemoApp.java:3: Assigment :: how to find out java versi sven class file? package javafs.application does not ex public abstract class DemoApp extends javafxapplication Application Lerror Stable Java versions beastie aL What is the difference between System.out:printin(-) and System.err.printin(-)? S.0.p(-) supports output redirection where as S..p(-) does not support output redirection... by default. [)ysdemo.java public class SysDemo { public static void main|sti ‘Syste argsfllt ‘out-printin("corana"}; system.err.printin( “virus U/main, Ufelass {[emd>javac SysDemo java [[emds java SyeDema > output.txt output.tet s>use S.0,0() for normal debugging foutput messages, “use S.esol for catch(}] blocks related Exception messexes.. API (Application Programming Interface) _ Itis no way related to java meaning, itis used having english meaning like base, platform and ete. => APIis base the programmers to develop software Apps... every programming language, s/w technology and framework provides API. => In “C" language API means set of functions that comes in the form of “header files" (h files) ‘= In "C++" langugae API means set of functions and classes that comes in the form "header files" => In "Java" language API means set of classes, interfaces enums, annotations which comes in the form of packages.. types of apis 2) Pre-defined APIs /Bult-n APIS ~>Will come along with software b)user-defined APIS —>Developed by the Programmers Third party APIS ~2Given by Third party vendors like java zoom, softwareTree, Apache and ete (Here party —> Programmer/Developer] ‘part2—> The s/w vendor company who is giving software language/technology/ framework Examples java pre-defined apis, utility api —> java.util and its sub pkgs relfection api => javalang.eflect and its sub pkgs networking api—> java.net and its sub pkgs. jdbc api technology) ~> java.sa,javax.sal and their sub pkes. servlet api technology] ~> javex.servlet and its sub pkgs hibernate api (framework) —-> org.hibernate and its sub phes andeten >In Application development we can use all 3 types of apis. => set of apis togather is called Library... and these libraries jarfiles.. java will come as [Jartes braries= apis = set of packages = classestinterfaces+enums +annotations Jar fe java archieve (java baced zip /rar tile) ‘compressed / zip/rar content Injava jar files willbe used in different angles, they are => as zipfile or rar file (To combine multiple files into single fle) = To represent pre-defined /user-defined/thrid party apis/libraries = Entire java language pre-defined api comesin the form of reer file => represents jdbc driver s/ws.. Java having (ener (e)tangauge : Core java al (b) technologies:: advjova ce [sate (dbl, servlet sp java mal on) 7 (d) frameworks veri bg of vain ina App and 08 s/n. ‘pring, hibernate, webservices and ete. which capable of converting java calls to DB calls and vice-versa. eg: ojdbc6/7/8,jar (oracle jdbc driver s/w) => Represents ready to release stanalone Project (will release App/Project as ‘executable ar file) eg:t lombok-cver> jar = Represents ready todeploy/host java web application (website) there we work war file (a flavor of jar file) w. files representing java based website. ‘war -> web applicaiton archieve =rrepresents EIBComps (Distributed Apps) and ett notes: Everyy Api/library comes in the form jar flew but we can not say every jar file is an api/library becoz jar files even represent jdbc driver s/w, standaline projects web sites and ete. =>To create our own jar file. we can use the idk supplied tool called "iar" {avaialbe in \bin directory.) To create jar file jarDemo, " s>eurrent directory [masta atat > parent directory ENadvjavaljarDemo>jar_cf_nitjar_+ __allthe contant (both files and subfolders) wil ‘> create archive file ‘be added nia filehaving compressed sizes) {-rspecity archive file name E\Advieva\larDemoojar cvf nitjar added manifest ¥=> verbose mode {detailed info) Min =39) (out= 33]{detlated 15%) ‘ifn = 52} (out= 32)(deflated 38%) Every or file creation automatically {gels manifest anf in METAANF folder having description about current jar default every jar file is not executable fle. ‘we need to make it executable files.. with extra content added ta jar files. and manifest.mf file. ote: we can see the content and extract jar files using winzip or winrar Tosee the contentjar file (use winzip or winrar) E:\Advlava\VarDemopjar tf nitjar METAANE/ METACINE/MANIFEST.ME ait baxt E\Adviava\JarDemosjar tvf nit jar (0 Wed Jul 15 17:19:38 IST 2020 META-INF/ (68 Wed Jul 15 17:19:38 IST 2020 META.INF/MANIFEST.MF ‘52 Wed Jul 15 17:17:38 IST 2020 b.txt t->table of content. ‘To add new file to the existing jar file (Updating the jar fle) \dvlava\JarDomo>jar uvt nitjar 223.0x¢ aeiing?25:b4Gn= 2) outs n(detlate ts) Haupt the archive E:\Adviava\JarDemo>jar tf nit.¢ META-INE/ (META-INF/MANIFEST.MF aut bot (12340) To extract specific file from jar file E:\Adviava\JarDemo>jar xvf nit.jar 123.txt ated 123int x=» Extract from archleve To extract al the content form jar file E\Advlava\JarDemo>jar x nit jar ‘ereated: META INF/ inflated: META INF/MANIFEST.MF inflated: a.bet inflated: b.txt we cannot delete specific file or files or inflated 123.txt all files from jr file..but we can delete total Jar fle what is the difference between PATH and CLASSPATH? PATH Itis DOS /Windows command .. So it can be used while working all softwares that are running in windows/DOS computer... This command is not java specific command. => In order execute exe , bat , cmd files certain location from any location of that computer with out copying files.., we need to add the orginal location of those files to PATH env.. variable... exe file —->executable file bat file -> batch file cmd file —-> command file (same as batch file windows) batch (.bat) file is useful to create single command by combining multiple commands. run.bat date en here "run" ,' tun.bat acts as single time command having multiple commands eet carat execution internally... E:\advjava |—>PATHDemo |———>run.bat run.bat date time ver dir E:\Advjava\PATHdemo>run (success) >run.bat (sucess) \> run (error) Bad command or file name (old) (or) =>run is not an internal or external command or operable program or batch file (new) E:\Advjava> run (error) ) note:: we able execute run.bat file only from its oginal location... not from locations... C:A> run (e Solutioni:: (Not Recomanded) copy run.bat file other locations .. where u want to execute... this is not recomanded.. becoz when copy file to other locations. memory will be wasted for the same file... Solution2:: (Recomanded) Add the orginal location of run.bat file (E:\advjava\PATHDemo) to PATH env.. variable, . Variables —-> user/sys vatiables user env.. variables are specific to currently c:\>run (success) logged in windows user.. where as d:\>run (success) system env.. variables visiable to all the e:\advjava>run (success) windows user of computer e:\advjava\PATHDemo>run (success) All java tools like javac java , javap and etc.. are .exe files of \bin directory.in order to use them from location of computer toward compilation and exection of java code... we need add \bin directory PATH env.. variable... variable name ::PATH value :: C:\Program Files\Java\jdk1.8.0_31\bin;;. Explain diff ways of reading inputs from enduser? CLASSPATH =>It is purely java based env.. variabl eit can be used only in java env.. not in all other places ‘=> if Java App uses user-defined apis or third party apis (other than jdk apis) then those apis related jar files or directories must be added to CLASSPATH env.. variable.. in order to make java tools like javac java and etc.. recognizing and using those apis... Problem: User-defined Api (WishAPI) F:\CPATHDemo: |-—>WishMessageGenertor,java |—-om.nt basics} |—>WishMessageGenerator.class ishMessageGenerator.java package com.nt.basics; public class WishMessageGenerator{ public String sayHello(String user}{ return "Good Mornit 1 } F:\CPATHDemo>javac -d_- — WishMessageGenerator.java wants to use WishApi E:\advjava |—>MainApplication java (Application) import com.nt.basics. WishMessageGenerator; public class MainApplication{ public static void main(String args{]}{ WishMessageGenrator generator=new WishMessageGenrator{); String result-generatorsayHello(‘aje"; ‘.0.p(result); } , E:\advjava>javac MainAppli jon.java (error) =>Can not find symbols "com.nt.basics”, \MessageGenerator”, "sayHello()" Soultion:: Add the location of "com.nt.basics" pkg that is (f:\CPATHDemo) to CLASSPATH env.. variable to make java tools like javac,java and etc... recogni package and its content (com.nt.basics and its classes) from that location... and using This PC-—>properties ——> adv sys sel ‘5 —> env. variables --> user/sys variables—> value :: F:/CPATHDemo;;. ~>0k->0k—>0k.. E:\advjava> javac MainApplication.java (sucess) Conclusion:: To use Java In our computer we need add \bin directory to larly to make java Apps working with user-defined ,thrid party apis then we need to add their locations to CLASSPATH Env.. variabl notes: we can not add java packages ,apis location to PATH .. java tools like javac,java always looks in CLASSPATH env. varaiable .. not in PATH env.. variable.. PReparing jar file representing user-defined api FA\CPATHDemo>jar evf wist added manifest ‘com/{in = 0) (out= 0}{stored 0%) com/nt/{in = 0) (out= 0){stored 0%) com/nt/basics/(in = 0) (out= 0)(stored 0%) ‘com/nt/basics/WishMessageGenerator.class(in = 504) (out= 317)(deflated 37%) WishMessageGenerator.javalin = 182) (out= 136)(deflated 25%) wishapi F (representing user-defined api) if the user-defined or third party apis are there in the form of jar files...then we need add jar files names and locations to CLASPATH env...variable.. inorder make java tools using them... CLASSPATH F:\CPATHDemo\s E:\Advjava>javac Mainppli e:\advjava>java MainApplication (sucess) note: Upto Java we can also copy jar files that representing user-defined or third party apis to \jre\lib\ext folder... (we can not place directories here) ‘eg: copy F:/CPATHDemo/wishapijar fi to \jre\lib\ext folder .. " folder will be used by “ExtensionClassLoader" ... But ‘ClassLoader is removed from "java9" onwords...50 there is “ext” folder in the jdk installation from java8.. Q) What the difference b/w adding values to CLASSPATH and adding values to ext folder ? * symbols added to Env.. variables represent" " respectively.. 4d) Itis recomanded to add new values to “env. variables” at the begining. e) values set to env variables from cmd prompt will remain temporary. them once cmd prompt closed.. where as the values kept in "This PC" env.. variables will remain perminent.. ) Modifications done in env.. variables will not reflect in old cmd prompts..so we must open new cmd prompts.. and ete. JDBC (Java Database Connectivit s08G=> Na abbrivation, Iti a trademark PRE Nave Darn age Cornero jas on today] TIME Inistitute TAME ‘What is persistence? Itis the process stroring and managing data for long time is called Persistence. for this we need touse Files, DBs/w andetc.. Need of Persistence > The Data stored in Variables, objects, collections, arrays and etc.. use stack,heap memory of JVM memory which is part of RAM .. Once the Application execution is over..the IVM memory of the App will be vanished becoz_RAM isa temporary memory.. i.e we can use App data across the multiple executions of same App or diff Apps... To overcome this problem .. we need to write (persist) App Data to Secondary Memory Devices like FloppyDisk, CD, DVD, HardDisk,pen drive and etc...«. by taking the support files and. Db s/w.. ___Secondary Memory Devices a A" (FD, HDD , PenDrive}, CD/DVD) This data will be vanished once = the App execution is over.becoz App's JVM Memory will be also be vanished.. This data is perminent... irrepsepctive App's execution Imp terminologies related to Persistence (4) Persistence oper (e) Persitence Logic (f) Persisttence Technologies/frameworks (Data Access Technologies /Frameworks) Persistence =>Itis the process of saving and managing data for long time... Persistence store => The place/ software where the data canbe saved and managed for long time ==2It is also Data Storage Unit / Data storage software. 's_, DB s/w, Google drive , One Drive, Cloud , DropBox and etc... — Eatenstons Persistent Data ‘=>The data of Persistence store is called Persistent data... file content , Db table Records persistence operations insert,update, delete and select operations performed on the persistent data are called Persitence operations.. These are called as CURD/CRUD/SCUD operations... ‘cURD/CRUD = Every Service sector project c—>create (insert) Soo select (Read Banking App, TicketBooking,, U—sUpdate (modify) ae E-Commerice and etc... should deal R—->Read (select) 1 Saas with CURD Operations.. D—>Delete (removed) Fe Persistence logic itis the logic /code using which we perform persistence operations on persistent data.. :: jdbc code, hibernate code , 1/0 streams code and etc... Persistence Technology/framework ~>itis the technology or framework using which we develop Persitence logic.. These also called Datanccess technologies/ frameworks.. IDBC (Technology), hibernate (framework), Spring JDBC{framework), Spring ORM(framework) , Spring Data (framework) l0Stream (part of java language) =>Persistence Technology/framework is given for devleoping persistence logic to perform persistence operations on the persistent data of Persistence store... >Fi 5 (Flat files) The files that software and hardware independent are ‘called flat files like txt files , csv files xml files and etc.. 6, .exe, doc,.class ,.dll and etc. are not flat files. > RDBMS DB s/w (oracle,mysql,postgresql and etc.) Io Stream: Java App. Java App nD Limitations with files as Persistence stores (a) No Security... (b) Can not store huge amount data .. (c) No SQL Support {d) tis very complex to retrieve data by applying mul {e) No Constraints Support , So data redundency (duplications) problem may occur {Performing update and delete operations is very complex. stream logics) bank () 101-raja savings” 10000, {e)~ a 102 ravi 20000 — 103 sureshy current 40000 40% raja savings 10000 104 rajesh savings~70000 103 suresh current 40000 4 —— 4104 rajesh savings 70000 data (4) Can not not keep in realationships.._ (No FK column) (e) Comparing and merging of data is very complex.. and etc... To overcome these Problems use DB s/w as the Persistence stores.. Conclusion go ‘small size App and generating little amount of data to persist then for ifthe App files as the Persistence stores eg:: Mobile Apps, mobile games, Desktop games and etc.. if the App is medium scale or larget scale App generating huge amoutn of data to persist. ‘then go for DB s/w as Persistence store.. eg:: Banking Apps, E-Commerce Apps, Financial SErvices Apps and etc... No SQL Dbs/w DB s/w 3-> employee with 4 details |~ Emploxee having 20 cobs: 4--> employee with 10 details (DB s/ws are not good unstructured Data dyamic Data) To overcome these problems we got NoSQL DB s/w... which allows to store data in different formats like does graphs and etc. but not as rows and cols ‘¢g:: MongonDB , Neodj and etc... Java App NoSQL API (mongoD8 apt (MiongoD8 ‘Neodj API Neoa) and ete.) ande te) notet:: JDBC oF 1O Streams are not given to talk NOSQL Db s/w.... they heed seperate their own apis JDBC driver JDBC driver s/w is bridge between Java App and DB s/w converting java calls (instructions) to DB calls and DB calls to java calls tava aipp, as (— Bslw > Device drivers act as bridge b/w ee Operating System and physical Devices Piers esi: Printer drivers, Sound Drivers < and ete. "(Back End) jdbc driver for oracle jdbe driver for mysql Jdbc driver for postgresql ‘ODBC means Open Database connectivity =PODAC driver s/w act as bridge b/w Non-lava App and DB s/w. eg:: odbe driver for mysal note:: Java Apps, Non-Java Apps from where dhe driver for oracle ‘we interact with Db s/w are called front end Apps.. lobe driver for postgresql ‘and DB s/w is called BackEnd, notes: Inany App/project what an end user can see and operate is cae front end... what an enduser can not see and can not operate but itis pert of App/project and responds tothe instructions given by frontend is called BackEnd When all onjava Apps are using ODBC Driver to interact with DR s/ws. why lava ApA are looking for seperate JDBC drivers? 1) OD8C drivers are giveri"C* language taking the support of pointers. but java oes nat support pointers b) Converting Pointer notation logic to non-pointer notation logics and using ‘ODAC drviers in Java Apps degrades the performence.. €) ODBC drivers are developed in “C” language which is Platiorm dependent..0 pairing ‘ODBC driver with Platform Independent Java Apps kills Java Apps Portability ie Platform independent behaviour.. Toovercome all these problems.. Java Apps are using Java Based JDBC driver s/ws.. we can get ODBC drivers from diff vendords 4) ODBC group (32+ companies like microsoft, IBM Oracle corp and ete.) (Best) bb) MicroSoft €) DB vendors 4) Third party Vendors We can JDBC Drivers from diff vendors natarazjavaarena@gmail.com * sum is Sih on days) ‘ote:: Most of ODAC drivers and JDBC drivers ) Third party vendors are free. What isthe! {b/w Programming language and S/w Technology? Progamming language ‘>itis directly installable s/w acting as raw material by providing basic features that are required in Application development. defines syntaxes(rules) and semantics{structure) of the programming by supplying compilers and interpeters. => Programming languages are bsse create s/w technologies , D8 s/w , Operating systems, Device Drivers , Tools , frameworks and ete.. aeons JVM based Languages seals groowy and etc. java scala, eroovy ,kotlin, eo and etc. All these languages gives .lass files after using their compilers. but those .class files can be executed using, samejvm.. specification that gives bunch of rules and guidelines in the form of apis to develope implementation software by using one or another programming languat S/w technologies are not installable , but the s/w technology based implementation s/ws are installable or arrangable .. Working with these implementation s/wsis nothing but working with s/w technologies. eg:! IDBC is s/w specification that providing bunch rules and guidlines in the form of jdbc apis (jave.sql,javax.sql and their pkgs) to develope JDBC driver s/ws by using java language « JDBCis not installable ,but JDBC based JDBC driver s/ws are arrangable (ike jars) . Working JDBC drivers is nothing but working JDBC Techonology.. (96:: JDBC, Serviet, JSP, £18, Java mailTA JAAS and tc... eg: JDBC, Servlet, JSP, EJB, Jave mailJTA JAAS and ten. 11a : ava Transaction AP! 1AAS = ava Authentication and ‘Authorization serves 3B: Enterpirse Java Beans. Upto java 7 Java Technologies give interfaces representing rules, concreate classes represent ‘guidlines and abstract classes representing both rules and guidelines. Interfaces contains only method declarations (rules) ‘oncrete classes contein only method concrete method definitations (guidelines) =>abstract classes contain both abstract methods (rules) and concreate methods (guidelines) Form Java8 onwords Java Tehnology gives interfaces jabstract classes representing both rules and guidlines, also ives classes representing only guidlines... note:: java8 onwords interfaces can have default, static method definitations along with method declarations (abstract methods). Every Technology will give api in the form packages .. having the above saided classes, interfeces and absttract classes representing rules , guidlines. Two types of S/w technologies oe open Fechnologies Open technologies Here the rules and guidlines of technology are open to all s/w vendor companies to develop implementation s/ws... ‘eg: All Java Technologies like JDBC, Servlet ,JTA and ete. 1: Based on JOBC Technology rules and guidlines there are 100+ jdbc ‘driver s/s for various Ob s/ws given by different s/w venedors.. Propritietary Technologies Here the rules and guidelines of s/w technology are specific to vendor company and, ‘only that vendor company is allowed to develope implementing s/ws... 6: All microsoft technologies like esp.net and etc... ‘sun TIDBC Technology javing JDBCAPI] (Open Technology) ~2Gives rules and guidlines to develop idbe driver s/ws.. 5 ~ Vendors (Oraclecerp) _—Nendor2 (eve) Vendor’ (Nataraj soft) seicreated shdieleased =>created and released =Sereated and: rena Idbe driver s/w for oracle |_208C driver s/w for mysq} JDBC driver s/w forforacle, OO mys Microsoft Asp.net (Proprietary logy) idlines to develop WebServer} Vend afpallowed) Created and released IIS (internet information server ) ‘as WEDSErver s/w. : note:: Since multiple Vendors of open Technology are giving their implementing s/ws .. based on the ‘commen rules and guidelines open technology..So the way we work with multiple implemer ‘s/ws given by multiple vendors will be the same.. =>Since All jdbc driver s/ws are given based on the common rules and guidelines jdbc technology... Sothe way we work with ll jdbc driver s/ws will remain same.. Le if we know how to work with cone jdbc driver s/w.. we can use that knowledge work with other jdbc driver s/w. What is IDBC? n java based Technology/specifiation given by Sun Mc in JSE module providing bunch of rules and guidlines in the form of jdbe api to create JDBC driver s/ws for different DB s/ws.. SE 1: JAva Standard Edi jdbc api packages (latest 4.x) java.sal Pks | Core pkgs javax.sal pkg, wax.sqlrovrset pkg, ‘extended pkgs javax.sqlrowsetserial phe jave.sal pkg. classes interfaces pie — DriverManager Connection StatementEvent Rowset Driver ConnectionEvent DataSource Resultset RowSetEvent PooledConnection Statement a . Preparedstatement Callablestatement DatabaseMetaData ResultsetMetData rogrammers/ developers are not resposible to implement the interfaces given by idbc api pgs. Itis the responsibilty of the vendor companies who actually creates the JDBC driver s/ws bbased JDBC Technology. ‘What is BC driver s/w? itis bride between Java App and Db s/w.- +> It is collection classes given vendor company implementing jdbc api interfaces(rules) and using jdbc api guidelines (classes) having logic to establish the connection with ceratain Db s/w and to send and execute SQL queries in that Db s/w.. > Atthe end the Vendor companies packs all these implementation classes into single jar tile and they release the ar ile tothe market as db driver s/w. sun Ms/Oracle corp oO Sp abe apt \Vendort (oracle corp) (tor oracle) erfaced(rulesand guidelines) ing 100 clases implementing 100 interfaces. (etjar) of jdbc api.. having logic to establish connection with Oracle Db s/w and having logic to send Vendor2 (Devs) (for mysql) and execute SQL queries in oracle DB s/w Giving 100 clases implementing 100 interfaces acai ini io ial 1 kita net hin giao acteblieh copmection (ojabe6/7/8.ar) and releases tothe market with sql Db s/w and having logic to send [abs elven afi tor Stace and execute SQL queries in mysql DB s/w SESSHS YS erseee ppackall these classes into jar fle rmysql-connector java jar and releases to the market a5 Jdbe driver s/w for mysql Developert (Working or Wipro) Appl java (Wants to interact oracle DB s/w) jownloads ojdbcé.jar file from internet and adds classpath => Activates and uses jdbe driver s/w for oracle rites persistence logic to perform CURD Operations on oracle Db s/w. Developer? (Working infosys) => downloads mysal-connector java.jar file from internet and adds to the classpath, ‘activates and uses jdbc driver for mysal =>writer persistence logic to pefrom CURD operations on mysql DB s/w. (e}Deveopment (Coding) nate |b) Testing (Checking the code) (mreatonshe) (4) aintenance/Suppor (Fxg the huge and sues) 108 driver s/w [+ sColection of dasses implementing various interfaces jdbc ap pkgs and released tothe market as jar fle. > nry JDO drier svi entiied with Rb drier class namelie even though there 100+ class names in jdbc diver s/w» we can activate and use bc eriver s/win our lave Aps by ust using ts driver cass rare. >The java cass given by fb driver sh implementing vasa. Orver( iret ‘orindiectiyicalled je driver cass name Pa 51 jar | jb drver fw for race jdbe.drver.OracleDiver e) > ide deve cass name ‘kg name jibe driver lars implementing {nv Driver (cect or indirect. ‘nina conatoran-erit be der tor mst com myc jibe Driver —> be deve ass name ‘Pkgmame je diver clas implementing java. river sin any lave App we cn activate any jdbc srver s/w ether by loading ibe driver cass (orky creating objet fr jbe diver class= ‘AepLeva [wants tolnteret with Oracle Db s/w] “Sdoumlondo}dbe6/7/.a fe fom internat and add elaespath = Aativate jdbc driver s/w ‘aeasormamel" oracle doe driver OreleDser|;, (loading of abc ever (or) ‘race jdbc ewer OraceDriverobj-new oracle jdbc dvr OracieDeuet: [object => use ac driver s/w to deeop the persistence logic (CURD ope a) ‘App2.jova (wants to interact with Db s/w) sdownioad Fie omlatemet and ad classpath activate bcdiver swe ‘Claesforlemel” cor.mysgljébe.Orver (or) commysalc|jdbeDriver objonew commysalelidbe-Orver), }, Hoasing of abe diver cass) (eect > se jibe deversjw to deveop the persistence logic (CURD ope arou//menrepost ‘Cloracexe\epp\orcl\productit.20\gerver abe —> gives ojabe6 jure {from orade 11g instalation) ‘racle0g > ofdbct jr ‘21a compilers given (ied to generate byte codelclan] from soruce code (jove) (eulte-n with jk) ‘Java Decompiler are gven to get sourcecode (jee rom bytecode [clss).we need to ‘arrange decompllers seperately or use online decopllers. ‘Toure jnva decompiler —> goto decompiler.com —> choose and upload ether less ile rar Mlehaving class files and get the sourcecode. iavasa.Dviver() invas.brver (0 implements ‘| implements corodejdbedtiverOraceDriverle) | comanysqhcbe.rive(C) incites /7/8,0r) (in myaghcomector javefor same orade 08 s/w “PIDBC driver s/w is bridge b/w fave App and Db s/w ‘Every JDBC driver s/w comes in the form a file: having bunch of classes implementing ‘the interfaces of jdbc ap pkesava.saljavansal and thier pkgs) 2 ode /7/8jar (jdbc driver s/w oracle) fg: mysalconnectorjava- jar (ib diver s/o mysql) > Every JDBC driver s/wis identified with ts jbe driver class name . by usingthis ‘dass name in our app we can activate and use jl driver s/w. ‘= The java class that implements java sqLDriver is calle abe driver class and its ‘unique lass name for every jdbc driver s/t In oibe6 77/8 (db diver s/w for oracle) --> fdbe driver eles name: oracle abe.trver OraleDriver pkgrame «lass name implementing Javasel Driver () In mysql comectorjava-cverja (be driver sv for mys) |—>jdbe driver class name :: comantsgl.cj.idbc. Driver kename classname implementing avasaLorwer() Fomeghoreer jivasl.vivert irplements Templeman, oraciejdbediverOracleDrvede) | commyagic derive) What the difference byw Drive), driver class_and driver s/w ine? [Ans] = bc driver s/w is bridge b/w java App and DB afw and comes in the form of ar ile ‘>Every Orver s/w isidentiied,can be activated and used by using je driver ‘The java clas that implements javasa.Drver) salle jd driver lass. AVIA of running ave App DriverManagerservice ; => Inthe execution of every Java App lots sarbage Daremteneer afservc wilbetarteedinternay tke (eter = Garbagecoletor service andDrieratanager (568) z serie = ~~ => Gorhage Collector service isusefultodestroy stag for) __YRSGLDTverManager clas are) ‘the objects in jova Rvp Pomme ge |-resterorve) > riveritanager Service isusefltomanage [-aderegsterprvert) | static method, setofidbe versus -Seeteonnecton we can acess Gerghog collector service in ouriave APP sing ete system.ge (0), Runtime) methods = we can access DriverManager service in java App using various method java.sq.DriverManager class. note: In ordertouse_jdbe driver s/w in our ava App, it must be placedregistered with DriverManager service . with the support of java.sql.DrverManager ciss.. Registering JOBC driver s/w with DriverManagerServiceis nothing keeping JDBC drier clas object in DrverMManager serve. 91 (Registering orate jb driver s/w with DrivarManagerService) Hfereate jd driver dass object [register Je driver sjw with DriverManager service. DriverManager repisterDriver{ driver) ati method 42: (Registering mys] be driver s/w with DriverManager serie) U create jd driver class object ‘somamsolchidbe Driver obienew comaneso.i db Driver, Uregister je arver s/w ‘DriverManager registerDriver{obj _noteijava App wants to talk with only one D8 s/w then we need to restr only one JDBC driver s/w. with DriverManager service. (eg: transfering money b/W'S8counts of same bank) not: itjave App wants to talk with more then one DE s/w then weneed to register multiple DBC driver ws with DriverManager service. eg: transfering money b/w two accounts of two diferent banks) Snature of resisterDriver() method of riverManager class sa. Driver. driver) throws SQLException terface] ‘ers cllerto_ handle ‘the exception while calling the Since alljdbedrivers/ware gen thelr method Jaber clas names by bnploreting A fovasol. rer crcetryor neectye 20 tre cn pts ay be driver lat objects the af om static void registerDriv ip paints on m neta ypee ie void ma 8 3 imp points on method parameter types = M8 OH sninew 8); vad ree (s)ifjave method parameter typeisaninterface, then we cancallthatmethod PE | milnew cn vs | soar ving any one inplementation lasso thet arface as pune vehi mifoew Of) inal faving anyone iplemetation aso of that iter se evotmate at, | male (o)ifjave method parameter type ian abstract as, the we can cll method — hhving any one susan object of at abstract lass ; ance (citthejavamethod parameter type leconcrat cat then wecan callrethod __publevod mana titer wth concrete das obec or withone subclass ofthat cancetedas. =] fea wad smalnew €)); valid rmilnew D4); vali {Looee coupling) , Standerd steps to develop to JDBC Apo [java Apo with JDBC Persistence logic) (To activate and use JDBC driver s/w) ‘step2) Establish the connection with DB s/w from Java App by using, ‘the je driver s/w that is there with DrivertManager service (itis ike road b/w Java App and Db s/w) stop2) Create Statement object {itacts vehicle to send inputs (SQL queries) to Db s/w from ava App and to gather SAL Query Results (outputs) from DB s/wto java App) step) Send and execute SQL Querives in DB s/w using Stetement object stepS) Use the Statement to gather SOL Query results and to proces the results. step6) Close Connection with Db s/w. teva bop. “| Jae code), | \ (persistence eonglipean txecution este) iat of SAL Quelies 1 Vac aor (Bridge) o “ ‘The vendor companies can use 4+1 (5) ochtectures/mechanisms/methodologies to reate jl cvers/ ws for diff Db s/w based the rules and {DRC speciation glven by Sun Ms (now part of Oracle Corp) Type JDBC driver ARchitecture (JOBC-O08C Brége Driver) “Type2 JOBC driver ARchitecture (Native API/Partly Java driver) | offical =>Type3 JDBC driver ARchitectre (Net Protocol/al Java diver) | andiven Typed JDBC driver ARchitecture (Native Protocol/Al Java drive) | bYSun Ms -=>Type5 JDBC driver ARchitecture ( No Technical name] | ot ofan | idelines JDBCTechnoosy/ =f ay yt ag not coming, Four Wheeler Architectures (Best) note:: Most of vendor companies give thelr JDBC driver s/ws based on Typed Mechanism ... becoz Ieie beet, note: Typed JDBC driver archlecture is designed to locate and Interact with Local or remote DB s/ws Directly with out taking support of other comps. note:: ojdbe6/7/3,Jar, mysal-connector-java- (Typed jdbc driver s/w] + [one | machine 10 >) _DriverManager Service f ’ pom Types jb driver i rrysel Bbw for mysal Cm note::for Every Db s/w , we need seperate typed JDBC driver s/w.. = Typed jdbc driver oracle (eg: ojdbc6/7/8,or) = Typed jdbc driver mysql (eg: mysql-connector-java- jar) Logical DB vs Physical DB s/w DBA->DB Administrator Every Logical DE Is a logical partition of» physical Db s/w (which i installed physically). ‘>in Phylscal Db s/w, multiple Logical Dbs wil be created on 1 per Project basis (DBA creates). > every logical Db maintain its project related dB table, PL/SCIL procedures/functulons, sequences and et _——_physiealoracle bs igs serviced kal pp1 for | oes! DB2 for Heenan: | Senales = logo Db s/w ntaltin we wget sldcp2 ‘One default logic DB..generally whose SID sid:pt "i XE tral version) /ORCL (enterorise Elton) _— \, Logical 083 for rw Project3 Tonow defuatlogca! DB's SID ater instaling oracle logeat Det for | let Project ‘a Taunch sl prompt search run sl command ine sido ) connect to oracle Db s/w ‘emd> connect system/manager ‘connected, get SID ‘SQL>Select * from global_name; XE (sid) (or) ORCL (sie) (or) XEABCOOLYYY (XEIsSID) (or) ORCL.ABCXXX-YYYY (ORCL is SID) Port number vs Socket number => nour computer fh StEFEhven to connect hardware devices to our computer ex: keyboard port, usb por, printer port, mouse port dm port and ete ‘= operating system gives software ports (opal) to maintain executes various software services ote: In windows 08 computer total 65535 (Ito 65,535 software ports are available Inthat 110 1024 pots reserved for OS related srvices(wicows Series) andthe remaning sotrare porte are given fo esteallyinealled s/w (2025 0 65,535) lik mys tomcat and eta. race, cared sf default _portnumber once | ast wats port number cash? ove 3306 web based sal Prompt race default port no: 8080, postarescl sa32 tomest server defauit port: 8080— eee: tomest 2080 por Spa chan] run windows aden) and ete {en number ucan choose byw 10565535) Socket number {ts extension of port number socket numer: + race port number: 521 race Socket number: 1925,775+1821 (or ‘machine30+1821 socket number scaled communication end point. becor using socket number ‘we can connect any service running on any compte. {house no:123/35/a) bose number or howseneme ts Fhe I address or host name fet numberis ke port number. scoket numbers ke both deta togather house number/name + Mat umber: 2 computer being rom that computer wecan use “ocahort or "127.003". race port no 182 Current computer oracle socket number: lcathos1521 aarooassa => Oracle corp supplied Typed mechanism based jdbe drive s/w for odes called “oracle thin” be dvr Its comming inthe form jar file along with Oracle installation. ke abecn Te oabs/7/8 jar (Oracle thin je driver deta name oracle dbe river OracleDrive (ot) oracle. OraceDriver 1@ chostname>/e eps ww fcebookcom/roupe/288095825162910/ :csie> (orotocol subname hostname or Mixed for (ised for ipaddress of race thin Face thin local oracle Logical Dbs/w DB name (or) remote portno (serviced) Stiver) ver) computer ‘here ore s/w Ie ranning Die forlecalxE oracle) | (practice Mbcoracething@127.00.12521:e or local XE race) Yor rmeote XE oracle) (Wor rmeote XE oracle) Iarfles: cassest 1 jar (race a)" ‘laser? ja (orale jdbc jar (race 108) oidbcGjar(oracetig) *—>1P address or hostname jdbcZJar(orace12e) of Remote computer nthe network ejdbeBjar oracle 13c+4) whera remote oracle DB els running protec =>Protocolis bunch of ules followed by two partis who want participate in communication. othere are two types of protocols 8} network protocols “ives st of rules to get communication bfw two physical computers eg: TCP/IP, UDP and ete. ) Application protocols (ives set of ules to get commnucation b/w two sofwares or software appliatons. to orbitps to get communication b/w browser s/w and ‘Webserver sf where the website executes) Mbccoracie ( To get communication b/w Java Append oracle Dbs/w using jdbc driver s/w support) |dbermysal_( To get communication bw Java App and_ mysql Db s/w using abe driver s/w support) and ee. In jdbecrace protec bcs ain protocol ‘races sub protocl, inreene TCP is main protocol IP teeub protec, note: Application Protocols run over (runs onthe tp of network protocols Machines r “isbebmce (ree [ petwore Tore a ‘Write a JDBC App Java App with DB s/w) to establish the connection ‘with oracle DB s/w using oracle thin driver step1) keep the following s/w setup ready =>oracle DB s/w any version (10+) [oracle 11g) idk any version (8+) (idk /11) ~Ealtplus fnotepads+ step2) make sure that Oracle D8 s/w related services are running properly. Go to search ~> services.msc —>services —> search for OracleServiceXE/ORCL, ORacleXETNSlistener | r>make sure they are in running start them to run. Gather SID of Oracle's logical DB to which u want to connect. SQL> select * from global_name XE (sid) (or) ORCL (sid) step) Gather jdbc drivers/w details (orace thin driver details) refer previous details step3) __--Aivorks forall ve stepS}add_jdbc driver s/w reatled jar file to classpath or copy to \ire\lib\ext folder based on active java version.. {only unto javes version) /a App uses any jar file content (like packages,clesses) then that jar file must be added classpath. or should be Steines paaesaes > eaten copied to \ire\lib\ext folder.. settings --> env..varibles—> system variables —> variable name :: CLASSPATH value :: C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbes jar;0k step6} Develop the The Application.. All the methods in System class and. DriverManager class are static methods. \workspaces |-sadvava [--ontaja4 |->idbe |-->ConnTestijava ConnTestjava [1ConnTest.java import jeva.sql.*; //jdbe. public class ConnTest { public static void: Mr (String args{]}throws Exception{ oracle thin driver with DriverManager service U/ create jdbc driver class object ‘oracle jdbe.driver. OracleDriver driver=new oracle,jdbe driver.OracleDriver(}; Iregister jdbe driver DriverManager.registerDriver(driver); static method HHestablish the connection with DB s/w //Connection con=DriverManager.getConnection(" ‘Connection con=DrivertManager.getConnection( Ucheck the connection if{con==null) ‘System.out.printin( ‘connection is not established" else ‘System.out.printin(*Connection is established"); Himain Hiclass Iferd>javac Conntestjava Memc>java ConnTest step7| compile and execute the Application.. cemd> javac ConnTest,java emd> java Contest ‘Connection con=DriverManager.getConnection|"jdbc:oractesthin:@localhost:1521:xe", | static method "system", "manager" ret erie setConnection( (a) Based o iverManager class performs jdberoraclesthin" into of be url it makes the driver manager service to pick up the registered “oracle thin driver” from Driver Manager service. (b) Based on "@localhost:1524:ne" info of jdbc url itlocates the oracle Db s/w runningon 1521 port number having logical DB "xe" on the current current computer and establishes the connection b/w "xo" logical DB of Oracle and java App... In that Process the it submits siven "system" ,"manger" as username,passwords for authentication. (@ returns "JDBC connection object” [iti implementation class obj of java.sal.Connection() back ‘to Java App representing connecton with Db s/w. we are refering that jdbc connection object using java.sql.Connectionl) ref variable (con) Instead of writing two lines of code to register jdbc driver s/w with DriverManager service , we can write single ine of code for the same that “loading db driver class" [Gass tortiarne(“oracle jdbc driver Oracebriver"); 0} nabove ine , how can say jdbe driver registered with DriverlManager service beco? ‘we are just loading bc driver class 7 ‘Ans) Class.forNtame(-} method makes jum to load given jdbe driver dass dynamically ‘atrun time —> In this proesss the static block of jdbe driver class executes and that stati block contains logic to create current jdbe driver class object and to register that ‘object with DriverManager service using registerDriver() method call. Inthe stati block of oracle jdbe.driver.OracleDriver Clase static block of com.mysal.jdbe-Driver stotie( wi DriverManager.registerOriver(new Driver}; defaultviver = new orace jdbc OraceDrive(; ) catch (SOLException vari} { DriverManager.registerDriver(defaultDriver); ‘throw new RuntimeException(*Can't register driver!" ) , Inall jdbc driver classes of different jdbc driver s/w.. we will be having this kind of static block. So we can register all dbe drivers with Driver Manager service by jut loading thelr Jdbe driver cases... with the support Class.forName(-) method... ‘we can write any code using jdbe driver class that makes stati block driver calss getting executed. to register jdbe driver. iver.OracleDriver driver-new oracle jdbc driver OracleDriver); new oracle dbcadriver.OracleDriver)s {Anonymous object) Inthe above two examples .. before creating objects jum loads given Jd driver class and its static block executes having logic to resizer jlbe driver with driver manager service. but the explicitly created ‘objects for driver classes will be wasted..Do these are not good techniques. 63: oracle jdbc: 2: =>jdbe technology atest version is 4.x => 4.3 => oracle latest version ‘upto jdbc there is not feature called auto loading diver lass. Le we must load abe driver class directly or indirectly to register jdbc driver with Driver Manager service. (eg oracle 105 gives ojdbe14jar based jdbc 3 version and it does net support auto loading of driver cals. not =>jdbe4 onwords “Auto loading of driver class" feature is introduced .i.e we need to load jdbc driver class directly or indirectly. we just add jar file to class path and the driver class will loaded automatically. 28: ojdbe7/8/9/20,jar given oracle 11g/12¢/13¢/ wo/19¢ are given based on jdbc. 50 they support auto loading jdbc driver class... So there is no need of writing Shen Seacrest httpt//wwww.java2s.com/Code/Jar/o/Downloadojdbe1 jar html (This is get ojdbe14 jar file) iWoracte 10g based ojibct4jaris added classpath..then we must write ‘lass forNlame(" oracle jdbc driver.OracleDriver"); code in our App.- oracle 11g...19¢ based ojdcs/7/8/2/10 ar file is added to classpath then writing Class.forName("oracie.jdbe-driver.OracleDriver"); code in our Apis optional. How the "Auto Loading of idbc ibe driver class feature" is working from jdbc4 on words? {Q} nthe call to Drivertanager.getConnection(,;).the static block of DriverManager class ‘executes >This static block having logic to search for METAANF/services/java.sal.Driver file inal ja ils that are added to CLASSPATH and it finds in one Jar file like ojdbe6/7/8/9/10,ar file..collets jdbc driver class name from that java.sql.Driver file and loads that cass internally by using Clas.forName(,).. (This s called auto loading driver class) jb <6/7 /8/9/10,jar file is having java.sql Driver file in METAANF/services folder ‘3s shown below , 50 they support autoloading driver cass javasalDriver (fle) ‘orace,jdbe.OracleDriver., ‘ofdbcitjar is given based on jdbe3 and it does not maintain java.sql.Driver fle Sot does nd@tRAB'Foading of driver clas.

You might also like