Professional Oracle 8i Application Programming with Java, PL SQL and XML

  

Professional Oracle 8 i Application Programming

  

Michael Awai

Matthew Bortniker

John Carnell

Sean Dillon

Drew Erwin

Jaeda Goodman

  

Bjarki Hólm

Ann Horton

Frank Hubeny

Thomas Kyte

  

Glenn E. Mitchell II

Kevin Mukhar

Gary Nicol

Daniel O'Connor

  

Guy Ruth-Hammond

Mario Zucca

Wrox Press Ltd.  

   

Professional Oracle 8 i Application Programming

  © 2000 W rox Press All righ ts reserved. N o p art of th is book m ay be reproduced, stored in a retrieval system or tran sm itted in an y form or b y an y m ean s, without the prior written perm ission of th e pub lisher, except in th e case of brief quotation s em bod ied in critical articles or reviews. The author and publisher have m ade every effort in the preparation of this book to ensure the accuracy of the inform ation. H owever, the information contained in this book is sold without warranty, either express or implied. N either the authors, W rox Press nor its dealers or distributors will be held liable for any dam ages caused or alleged to be caused either directly or indirectly by this book.

  Pub lished by W rox Press Ltd , Arden H ouse, 1102 W arwick R oad , Acocks G reen,

  Birm ingh am , B27 6BH , U K Prin ted in C anada

  ISBN 1-861004-84-2

Trademark Acknowledgements

  W rox has endeavored to provide trademark inform ation about all the com panies and products m entioned in this book by the appropriate use of capitals. H owever, W rox cannot guarantee the accuracy of this inform ation.

Credits Authors Technical Reviewers Author Agents

  Kevin M ukhar Sean D illon T om Bartlett G ary N icol D rew Erwin D an iel O 'C on nor M ark Fehren bacher Illustrations G uy R uth-H am m ond D ario Ferreira G om es Shab nam H ussain M ario Zucca N ikolay Fiykov

  Fran k H ubeny Cover

  Contributing Authors M an zoor H ussain Shelley Frazier

  San deep an Ban erjee M ike Kay Fran k Bell Aakash Kam buj Proof Readers Bam bi Bellows D oug Kanwischer C h ris Sm ith Kelly C ox V ictor Kolesov Keith W estm orelan d Shekh ar D hupelia T hom as Kyte Agn es W iggers M ichael Kay T od d Lauinger

  Karen Little Production M anager

  M ichael Awai D un can Ainsworth T on y Berry M atth ew Bortn iker D an ny Ayers V elim ir Ilic Joh n C arnell Yogesh Bh and arkar T h e C hurch ill Team G raham Bowd en Project Administrators Sean D illon Luis C abral C ilm ara Lion D rew Erwin R obert C hang C h an d im a N eth isinghe Jaeda G oodm an Jiten d ra C h itkara Bjarki H ólm D aryl C ollin s Indexers An n H orton M ichael C orn ing Alessan d ro An sa Fran k H ubeny Jerem y C rosb ie An d rew C rid dle T hom as Kyte D ean D am eron G lenn E. M itch ell II R ob in D ewson

  T on y D avis Jim M acIn tosh Jen n ifer M cG urk

  Technical Editors V in ay M enon

  Fiver Löcker Jon M illard Jim M olon y Brian Peaslan d M oh am m ed R faquat Sarm a PR KV R obert Shaw Joh n R ob erts

  Jord on Saard ch it

  M anaging Editor An un aya Sh riwastava

  Paul C oop er Leslie T ierstein R aj V uch atu H iroko W ilen sky

  Production Coordinator

  Technical Architect Steven Livingston Sim on H ardware

  

About the Authors

M ichael Awai

  Michael Awai lives near C harlotte, North C arolina, USA. H e is currently a Consulting Partner with a successful privately owned consulting company. H e works as a system architect, helping clients leverage the Internet, build extranet services and accomplish their application and business integration goals. H e and his partner Karla are currently expecting their first baby and their first Irish wolfhound.

  M atthew Bortniker

  M att has been in th e com puter field sin ce 1982 and is an in dep end en t con sultan t for local busin esses in th e W ash ington D C area and for the U S govern m ent. C urrently h is m ain tasks include upgrad in g client server ap p lications to enterprise wide system s written entirely in V isual Basic an d utilizing O racle and M icrosoft technologies. H e is the author of Professional VB6 MTS Programming, ISBN 1861002440,an d con tributing author in Professional W indows DNA, ISBN 1861994451, (both W rox Press). H e can be reached at pc_geek37@hotmail.com.

John Carnell

  Joh n C arnell h as had an obsession with com p uters since h e was twelve years old , workin g on his C om m odore 64. Th at obsession n ever wan ed an d h e is curren tly working as a Sen ior System s Arch itect for W orkscape, a lead ing provider of H um an Resources an d an d Em ployee Benefits self- service solution s. John's favorite topic of d iscussion, m uch to h is wife's chagrin , is com ponent based N -tier arch itectures. John has extensive exp erien ce with M icrosoft, O racle an d Java N -tier solution s. H e lives in W aukesha, W isconsin with h is wife Janet and h is two pup s Lad ybug an d G in ger. Joh n can b e reached at john_carnell@yahoo.com.

  

For my mother Deborah: W hat I have achieved in my life is a summation of your hard w ork, dedication, and

most importantly your sacrifices. And to Janet: Y ou are my inspiration. I love you both.

  The Churchill Team

  C h an d rabh anu Am batipudi, Ekta R an i Agarwal, John Ipe, an d M akaran d Kulkarni form the ‘O racle sup rem e & Java d ream ’ team at C hurch ill Software Services In dia (C SSI). C SSI was establish ed in 1996 in Bangalore In d ia as an O racle offsh ore develop m en t center, b y an ex-O racle U K m anagem ent team . Since its in ception the center has b een serving th e U K m arket with an exclusive focus on the O racle p latform , m esh ing cutting edge tech nologies with estab lished O racle technologies, an d p rovid ing in novative road m ap solution s for the In tern et age.

  Sean Dillon

  Sean got his start program m ing a C om m odore V ic 20, b ack in 1980. T rying to p rogram sprites an d word gam es in the enorm ous 3.5Kb of user m em ory was truly a labor of love. H e is n ow a Sen ior O racle Tech nologist, workin g for O racle C orporation based in R eston, V irginia. H e has eight years of experience specializing in database arch itecture, tun ing, web app lication developm en t, an d now

  X M L-b ased tech nologies. Sean is one of th e lead d esigners on O racle's W eb Education In itiative for ch ildren, T h in k.com . H e is also an avid Q uake p layer. Sean lives outsid e W ash in gton, D C with h is wife, W hitney, and two son s, Jord an an d C am eron .

  I w ould like to thank my w ife for her never-ending support and encouragement.

  Drew Erwin D rew is a techn ical p roject leader and has b een working with O racle products for the last n ine years.

  T h e last three of those have b een ded icated to enterp rise app lication developm en t with the ever ch anging an d im p roving O racle toolset. O utside of work, D rew’s interests in clude h is fam ily, Pam an d H ann ah , h is Playstation, an d traveling.

  Jaeda Goodman

  Jaeda G oodm an is currently working as a Prin cipal Software Engineer for Kean e Ltd., th e com pan y who were respon sible for the Sun C on nect Fram ework. Sh e h as over four years experien ce working with O racle and Java, encom passing everything from data wareh ousin g to EJBs, servlets an d JSPs – an d also InfoBus, if an yone n eed s any ad vice or consultation about th is now esoteric technology. Jaeda’s non -tech nical interests includ e house restoration, Am erican T V im ports, and th e ab ility to m ake an am azing b lue pun ch , although of course the latter does n ot m ix well with all of th e form er, especially InfoBus.

  I'd like to dedicate this to everyone who went through the Synchromatic experience with me.

  Bjarki Hólm

  For m ore than three years Bjarki has b een d esign ing an d d evelop ing com m ercial software tools at SALT System s, In c. H is work in cludes the developm en t of SALT Solution s, a web site con struction suite built with Java tech nology. H is areas of (techn ical) interest in clude Enterprise Java, XM L and e- com m erce O racle ap plication s. In h is working an d waking hours, Bjarki is stud ying com puter engineering at the U n iversity of Iceland , and with his W rox auth oring on top of this, he ten d s to get very little sleep. Bjarki can b e reached at holm@salt.is.

Ann Horton

  Ann H orton is the President of H orton Associates, Inc. and has over twelve years experience designing, developing, and managing O racle projects. She has worked closely with O racle C orporation for many years, is active in the O racle User Group C ommunity, and is a frequent presenter at O DTUG, IO UG-A, RMO UG, and EC O conferences. Ann has been extremely active in the O racle Development Tools User Group (O DTUG) serving as a member of the Board of Directors, conference chairperson, and paper selection chair for numerous conferences, and O DTUG Volunteer of the Year for 2000. Ms. H orton has also worked as an Affiliate Professor for the Regis University evening MSC IS Program since 1992 teaching database classes to working students in the Denver area. In her spare time, Ann enjoys biking, hiking, bird watching, and scuba diving with her husband Dean.

  

Thanks to my husband Dean, my brother Tom, Jim, and Betty, and all my friends who have encouraged me to

participate in this book project! Frank Hubeny Fran k H ubeny is a certified O racle 8i D BA an d currently works for Exp erian doing data warehousing.

  H e has recently worked for W Excel in C h icago where he d esigned an d built databases for web ap p lications an d used th e PL/ SQ L Toolkit exten sively.

  Thomas Kyte

  T hom as Kyte is an O racle p rofessional who works for O racle C orporation in the U S. H e specializes in database arch itecture, im p lem entation, an d tuning. In ad d ition to h is regular duties at O racle, Tom writes an ongoing article for O racle M agazine an d can be found on the web an swering question s via ‘Ask Tom ’ on the O racle M agazine web site. Prior to working for O racle, Tom worked with a contractor develop ing database ap plications an d tools usin g m an y d ifferen t com m ercial database p roducts. Tom lives in Leesb urg V A, U SA with h is wife Lori and two ch ild ren, Alan and M egan.

Glenn E. M itchell II

  G lenn E. M itch ell II, wh o p refers ‘M itch ’, wears m any differen t h ats. H e is p residen t of .C om C onsulting G roup , a com puter-consulting firm in Tallah assee, Florid a. M itch is also a faculty ad m in istrator at the U niversity of South Florida in Tam p a, Florida, where he d irects the State D ata C enter on Aging, teaches graduate and un dergrad uate stud ents, and earn s lots of frequen t flyer m iles. H e also hold s a Ph.D . from the U niversity of Iowa. M itch writes an d speaks at conferences exten sively on object-orien ted analysis an d design, C + + , Java, V isual Basic, an d M icrosoft SQ L Server. W hen not a busy p rofessional, M itch is husb and to Lillian an d d ad to Jessica. Lillian is a veterinarian, whose p assion is sm all an im al m ed icin e. Jessica recently becam e a teen an d sp en ds her sp are tim e alternately stud yin g Latin and listen ing to p op m usic.

  

Mitch wants to dedicate his contribution to his wife, Lillian, who is also a busy professional and tolerates him

spending countless hours in front of the computer.

  Kevin M ukhar

  Kevin Mukhar is a software engineer who lives and works in C olorado, USA. H e spent 12 years in the US Air Force, where many of his jobs included using computers, but none of them involved writing software. Still, he managed to dabble in various languages as a hobby, and had enough practical experience to land a software engineering job when he left the Air Force. For the past two years he has been part of a team that developed a distributed system to manage and access large amounts of binary data from an O racle database. H is heroes are Steve McC onnell and Philip Greenspun. Now that he has finished writing (part of) a book, he understands why many married writers thank their spouse; and so, he too, thanks his wife for tolerating him during the last few months.

Gary Nicol

  G ary N icol is a Senior C onsultant with in th e eBusin ess d ivision of M i Services G roup, an d h as worked on a num b er of web-based projects in volving in tegration of O racle an d M icrosoft tech nologies. H aving origin ally cut h is teeth on a Sin clair ZX Spectrum , h e took a twisted career p ath, via a degree in Electron ic Engin eering, followed b y a brief in carnation as a sem iconductor engineer, before realising that d evelop ing software was a m uch m ore fun way to spen d h is working d ay. In writing for th is book, he has surprised not on ly h im self, but prob ab ly a n um ber of h is high school teachers, wh o would n ever h ave b elieved he was capab le of form ing a coherent senten ce (even when they could read h is han dwriting).

  Daniel O'Connor

  Daniel O 'C onnor is an independent software developer currently working on management applications using J2EE technologies, including EJB and JSP. H e is a member of the board of directors for jBoss.org, an open-source application server featuring an EJB container. H e is one of the authors of the Professional Java

  

Server Programming J2EE Edition , W rox Press, ISBN 186199463. H e is also a principal of MVC Soft, Inc.,

which provides training and consulting on J2EE application development. I would like to dedicate my efforts in this book to Christina Coughlin.

  M ario Zucca

  Som e years ago M ario m oved from the p rocedural world to th e ob ject-orien ted on e. Alth ough it was a d ifficult step to take he's sin ce fallen in love with Java an d J2EE tech nologies and in p articular with

  XM L-related tech nologies such as XSL, XPath and SO AP.

  

I love freedom! I would like to dedicate this book to my daughter Federica. W hen she reads this book, many of the

technologies will be prehistoric things, but I hope in an even freer world.

  Summary of Contents Introduction

  Chapter 8: The PL/SQL Web Toolkit 225

  XML Primer 1179

Appendix D: Support, Errata, and p2p.wrox.com 1221

  Appendix A: Installation Issues 1107 Appendix B: Java Primer 1145 Appendix C:

  

Chapter 22: A Case Study in Enterprise Application Development 893

Chapter 23: Application Integration using SOAP 941 Chapter 24: Wireless Applications with Oracle Portal-to-Go 1005 Chapter 25: ASP, XML and Oracle 1049

Section V: Appendices 1107

  

Chapter 18: A Discussion Forum using PL/SQL and Java 719

Chapter 19: Overview of Oracle interMedia Text 779 Chapter 20: Building a Search Engine using Java and interMedia 803 Section IV: XML 827 Chapter 21: Oracle and XML 827

  Chapter 17: Business Components for Java 655

  

Chapter 13: Connection Pooling and Caching 453

Chapter 14: Database Connectivity with SQLJ 501 Chapter 15: Enterprise JavaBeans and Oracle 557 Chapter 16: Inside the Database 629

  

Chapter 9: A Stock Tracker using the PL/SQL Web Toolkit and JavaScript 257

Chapter 10: Web PL/SQL Application Development Using Designer 6i 291 Section III: Java 343

Chapter 11: Oracle JVM and Java Stored Procedures 343

Chapter 12: Oracle Access with JDBC 393

  Chapter 7: PL/SQL Server Pages 207

  1 Section I: The Database

  Chapter 6: PL/SQL Development 171

  171

  105 Section II: PL/SQL and the Web

  83 Chapter 5: Enterprise Development with Designer 6i

  53 Chapter 4: Scaling Your Application with Net8

  31 Chapter 3: Database Foundations

  11 Chapter 2: Enterprise Application Design

  11 Chapter 1: Internet Programming with Oracle 8i

  Index 1227

Table of Contents

  7 To o ls

  Orac le Fo rms and Re po rts 1 6 Orac le Po rtal 1 6 De s igne r 1 7 1 7

  PL/ S QL The PL/ S QL We b To o lkit 1 4 PL/ S QL S e rve r Page s 1 5 1 6 Traditio nal Orac le De ve lo pme nt To o ls

  1 2 Versions and Editions of Oracle 8 i 1 3 Programming Support 1 4

  8 Section I: The Database 1 1

  8 Errata

  8 S o urc e Co de and Update s

  7 Customer Support

  7 Conventions

  

Int roduction 1

What this Book is About

  1 Who Should Use this Book

  6 De ve lo pme nt Kits

  6 The Tools you Need for this Book

  5 Appe ndic e s

  4 XML

  3 Java

  3 PL/ S QL and the We b

  2 The Databas e

  2 How this Book is Structured

  6 We b and Applic atio n S e rve rs Table o f Co nte nts

  1 8 The Orac le Java Virtual Mac hine

  Advantage s o f the Orac le JVM 1 9 JDK Co m patibility 2 0 Java S to re d Pro c e dure s 2 0 2 0 Diffe re nc e s be twe e n Orac le JVM and JDK 2 0 The J2 EE Frame wo rk and Orac le Java Databas e Co nne c tivity (JDBC) 2 1 S QLJ 2 1 S e rvle ts and JavaS e rve r Page s (JS P) 2 1 Ente rpris e JavaBe ans 2 2 Re mo te Me tho d Invo c atio n (RMI) with CORBA and IIOP 2 2 2 3 JDe ve lo pe r

  2 3 Bus ine s s Co mpo ne nts fo r Java (BC4 J) 2 3

  Oracle XM L Developer's Kit 2 4 Oracle InterM edia 2 5

  Te xt S e rvic e s 2 5 Imaging, Audio , and Vide o S e rvic e s 2 5 Orac le S patial Cartridge 2 5

  Oracle 8 i and the Internet 2 6

  Inte rne t Applic atio n S e rve r (iAS ) Orac le iAS S tandard Editio n 2 6 Orac le iAS Ente rpris e Editio n 2 6 2 6 9 iAS Wire le s s Editio n 2 6 Orac le HTTP S e rve r

  Orac le JS P 2 6 Orac le 8 i JVM 2 7 Po rtal-to -Go 2 7 Orac le iCac he 2 7 2 7 Summary

  2 8

  3 2 The Evolution to N-Tier Computing 3 3

  Two -Tie r Arc hite c ture S c alability 3 3 Hidde n Co s ts 3 4 Fle xibility Is s ue s 3 4 3 4 Thre e -Tie r Arc hite c ture

  Advantage s o f Thre e -Tie r 3 5 Re us e o f Co de 3 6 Pro ble ms with Thre e -Tie r 3 6 3 7 N-Tie r Arc hite c ture S c alability and Re dundanc y 3 8 Inte gratio n 4 0 Adaptability 4 1 Pro ble ms with N-Tie r 4 1 4 2 Table o f Co nte nts iii Oracle and EAD

  4 3 PL/ S QL De ve lo pme nt

  4 3 Java De ve lo pme nt Co ntaine rs and the Middle Tie r 4 4 S e rvic e s 4 5 Trans ac tio n Manage me nt 4 6 De c larative S e c urity 4 6 4 6

  Erro r Handling Bus ine s s Lo gic 4 6 S c alability 4 6 Po rtability 4 7 4 7 Whe n to Us e Java

  4 7 The S uppo rting Cas t o f Orac le S o ftware 4 8 XML 4 8

  Communication Issues 4 9 Summary 4 9

  5 4 Logical Structures 5 6 Components of an Oracle 8 i Database 5 6 Data Dictionary 5 6

  Inte rnal RDBMS Table s 5 7 Data Dic tio nary Table s 5 7 Data Dic tio nary Vie ws DBA Vie ws 5 7 Us e r Vie ws 5 8 All Vie ws 5 8 5 8 Dynamic Pe rfo rmanc e Vie ws

  5 8 Oracle Instance

  5 8 Data File s and Table s pac e s

  5 9 Blo c ks 6 0 S e gme nts 6 0 Table S e gme nts 6 0 Inde x S e gme nts B* Tre e Inde x 6 0 Re ve rs e Ke y Inde xe s 6 1 Bitmappe d Inde xe s 6 2 Func tio n-Bas e d Inde xe s 6 2 6 3 Clus te r S e gme nts

  6 3 Table Clus te rs 6 3 Has h Clus te rs 6 4 Ro llbac k S e gme nts 6 4 Te mpo rary S e gme nts 6 4 Exte nts 6 4 Table o f Co nte nts iv Oracle 8 i Object/ Relational Database

  6 5 Obje c t Type s

  Obje c t Co lumns 6 5 Obje c t Vie ws 6 6 Obje c t Table 6 6 Obje c t Ide ntifie r 6 6 6 7 Co lle c tio ns Ne s te d Table s 6 7 Varrays 6 7 6 8

  Oracle M emory Structures 6 8

  S ys te m Glo bal Are a 6 8 S hare d Po o l 6 9 DB Buffe r Cac he 7 0 Re do Lo g Buffe r Ho w Re do Lo gs Wo rk 7 1 7 2 Pro gram Glo bal Are a

  7 3 Bac kgro und Pro c e s s e s 7 4 S ys te m Mo nito r (SMON) 7 4 Pro c e s s Mo nito r (PMON) 7 5 Databas e Write r (DBWn) 7 5 Re do Lo g Write r (LGWR) 7 5 Che c kpo int (CKPT) 7 6 Optio nal Pro c e s s e s Re do Lo g Arc hive r (ARCH) 7 6 Re c o ve re r (RECO) 7 6 7 7 S tarting an Ins tanc e

  7 8 Oracle's Database Initialization File

  7 8 Control Files 7 9 Recap 7 9 Summary 8 1

  8 4 Why Use Net8 ? 8 4

  Typic al S c e nario s Two -Tie r Clie nt/ S e rve r 8 5 Multi-Tie r Clie nt/ S e rve r 8 5 8 9

  Oracle Connectivity 9 0

  Co nne c ting to a S e rve r The Ne two rk S e rvic e Name 9 1 Ne two rk Ro ute 9 1 Glo bal Databas e Name 9 1 The Co nne c tio n Pro c e s s 9 1 9 1

  Be que athe d S e s s io ns to De dic ate d S e rve r Pro c e s s e s Re dire c te d S e s s io ns to Exis ting S e rve r Pro c e s s e s 9 2 Re fus e d S e s s io ns 9 3 Dis c o nne c ting fro m a S e rve r 9 5 9 5

  Table o f Co nte nts v Data Operations

  9 5 M igrating to Net8 9 6 Net8 Tuning 9 6 Net8 Troubleshooting 9 8

  Diagno s ing the Ne two rk 9 8 Diagno s ing the S e rve r 9 9 Diagno s ing the Clie nt

  1 0 0 S o me Co mmo n ORA Erro rs and What To Do 1 0 1

  Summary 1 0 2

  1 0 6 The New Oracle Repository 1 0 8

  Re po s ito ry Obje c ts 1 0 8 Co ntaine rs 1 0 9 File Obje c ts 1 1 0 Ve rs io n Co ntro l Co nfiguratio ns 1 1 1 De pe nde nc y Analys is 1 1 2 1 1 3 Wo rkare as

  1 1 3 Ove rvie w o f De s igne r 6 i To o ls 1 1 4 S e tting up the Orac le Re po s ito ry Enabling Ve rs io n Co ntro l 1 1 6 Maintaining Us e rs 1 1 7 Adminis te ring the Orac le Re po s ito ry 1 1 7 1 2 0 Intro duc ing the Re po s ito ry Obje c t Navigato r (RON)

  Abo ut Was te bas ke ts 1 2 0 S e le c ting a Re po s ito ry Wo rkare a 1 2 2 Cre ate an Applic atio n S ys te m Co ntaine r 1 2 3 1 2 3 The Case Study

  1 2 5 Ge tting S tarte d

  1 2 6 Ove rvie w Databas e De s ign and De ve lo pm e nt Pro c e s s Us ing De s igne r 1 2 8 1 2 6 De ve lo p a Co nc e ptual Data Mo de l o f Re quire me nts Cas e S tudy Data Re quire m e nts 1 2 8 Orac le ' s Entity Re latio ns hip Diagramming Co nve ntio ns 1 2 9 1 3 0 De ve lo p the Educ atio n Ce nte r Entity-Re latio ns hip Mo de l 1 3 1 Lo g o n to De s igne r Cre ate an Entity-Re latio ns hip Diagram 1 3 2 Cre ate the Entitie s 1 3 3 Cre ate the Re latio ns hips 1 3 4 1 3 6

  Add the Attribute s Cre ate Do mains 1 3 8 As s ign a Do main to an Attribute 1 4 0 De fine a Unique Ide ntifie r fo r e ac h Entity 1 4 2 Print Entity and Attribute Re po rts 1 4 3 Re vie w the ERD' s Quality 1 4 5 1 4 6 Table o f Co nte nts vi

  Trans fo rm the Co nc e ptual Data Mo de l into a Pre liminary Databas e De s ign 1 4 8 S e le c t the Run S e t fo r Trans fo rmatio n S e le c t the S e ttings fo r Trans fo rmatio n 1 4 8 Exe c ute the Databas e De s ign Trans fo rme r 1 5 0 1 5 3 Re fine the Databas e De s ign Intro duc ing the De s ign Edito r 1 5 4 Cre ate a S e rve r Mo de l Diagram 1 5 5 Re vie w the Pre liminary Databas e De s ign 1 5 7 De le ting a Pre liminary Databas e De s ign 1 5 8 Re vis e Eac h Table ' s Co lumn Orde r 1 5 8 1 5 9

  De fine Databas e S e que nc e s Add Change His to ry Co lumns 1 6 0 Re vie w and Re fine Databas e Co ns traints and Inde xe s 1 6 1 Print the Re vis e d S e rve r Mo de l Diagram 1 6 3 1 6 4 Ge ne rate DDL and Cre ate a Phys ic al Databas e

  Invo ke the S e rve r Mo de l Ge ne rato r and S e le c t Optio ns 1 6 4 S e le c t Obje c ts to Ge ne rate 1 6 5 Exe c ute the S e rve r Mo de l Ge ne rato r and Re vie w its Re s ults 1 6 6 Exe c ute the Ge ne rate d DDL 1 6 7 1 6 8 Re vie w the Phys ic al Databas e 1 6 8

  S ummary 1 6 9

  

Section II: PL/ SQL and the Web 1 7 1

  

Chapter 6 : PL/ SQL Development 1 7 1

M inimal Development Environment 1 7 2

  Re fe re nc e Mate rial 1 7 2 Pro gramming Edito r 1 7 2 Ve rs io n Co ntro l S o ftware 1 7 3 S QL Pe rfo rmanc e To o ls 1 7 3 De bugging 1 7 6 Pro filing 1 7 6 Te s ting 1 7 7 Pro gramming S tyle 1 7 8

  Writing PL/ SQL 1 7 8 Building a PL/ SQL Test Framework 1 7 9

  Pac kage s Data Pac kage s 1 7 9 The e x Exc e ptio n Pac kage 1 8 0 The Te s t Frame wo rk 1 8 7 Dis play Pac kage s 1 9 1 Fo rmatting the Dis play 1 9 7 2 0 4

  Ge ne rating the Re po rt 2 0 4 Summary

  2 0 5 Table o f Co nte nts vii

  

Chapter 7 : PL/ SQL Server Pages 2 0 7

Introduction 2 0 7 When to Use PSPs 2 0 8 PSP Architecture 2 0 8 The Anatomy of a PSP 2 0 9

  PSP Dire c tive s The Page Dire c tive 2 1 0 The pro c e dure Dire c tive 2 1 0 The parame te r Dire c tive 2 1 1 The inc lude Dire c tive 2 1 1 2 1 2 PSP De c laratio ns

  2 1 2 PSP S c riptle ts 2 1 3 PSP Expre s s io ns 2 1 4 S o urc e fo r c us t_ de ts .ps p 2 1 5

  Handling Errors in a PSP 2 1 9 Loading a PSP into the Database 2 2 0 What Now? 2 2 1 Summary 2 2 2

  

Chapter 8 : The PL/ SQL Web Toolkit 2 2 5

A Brief History of the Toolkit 2 2 6 When to Use the Toolkit 2 2 6 The Toolkit Architecture 2 2 7 Setting up the Environment 2 2 8

  Co nfiguring iAS Co nfiguring a S im ple Databas e Ac c e s s De s c ripto r (DAD) 2 2 9 2 3 0 Yo u Do n' t Have iAS , Yo u S ay?

  2 3 1 Ins talling the To o lkit 2 3 1 De bugging Yo ur Co nfiguratio n CGI Enviro nme nt No t Initialize d 2 3 3 Impro pe r privile ge s 2 3 3 Can' t Re s o lve Pac kage / Pro c e dure Name 2 3 4 2 3 4

  Building Applications Using the Toolkit 2 3 4

  Yo ur Firs t Dynamic Page 2 3 5 No me nc lature o f a Re que s t 2 3 5 Life c yc le o f a Re que s t 2 3 6

  The Toolkit API 2 3 8 HTF & HTP OWA_CACHE 2 3 8 OWA_COOKIE 2 3 9 OWA_CUS TOM 2 3 9 2 4 0 Table o f Co nte nts viii OWA_IMAGE OWA_ OPT_LOCK 2 4 0 OWA 2 4 0 OWA_ PATTERN 2 4 0 OWA_S EC 2 4 0 OWA_TEXT 2 4 0 OWA_ UTIL 2 4 0 WPG_ DOCLOAD 2 4 0 2 4 1

  Building the Sample Application 2 4 1

  The De partme nt Re po rt 2 4 1 Changing the De partme nt 2 4 3 S ho wing the Us e r' s De tail Re c o rd 2 4 5 The De partme nts Pro c e dure , Explaine d 2 5 2

  Summary 2 5 5

  2 5 8 Application Architecture 2 5 9

  Maintaining S tate o n the Clie nt 2 5 9 The Us e r Inte rfac e s 2 6 0

  Data M odel 2 6 2

  Ac c o unts Table 2 6 3 Funds Table 2 6 4 Trade s 2 6 5 Curre nt Value Table 2 6 6 Trac k Us e r Table 2 6 6 Lo ading Initial Data 2 6 7

  The PL/ SQL Packages 2 6 8

  Bac ke nd Data Pac kage The bac ke nd S pe c ific atio n 2 6 8 The bac ke nd Pac kage Bo dy 2 6 8 2 7 0 Fro nte nd Dis play Pac kage

  2 7 5 Support Files

  2 8 0 JavaS c ript: htm.js

  2 8 1 Javas c ript: s to c ks .js 2 8 2 S tyle S he e t: s to c ks .c s s 2 8 7

  Summary 2 8 9

  Table o f Co nte nts ix

  2 9 2 Overview 2 9 2

  De s igne r' s We b PL/ S QL Applic atio n De ve lo pme nt Pro c e s s 2 9 4 Setup the Web Application Environment

  2 9 6 Cre ate an Applic atio n S c he ma Obtain Ac c e s s to the PL/ S QL We b To o lkit 2 9 6 Co nfigure Yo ur We bs e rve r 2 9 7 2 9 9 Ins tall the De s igne r We bs e rve r Ge ne rato r Library

  3 0 0 Develop the Database Design in Designer

  3 0 1 Generate DDL and Build the Physical Database 3 0 3 Ins e rt Ins truc to r Data into the PERS ON Table 3 0 3 Extend the Database Design with Application Properties 3 0 4 Generate the Table API

  3 0 8 Introduction to Web PL/ SQL M odule Design 3 1 0 Fo rmat o f Ge ne rate d We b PL/ S QL Mo dule s Mo dule Co mpo ne nt Layo ut S tyle s 3 1 0 3 1 1 Define Application-Level Generator Preferences 3 1 1

  De fine an Applic atio n-Le ve l Pre fe re nc e S e t 3 1 2 As s ign the Pre fe re nc e S e t to the Applic atio n 3 1 4 Us ing Cas c ading S tyle s he e ts (Optio nal Exe rc is e ) 3 1 4

  Design and Generate Web PL/ SQL M odules 3 1 6

  COURSE Mo dule Cre ate the Mo dule De finitio n 3 1 6 Cre ate a Mo dule Co mpo ne nt and Table Us age s 3 1 7 Mo dule Co mpo ne nt Dis play Wizard 3 1 8 Us e a Mo dule Diagram to Re fine the Mo dule De s ign 3 2 0 De fine Mo dule Co mpo ne nt Pre fe re nc e s fo r Multi-Ro w Ins e rt Fo rm 3 2 1 3 2 0 Ge ne rate and Exe c ute the Firs t Co urs e Mo dule

  3 2 2 FRCOURSE Mo dule Co py COURS E Mo dule 3 2 6 Re vis e the Mo dule De finitio n 3 2 6 Re vis e the Mo dule Co mpo ne nt 3 2 7 Re vis e the Bas e Table Us age 3 2 7 3 2 7

  Re vis e the Mo dule ' s Ge ne rato r Pre fe re nc e s Re vis e the Mo dule Co mpo ne nt Pre fe re nc e s 3 2 8 Ge ne rate and Exe c ute the FRCOURS E Mo dule 3 2 8 3 2 8 MDCOURS E Mo dule

  Co py COURS E Mo dule 3 2 9 Add the CS Mo dule Co m po ne nt 3 3 0 Re fine the Mo dule Co mpo ne nt' s Dis play 3 3 0 Cre ate LOV Co mpo ne nt 3 3 3 3 3 4 Re vis e the Mo dule ' s Ge ne rato r Pre fe re nc e s Ge ne rate and Exe c ute the MDCOURS E Mo dule 3 3 6 3 3 6

  MAIN Mo dule Cre ate the Main Mo dule 3 3 9 Ge ne rate and Exe c ute the MAIN Mo dule 3 3 9 3 4 1

  Summary 3 4 1 Table o f Co nte nts x

Section III: Java 3 4 3

  

Chapter 1 1 : Oracle JVM and Java Stored Procedures 3 4 3

Java-enabling Infrastructure 3 4 4

  The Orac le 8 i Java Virtual Mac hine Java Name s pac e Im ple m e ntatio n 3 4 5 Co mpile rs : BCOMP and the Orac le 8 i JVM Ac c e le rato r (NCOMP) 3 4 6 3 4 5 The Re s o lve r JDBC and S QLJ 3 4 6 3 4 6

  Java Stored Procedures 3 4 7 Preparing the Development Environment 3 4 8

  Ide ntify and Ins tall the Appro priate JDK 3 4 8 Us e Yo ur JDK Do c ume ntatio n 3 4 8 Ins tall Yo ur IDE 3 4 9 Che c k Yo ur Path Enviro nme nt Variable 3 4 9

  Developing Stored Procedures in Java 3 5 0

  A Date -Fo rmatting Func tio n Co ding and Co mpiling the Java Clas s 3 5 1 Editing and Co mpiling the Co de fro m the Co mm and Line 3 5 1 Editing and Co mpiling the Co de in Orac le JDe ve lo pe r 3 5 2 Examining the Co de 3 5 2 3 5 4

  S imple De bugging with S ys te m .o ut() and S ys te m.e rr() De plo ying to the Databas e 3 5 5 De plo ying fro m the Co mmand Line 3 5 5 Re s o lve r S yntax 3 5 5 Che c king Ins tallatio n S tatus 3 5 6 3 5 6 Othe r lo adjava Optio ns fo r Clas s Lo ading/ Re s o lving Un-ins talling Java Clas s e s with dro pjava 3 5 7 Publis h a Java Clas s Us ing a Call S pe c 3 5 8 Publis hing a Call S pe c into an Orac le Pac kage 3 5 8 Firs t-time Ac tivatio n 3 6 0 3 6 0 De plo ying and Publis hing with Orac le JDe ve lo pe r 3 6 1 A S imple Func tio n Us ing JDBC to Que ry Databas e

  Editing and Co mpiling the Co de 3 6 4 De plo ying S ale s Pe rfo rmanc e fro m the Co mm and Line 3 6 6 Publis hing S ale s Pe rfo rmanc e .ge tAvgS ale s Pe rf() 3 6 6 Java to Orac le Type Mappings 3 6 6 3 6 6 Bo o le an Is s ue s 3 6 8

  Us ing OUT and IN OUT Parame te rs De plo ying ge tAvgS ale s Pe rf() with JDe ve lo pe r 3 6 8 3 7 2 Calling S to re d Pro c e dure s fro m Java S to re d Pro c e dure s 3 7 2

  DML and Trans ac tio ns Re s tric tio ns o n DML-Enable d Java S to re d Pro c e dure s 3 7 4 Trans ac tio ns and S e s s io ns in Java S to re d Pro c e dure s 3 7 7 3 7 7 Trigge rs and Advanc e d Que uing with Java S to re d Pro c e dure s 3 7 8 S e tting up the Que ue Co ding the S to re d Pro c e dure 3 7 9 Co mpiling Us ing the JDK fro m the Co mmand Line 3 8 0 Lo ading the Clas s e s and Publis hing the Call S pe c 3 8 3 3 8 3

  De fining the Trigge r Te s ting the S o lutio n 3 8 4 3 8 4

  Table o f Co nte nts xi

  Re turning Que ry Re s ults as XML Ins talling XS U 3 8 5 Co ding the Cus to me r Clas s 3 8 5 Co mpiling and De plo ying the Cus to m e r Clas s 3 8 6 3 8 7 DML Ope ratio ns in XML

  3 8 8 System Architecture Considerations

  3 9 0 Pe rfo rmanc e Fe ature s 3 9 0 3 9 1 Summary 3 9 1

  3 9 4 Installing JDBC

  3 9 4 Whe re to Ge t Drive rs

  3 9 4 Ins talling the Orac le JDBC Clas s e s 3 9 5 Java Re quire me nts 3 9 6 Che c king Yo ur Ins tallatio n 3 9 7

  JDBC Basics 3 9 8

  Databas e Co nne c tio ns Lo ading a Drive r 3 9 8 Ge tting a Co nne c tio n 3 9 8 Co mmit and Ro llbac k 4 0 2 Clo s ing a Co nne c tio n 4 0 3 4 0 4 S tate me nts

  4 0 4 java.s ql.S tate me nt 4 0 5 java.s ql.Pre pare dS tate m e nt 4 0 8 java.s ql.Callable S tate me nt Batc h Update s 4 1 0 4 1 6 Re s ults e ts Ge tting And Mo ving Thro ugh Re s ults e ts 4 2 4 S c ro llable Re s ults e ts 4 2 6 Re trie ving Data fro m a Re s ults e t 4 2 7 Updatable Re s ults e ts 4 2 8 4 2 9 Me taData

  Databas e Me taData 4 3 5 4 3 5 Advanced Topics

  4 3 6 BLOBs

  Writing a BLOB fro m One Table to Ano the r 4 3 6 Re ading and Writing Binary Data 4 3 7 4 3 7 CLOBs Re ading and Writing Charac te r Data 4 4 1 Re ading and Writing Charac te r Data Us ing Re ade rs and Write rs 4 4 3 4 4 2 BFILEs

  Ge tting a BFILE Lo c ato r 4 4 4 Us ing the Bfile Lo c ato r to Ins e rt a BFILE 4 4 4 Re ading BFILE Data 4 4 4 Ins e rting BFILE Data 4 4 5 4 4 5 Datasources

  4 4 6 Summary 4 5 0 Table o f Co nte nts xii

  4 5 4 Co nne c tio n Po o l Advantage s

  4 5 4 Diffe re nt Type s o f Co nne c tio n Po o ling Ne t8 Co nne c tio n Po o ling 4 5 5 Co nne c tio n Obje c t Po o ling 4 5 5 4 5 5 Ove rvie w

  4 5 5 Standard Connection Pool

  4 5 6 Lo gge r

  4 5 7 DBCo nne c tio n Ins tanc e Variable s 4 5 8 Co ns truc to r 4 5 8 Co nne c ting 4 5 9 Clo s ing the Co nne c tio n 4 5 9 4 6 0

  Databas e Me tho ds 4 6 0 DBCo nne c tio nPo o l

  Ins tanc e Variable s 4 6 4 Maintaining the Po o l o f Co nne c tio ns 4 6 4 Co ns truc to r 4 6 5 Mo nito ring the Co nne c tio n Po o l 4 6 6 4 6 7 Ge tting a Co nne c tio n Fro m the Po o l Re turning Co nne c tio ns to the Po o l 4 6 9 Cle aning Up Re s o urc e s 4 7 1 4 7 1

  Managing the Co nne c tio n Po o ls Pro pe rty File s 4 7 2 DBPo o lManage r 4 7 2 4 7 4 Clie nt Example

  Pre pare the Databas e 4 7 9 Cre ate the S e rvle t 4 7 9 De plo ying the S e rvle t 4 8 0 4 8 3 JDBC 2 .0 Connection Pooling

  4 8 5 Ne w Fe ature s

  DataS o urc e 4 8 5 Co nne c tio n Po o ling 4 8 5 4 8 6 Orac le JDBC 2 .0 Exte ns io ns Co nne c tio n Cac hing 4 8 7 Orac le Co nne c tio n Cac he Im ple m e ntatio n 4 8 8 4 8 9 Alte ring the S tandard Po o l

  S ummary o f Update s fro m JDBC 1 .0 4 9 1 DBCo nne c tio n Update s 4 9 1 DBCo nne c tio nPo o l Update s 4 9 2 DBPo o lManage r Update s 4 9 4 4 9 7 S ummary 4 9 9 Table o f Co nte nts xiii

  5 0 2 Exe c utable S tate me nts

  5 0 2 Ho s t Expre s s io ns 5 0 3 The De fault Co nne c tio n Orac le .c o nne c t() 5 0 6 Orac le .ge tCo nne c tio n() 5 0 7 Clo s ing the Co nne c tio n 5 0 8 5 0 8

  A Simple SQLJ Application 5 0 9 The Cus to me r Clas s The Us e r Inte rfac e Clas s 5 1 0 5 1 5 Using the SQLJ Translator

  5 1 8 Bas ic Trans lato r Ope ratio ns

  Pro file s 5 1 9 Catc hing S QL Erro rs 5 2 0 Othe r Bas ic Ope ratio ns 5 2 0 5 2 1 Advanc e d Trans lato r Ope ratio ns 5 2 2

  Declarations 5 2 3

  S QLJ Ite rato rs De c laring an Ite rato r 5 2 4 Ite rato r Example s 5 2 4 5 2 5 Cre ating an Ite rato r

  Multiple Ro w S e le c tio n Us ing Ite rato rs 5 2 6 Us ing the Im ple me nts Claus e 5 2 7 5 3 2 Co nne c tio n Co nte xts 5 3 5 Co nne c ting to the S ame S c he ma 5 3 6 Co nne c ting to Diffe re nt S c he mas 5 4 0 Exe c utio n Co nte xts 5 4 2

  SQLJ in the Server 5 4 8

  S e rve r vs Clie nt S QLJ S QLJ Runtime Clas s e s 5 4 9 The Databas e Co nne c tio n 5 4 9 Auto -c o mmit 5 4 9 The De fault Output De vic e 5 4 9 5 4 9

  S QLJ S e rve r Exam ple 5 5 0 Summary

  5 5 5 Table o f Co nte nts xiv

  5 5 9 Where EJBs Fit into Sun's Plans for Server-side Java 5 6 0 Do You Need EJB Components in Your Architecture? 5 6 2 Resource Acquisition in J2 EE Components 5 6 3 Transactional Resource Usage 5 6 5 Cooperation with Other Enterprise Technologies 5 6 7 Constructing EJB Components 5 6 8

  Intro duc ing the Re s taurant Finde r Applic atio n EJB Co m po ne nts 5 6 8 Clie nts 5 7 1 5 7 1 Re mo te Inte rfac e s

  Pre fe re nc e Inte rvie we r Re mo te Inte rfac e and Vie w Obje c ts 5 7 2 Pro pe rtyUpdate r Re mo te Inte rfac e and S e s s io n Be an faç ade s 5 7 5 5 7 2 Re s taurant Re m o te Inte rfac e 5 7 7 Ho me Inte rfac e s Pre fe re nc e Inte rvie we r Ho me Inte rfac e 5 7 8 Pro pe rtyUpdate r Ho me Inte rfac e 5 7 8 Re s taurant Ho me Inte rfac e , and Entity Cre ate and Finde r Me tho ds 5 7 9 5 7 9 Entity Primary Ke ys

  5 8 1 Imple me ntatio n Clas s e s Pro pe rtyUpdate r Imple me ntatio n Clas s 5 8 1 Pre fe re nc e Inte rvie we r Imple me ntatio n Clas s 5 8 3 Re s taurant Imple me ntatio n Clas s 5 8 7 5 9 1 De plo yme nt De s c ripto r

  6 0 5 De plo yme nt 6 0 7 S ample Clie nts 6 0 8

  A Solution without Entities 6 1 2

  De plo yme nt De s c ripto rs De plo yme nt 6 2 1 Tro uble s ho o ting 6 2 2 6 2 4 JDe ve lo pe r

  6 2 5 Summary

  6 2 6 Table o f Co nte nts xv