• Tidak ada hasil yang ditemukan

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

N/A
N/A
Protected

Academic year: 2019

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

Copied!
1144
0
0

Teks penuh

(1)
(2)

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

(3)

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

(4)

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

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 Production Coordinator

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

Technical Architect Steven Livingston Sim on H ardware

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

(5)

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 indow s DN A, 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 .

(6)

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 e-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

(7)

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

(8)

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.

(9)
(10)

Introduction

1

Section I:

The Database

11

Chapter 1:

Internet Programming with Oracle 8i

11

Chapter 2:

Enterprise Application Design

31

Chapter 3:

Database Foundations

53

Chapter 4:

Scaling Your Application with Net8

83

Chapter 5:

Enterprise Development with Designer 6i

105

Section II:

PL/SQL and the Web

171

Chapter 6:

PL/SQL Development

171

Chapter 7:

PL/SQL Server Pages

207

Chapter 8:

The PL/SQL Web Toolkit

225

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 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 17:

Business Components for Java

655

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 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

Appendix A:

Installation Issues

1107

Appendix B:

Java Primer

1145

Appendix C:

XML Primer

1179

Appendix D:

Support, Errata, and p2p.wrox.com

1221

(11)

Int roduction 1

What this Book is About 1

Who Should Use this Book 2

How this Book is Structured 2

The Databas e 3

PL/ S QL and the We b 3

Java 4

XML 5

Appe ndic e s 6

The Tools you Need for this Book 6

De ve lo pme nt Kits 6

We b and Applic atio n S e rve rs 7

To o ls 7

Conventions 7

Customer Support 8

S o urc e Co de and Update s 8

Errata 8

Section I: The Database 1 1

Chapter 1 : Internet Programming with Oracle 8 i 1 1

A Brief History of Oracle 1 2

Versions and Editions of Oracle 8 i 1 3

Programming Support 1 4

PL/ S QL 1 4

The PL/ S QL We b To o lkit 1 5

PL/ S QL S e rve r Page s 1 6

Traditio nal Orac le De ve lo pme nt To o ls 1 6

Orac le Fo rms and Re po rts 1 6

Orac le Po rtal 1 7

(12)

ii

Oracle 8 i and Java 1 8

The Orac le Java Virtual Mac hine 1 9

Advantage s o f the Orac le JVM 2 0

JDK Co m patibility 2 0

Java S to re d Pro c e dure s 2 0

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 ) 2 6

The Evolution to N-Tier Computing 3 3

(13)

Oracle and EAD 4 3

PL/ S QL De ve lo pme nt 4 3

Java De ve lo pme nt 4 4

Co ntaine rs and the Middle Tie r 4 5

S e rvic e s 4 6

Trans ac tio n Manage me nt 4 6

De c larative S e c urity 4 6

Erro r Handling 4 6

Bus ine s s Lo gic 4 6

S c alability 4 7

Po rtability 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

Chapter 3 : Database Foundations 5 3

Database History 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 5 7

DBA Vie ws 5 8

Us e r Vie ws 5 8

All Vie ws 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 6 0

B* Tre e Inde x 6 1

Re ve rs e Ke y Inde xe s 6 2

Bitmappe d Inde xe s 6 2

Func tio n-Bas e d Inde xe s 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

(14)

iv

Oracle 8 i Object/ Relational Database 6 5

Obje c t Type s 6 5

Oracle M emory Structures 6 8

S ys te m Glo bal Are a 6 8

Oracle's Database Initialization File 7 8

(15)

Data Operations 9 5

Designer 6 i Software Architecture 1 0 6

The New Oracle Repository 1 0 8

Re po s ito ry Obje c ts 1 0 8

Cre ate an Entity-Re latio ns hip Diagram 1 3 3

(16)

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 1 4 8

S e le c t the S e ttings fo r Trans fo rmatio n 1 5 0

Exe c ute the Databas e De s ign Trans fo rme r 1 5 3

Re fine the Databas e De s ign 1 5 4

Intro duc ing the De s ign Edito r 1 5 5

Cre ate a S e rve r Mo de l Diagram 1 5 7

Re vie w the Pre liminary Databas e De s ign 1 5 8

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 9

De fine Databas e S e que nc e s 1 6 0

Add Change His to ry Co lumns 1 6 1

Re vie w and Re fine Databas e Co ns traints and Inde xe s 1 6 3

Print the Re vis e d S e rve r Mo de l Diagram 1 6 4

Ge ne rate DDL and Cre ate a Phys ic al Databas e 1 6 4

Invo ke the S e rve r Mo de l Ge ne rato r and S e le c t Optio ns 1 6 5

S e le c t Obje c ts to Ge ne rate 1 6 6

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 7

Exe c ute the Ge ne rate d DDL 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 1 7 9

Data Pac kage s 1 8 0

The e x Exc e ptio n Pac kage 1 8 7

The Te s t Frame wo rk 1 9 1

Dis play Pac kage s 1 9 7

Fo rmatting the Dis play 2 0 4

Ge ne rating the Re po rt 2 0 4

(17)

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 2 1 0

The Page Dire c tive 2 1 0

The pro c e dure Dire c tive 2 1 1

The parame te r Dire c tive 2 1 1

The inc lude Dire c tive 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 2 2 9

Co nfiguring a S im ple Databas e Ac c e s s De s c ripto r (DAD) 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 2 3 3

CGI Enviro nme nt No t Initialize d 2 3 3

Impro pe r privile ge s 2 3 4

Can' t Re s o lve Pac kage / Pro c e dure Name 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 2 3 8

OWA_CACHE 2 3 9

OWA_COOKIE 2 3 9

(18)

viii

OWA_IMAGE 2 4 0

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 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

Chapter 9 : A Stock Tracker using the PL/ SQL Web Toolkit and JavaScript 2 5 7

Overview of the Case Study 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 2 6 8

The bac ke nd S pe c ific atio n 2 6 8

The bac ke nd Pac kage Bo dy 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

(19)

Chapter 1 0 : Web PL/ SQL Application Development Using Designer 6 i 2 9 1

Getting Started 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 2 9 6

Obtain Ac c e s s to the PL/ S QL We b To o lkit 2 9 7

Co nfigure Yo ur We bs e rve r 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 3 1 0

Mo dule Co mpo ne nt Layo ut S tyle s 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

(20)

x

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

(21)

Re turning Que ry Re s ults as XML 3 8 5

Ins talling XS U 3 8 5

Co ding the Cus to me r Clas s 3 8 6

Co mpiling and De plo ying the Cus to m e r Clas s 3 8 7

DML Ope ratio ns in XML 3 8 8

System Architecture Considerations 3 9 0

Pe rfo rmanc e 3 9 0

java.s ql.Callable S tate me nt 4 1 0

Batc h Update s 4 1 6

Re ading and Writing Binary Data 4 3 7

CLOBs 4 4 1

Re ading and Writing Charac te r Data 4 4 2

(22)

xii

Chapter 1 3 : Connection Pooling and Caching 4 5 3

Pooling 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 4 5 5

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

Ove rvie w 4 5 5

Standard Connection Pool 4 5 6

Lo gge r 4 5 7

DBCo nne c tio n 4 5 8

Ins tanc e Variable s 4 5 8

Co ns truc to r 4 5 9

Co nne c ting 4 5 9

Clo s ing the Co nne c tio n 4 6 0

Databas e Me tho ds 4 6 0

DBCo nne c tio nPo o l 4 6 4

Ins tanc e Variable s 4 6 4

Maintaining the Po o l o f Co nne c tio ns 4 6 5

Co ns truc to r 4 6 6

Mo nito ring the Co nne c tio n Po o l 4 6 7

Ge tting a Co nne c tio n Fro m the Po o l 4 6 9

Re turning Co nne c tio ns to the Po o l 4 7 1

Cle aning Up Re s o urc e s 4 7 1

Managing the Co nne c tio n Po o ls 4 7 2

Pro pe rty File s 4 7 2

DBPo o lManage r 4 7 4

Clie nt Example 4 7 9

Pre pare the Databas e 4 7 9

Cre ate the S e rvle t 4 8 0

De plo ying the S e rvle t 4 8 3

JDBC 2 .0 Connection Pooling 4 8 5

Ne w Fe ature s 4 8 5

DataS o urc e 4 8 5

Co nne c tio n Po o ling 4 8 6

Orac le JDBC 2 .0 Exte ns io ns 4 8 7

Co nne c tio n Cac hing 4 8 8

Orac le Co nne c tio n Cac he Im ple m e ntatio n 4 8 9

Alte ring the S tandard Po o l 4 9 1

S ummary o f Update s fro m JDBC 1 .0 4 9 1

DBCo nne c tio n Update s 4 9 2

DBCo nne c tio nPo o l Update s 4 9 4

DBPo o lManage r Update s 4 9 7

(23)

Chapter 1 4 : Database Connectivity with SQLJ 5 0 1

SQLJ Code 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 5 0 6

Orac le .c o nne c t() 5 0 7

Orac le .ge tCo nne c tio n() 5 0 8

Clo s ing the Co nne c tio n 5 0 8

A Simple SQLJ Application 5 0 9

The Cus to me r Clas s 5 1 0

The Us e r Inte rfac e Clas s 5 1 5

Using the SQLJ Translator 5 1 8

Bas ic Trans lato r Ope ratio ns 5 1 9

Pro file s 5 2 0

Catc hing S QL Erro rs 5 2 0

Othe r Bas ic Ope ratio ns 5 2 1

Advanc e d Trans lato r Ope ratio ns 5 2 2

Declarations 5 2 3

S QLJ Ite rato rs 5 2 4

De c laring an Ite rato r 5 2 4

Ite rato r Example s 5 2 5

Cre ating an Ite rato r 5 2 6

Multiple Ro w S e le c tio n Us ing Ite rato rs 5 2 7

Us ing the Im ple me nts Claus e 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 5 4 9

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

S QLJ S e rve r Exam ple 5 5 0

(24)

xiv

Chapter 1 5 : Enterprise JavaBeans and Oracle 5 5 7

Varieties of EJB Components 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 5 6 8

EJB Co m po ne nts 5 7 1

Clie nts 5 7 1

Re mo te Inte rfac e s 5 7 2

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

Re s taurant Re m o te Inte rfac e 5 7 7

Ho me Inte rfac e s 5 7 8

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 9

Re s taurant Ho me Inte rfac e , and Entity Cre ate and Finde r Me tho ds 5 7 9

Entity Primary Ke ys 5 8 1

Imple me ntatio n Clas s e s 5 8 1

Pro pe rtyUpdate r Imple me ntatio n Clas s 5 8 3

Pre fe re nc e Inte rvie we r Imple me ntatio n Clas s 5 8 7

Re s taurant Imple me ntatio n Clas s 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 6 2 1

De plo yme nt 6 2 2

Tro uble s ho o ting 6 2 4

JDe ve lo pe r 6 2 5

(25)

Chapter 1 6 : Inside the Database 6 2 9

Why You Really Need to Deal with the Database 6 3 0

S QL/ 9 2 – A Who le Bunc h o f S tandards 6 3 1

Lo c king Mo de ls 6 3 4

Co nc urre nc y 6 3 9

Trans ac tio ns 6 4 1

Tuning Que rie s 6 4 2

Ope nne s s 6 4 3

Use the Tools the Database Provides 6 4 4

S QL_Trac e 6 4 5

TKPROF 6 4 7

Summary 6 5 3

Chapter 1 7 : Business Components for Java 6 5 5

Components of Oracle BC4 J 6 5 6

Features of BC4 J 6 5 7

Enc aps ulate d Bus ine s s Lo gic 6 5 7

Fle xible Vie ws Of Data 6 5 8

Trans ac tio n Manage me nt 6 5 8

De ve lo pe r Pro duc tivity 6 5 8

Developing with BC4 J 6 5 8

The Restaurant Example 6 5 9

Cre ating a Databas e 6 6 3

Creating the Database Connections in JDeveloper 6 6 4

Creating a Business Components Project using JDeveloper 6 6 5

Imple me nting the S uppo rt Clas s e s 6 6 6

Clas s Ite m 6 6 7

Clas s Orde r 6 6 7

Clas s Orde rLine 6 6 8

Clas s Re s e rvatio n 6 6 9

Clas s Re s taurant 6 7 0

Entity Objects 6 7 0

De fining Validatio n and Bus ine s s Lo gic 6 7 3

Do main Obje c ts 6 7 3

Us ing Do main Obje c ts 6 7 4

S te p 1 : Cre ating Do main Obje c ts 6 7 4

S te p 2 : Adding Validatio n Lo gic 6 7 4

S te p 3 : Binding an Attribute with a Do main 6 7 5

Us ing Built-in Validatio n Rule s 6 7 5

Validatio n Rule s 6 7 6

(26)

xvi

View Objects 6 7 7

Mo re o n Exe c uting a Vie w Obje c t' s Que ry 6 7 9

Re trie ving a Vie w Obje c t’ s Que ry Re s ults 6 8 0

Us ing a Vie w Obje c t to Ins e rt and De le te Ro ws 6 8 3

Ac c e s s ing the Vie w Obje c t Me tho ds fro m the Applic atio n Mo dule 6 8 5

De le ting Ro ws Us ing Vie w Obje c ts 6 8 5

De le ting Ro ws Us ing Vie w Obje c ts 6 8 6

View Links 6 8 6

Us ing the Ac c e s s o r o f the Mas te r Vie w Ro w Clas s to Ac c e s s the Ro ws e t o f a De tail Vie w 6 8 7

Associations 6 8 8

Application M odule 6 8 9

Exc e ptio n Handling Appro ac he s with BC4 J 6 9 0

Expo rting Applic atio n Mo dule Me tho ds to Clie nts 6 9 1

Deploying Business Components 6 9 1

Cre ating a Re mo table Applic atio n Mo dule 6 9 2

Cre ating the De plo yme nt Pro file 6 9 3

Co nne c ting To the De plo ye d Applic atio n 6 9 4

Where Are We Now? 6 9 4

Inserting Data 6 9 5

Building the JSP Client Application 6 9 5

Re s taurants Vie w_ Bro ws e .js p 6 9 6

Bo o kings Vie w_ Ins e rt.js p 6 9 7

Bo o kings Vie w_ S ubmitIns e rtFo rm.js p 6 9 8

Re s taurantBo o kings Link.js p 7 0 0

Orde rLine Ite ms Link.js p 7 0 1

Orde rs Vie w_ Ins e rt.js p 7 0 3

Orde rs Vie w_S ubmitIns e rtFo rm.js p 7 0 4

Orde rLine s Vie w_ Ins e rt.js p 7 0 5

Orde rs Line s Vie w_S ubmitIns e rtFo rm.js p 7 0 6

Run the Application 7 0 7

Deploying the JSPs to iAS 7 0 7

Connecting To an Application M odule 7 0 9

Running the Command Line Client 7 1 1

Tro uble s ho o ting 7 1 3

Transactions 7 1 4

The Ne e d fo r Trans ac tio ns : 7 1 4

Trans ac tio n S uppo rt in BC4 J 7 1 4

Trans ac tio ns and Lo c ks 7 1 5

(27)

Chapter 1 8 : A Discussion Forum using PL/ SQL and Java 7 1 9

Case Study Overview 7 2 0

Applic atio n Arc hite c ture 7 2 1

PL/ SQL Stored Procedures 7 2 4

(28)

xviii

User Interface 7 6 2

Us e r Clas s 7 6 3

Page Fo o te r 7 6 4

Dis playing the Cate go rie s 7 6 5

Dis playing the Me s s age Thre ads 7 6 7

Dis playing Me s s age s 7 7 0

Po s ting Me s s age s 7 7 3

Mo re Page s 7 7 5

Summary 7 7 6

Chapter 1 9 : Overview of Oracle int erM edia Text 7 7 9

Introduction 7 7 9

inte rMe dia te xt que rie s 7 8 0

CONTAINS – the He art o f inte rMe dia Te xt S e arc he s . 7 8 0

Inte rMe dia Inde xe s 7 8 2

DataS to re 7 8 4

Filte rs 7 8 8

S e c tio n Gro ups 7 8 9

S to rage 7 9 4

Le xe r and Lis ts 7 9 4

Bas ic Le xe r 7 9 5

Multi-Le xe r 7 9 6

Lis ts 7 9 6

Othe r Pre fe re nc e s 7 9 7

S pe c ial Ope rato rs 7 9 7

(29)

Chapter 2 0 : Building a Search Engine using Java and int erM edia 8 0 3

Implementing the Search Engine 8 0 6

S e arc h S yntax 8 0 6

XM L Query and Transformation 8 4 1

(30)

xx

JavaServer Pages and XM L 8 5 5

XSQL Pages 8 5 8

XML S ELECT and INSERT 8 6 1

Lo ading a Databas e Us ing XSLT 8 6 5

XM L and Distributed Processing 8 6 7

The XML Clas s Ge ne rato rs 8 6 8

The Java Clas s Ge ne rato r 8 6 9

Using the Oracle XSL Transformation Engine 8 7 6

Trans fo rming Be fo re Dis play 8 7 6

Trans fo rming be fo re Ins e rtio n 8 8 1

XS LT Pe rfo rmanc e 8 8 4

Transviewer JavaBeans 8 8 7

Summary 8 9 1

Chapter 2 2 : A Case Study in Enterprise Applicat ion Development 8 9 3

The Current Setup 8 9 4

CRM System 8 9 5

KM S System 8 9 7

CRM -KM S Integration System 8 9 7

Initial De ve lo pme nt 8 9 7

Future De ve lo pme nt 8 9 8

The Pilot Project 8 9 9

Two-Tier: The Quick and Easy Route 9 0 0

Three Tier: A Better Approach 9 0 3

N-Tier: The Long-Term Solution 9 0 5

N-Tie r Arc hite c ture s : An Ove rvie w 9 0 6

Clus te ring and Lo ad Balanc ing 9 0 7

Using a M odel-View-Controller Framework with N-Tier 9 0 8

The Mo de l-Vie w-Co ntro lle r 9 0 8

Co ntro lle r 9 1 0

Mo de l 9 1 5

Java S to re d Pro c e dure s 9 2 0

Vie w 9 2 7

Exte ns ible Markup Language (XML) 9 2 9

Extensible Stylesheet Language (XSL) 9 3 0

The XS LTManage r 9 3 3

Deployment 9 3 6

Troubleshooting 9 3 6

M igrating from Legacy Applications 9 3 7

(31)

Chapter 2 3 : Applicat ion Integration using SOAP 9 4 1

What is SOAP? 9 4 3

Co nve rs atio n and Me s s age Type s 9 4 4

S OAP Enve lo pe 9 4 4

The S OAP He ade r 9 4 5

Faults 9 4 6

S e rving It Up 9 4 6

S e c urity 9 4 7

Enc o ding Data 9 4 7

Expo s ing S e rvic e s 9 4 7

Imple me nting S OAP 9 4 8

S OAP Arc hite c ture 9 4 9

The Apac he -S OAP 9 5 1

The Apac he -S OAP Lis te ne r 9 5 1

The Mic ro s o ft S OAP To o lkit 9 5 3

The Orac le c lie nt S OAP Im ple me ntatio n 9 5 9

Sample Applications 9 6 8

The Calc ulato r Example 9 6 9

S e rve r Co m po ne nts 9 6 9

Clie nt Co mpo ne nts 9 7 0

LUMA Cars 9 7 9

Bus ine s s Ne e ds 9 7 9

De s c riptio n o f the Applic atio n Do main 9 8 0

LUMA Cars S e rve r Co mpo ne nts 9 8 4

EJB Co m po ne nt 9 8 4

Vis ual Bas ic S e rve r Co m po ne nt 9 9 2

Clie nt Imple m e ntatio n 9 9 3

(32)

xxii

Chapter 2 4 : Wireless Applications with Oracle Portal-to-Go 1 0 0 5

Portal-to-Go as a Wireless Solution 1 0 0 6

A Us e r' s Vie w 1 0 0 6

The De ve lo pe r' s Pe rs pe c tive 1 0 0 6

Portal-to-Go Architecture 1 0 0 7

Obje c ts and the Re po s ito ry 1 0 0 8

Installing Portal-to-Go 1 0 1 0

Ins talling Po rtal-to -Go Binarie s 1 0 1 1

Designing a Web Integration Service 1 0 1 7

Cre ating the WIDL Inte rfac e 1 0 1 8

Cre ating Us e r Ac c o unts 1 0 2 0

(33)

Portal-to-Go SimpleResult XM L 1 0 2 6

S imple Re s ult 1 0 2 6

S imple Co ntaine r 1 0 2 7

S imple Te xt 1 0 2 7

S imple Te xtIte m 1 0 2 7

S imple Me nu 1 0 2 8

S imple Me nuIte m 1 0 2 8

S imple Fo rm 1 0 2 8

S imple Fo rmIte m 1 0 2 9

S imple Fo rmS e le c t 1 0 2 9

S imple Fo rmOptio n 1 0 2 9

S imple Table 1 0 3 0

S imple Table He ade r 1 0 3 0

S imple Table Bo dy 1 0 3 0

S imple Ro w 1 0 3 1

S imple Co l 1 0 3 1

S imple but Po we rful 1 0 3 1

Writing Your Own Adapter 1 0 3 1

Writing and M odifying Existing Stylesheets 1 0 3 8

Personalization Portal 1 0 3 8

A Sample Phone Book Application with LDAP 1 0 3 9

Ins talling Ope nLDAP S e rve r 1 0 3 9

The LDIF File 1 0 3 9

Summary 1 0 4 6

Chapter 2 5 : ASP, XM L and Oracle 1 0 4 9

Why Use ASP with Oracle? 1 0 5 0

ASP for the Uninitiated 1 0 5 1

The ASP Obje c ts 1 0 5 2

The Re que s t Obje c t 1 0 5 3

The Re que s t Obje c t' s Co lle c tio ns 1 0 5 3

The Re s po ns e Obje c t 1 0 5 6

The Re s po ns e Obje c t' s Write Me tho d 1 0 5 6

The Applic atio n and S e s s io n Obje c ts 1 0 5 6

The glo bal.as a File 1 0 5 7

The Applic atio n Obje c t 1 0 5 7

The S e s s io n Obje c t 1 0 5 8

Co lle c tio ns 1 0 5 9

Me tho ds 1 0 5 9

Eve nts 1 0 5 9

The S e rve r Obje c t 1 0 5 9

(34)

xxiv

ActiveX Data Objects (ADO) 1 0 6 0

OLE DB fo r ODBC 1 0 6 1

OO4 O 1 0 6 1

The ADO Obje c t Mo de l 1 0 6 2

Cre ating a Co nne c tio n 1 0 6 2

Re trie ving Re c o rds 1 0 6 4

Curs o r Type 1 0 6 5

Lo c king Type 1 0 6 5

Optio n Value s 1 0 6 6

The BOF and EOF Pro pe rtie s 1 0 6 6

The Re c o rdCo unt Pro pe rty 1 0 6 7

Othe r Us e ful Pro pe rtie s 1 0 6 7

Exe c uting S to re d Pro c e dure s and Func tio ns 1 0 6 7

Re c o rd Lo c king in a S tate le s s HTTP Enviro nme nt 1 0 6 8

Re plic ating Orac le Fo rms Func tio nality 1 0 7 2

Re plic ating Vis ual Attribute s 1 0 7 2

Re plic ating Func tio n Blo c ks 1 0 7 2

Re plic ating Co ntro ls 1 0 7 6

Re plic ating Ite m-Le ve l Trigge rs 1 0 7 7

Re mo te S c ripting 1 0 7 7

Orac le AppWizard fo r Mic ro s o ft Vis ual Inte rDe v 1 0 9 2

Inte gratio n with Orac le De ve lo pe r S e rve r 1 0 9 2

Using ASP and XM L with Oracle 1 0 9 2

The XML S QL Utility 1 0 9 2

The xmlge n Pac kage 1 0 9 2

Re trie ving an XML Do c um e nt fro m the Databas e 1 0 9 3

Ins e rting Ro ws Into the Databas e 1 0 9 6

De le ting Ro ws fro m the Databas e 1 0 9 8

Updating the Databas e 1 0 9 9

Orac le XML Example 1 1 0 1

The S to re d Pro c e dure s 1 1 0 1

The AS P Page 1 1 0 2

(35)

Section V: Appendices 1 1 0 7

Oracle Clients and Net8 1 1 1 7

Ins talling Clie nt Ne two rking S o ftware 1 1 1 7

Co nfiguring Ne t8 1 1 2 2

M ulti-Threaded Server 1 1 2 5

Me mo ry Initializatio n Parame te rs 1 1 2 6

S ys te m Table s pac e and Ro llbac k Se gme nts 1 1 2 7

Installing Oracle SQLJ 1 1 2 7

If Orac le is Ins talle d o n Yo ur Co mpute r 1 1 2 8

SOAP Installation 1 1 3 6

(36)

xxvi

Appendix B: Java Primer 1 1 4 5

Java's History 1 1 4 5

The Java Virtual M achine 1 1 4 6

Developing with Java 1 1 4 6

The Java Platform and the SDK 1 1 4 6

Writing, Compiling and Running Code 1 1 4 7

Clas s path 1 1 4 8

The Java Language 1 1 4 9

Obje c t Orie ntatio n 1 1 4 9

Ke y Co nc e pts 1 1 4 9

De s ign Patte rns 1 1 5 0

Frame wo rks 1 1 5 1

Writing Java Co de 1 1 5 1

An Intro duc tio n to Java Clas s e s and Obje c ts 1 1 5 1

Two S imple Clas s e s 1 1 5 2

Cre ating a c las s 1 1 5 5

Pro pe rtie s and Me tho ds 1 1 5 5

Me tho d Ove rlo ading 1 1 5 8

S truc turing Co de 1 1 5 9

Equality 1 1 6 2

Co ns truc to rs 1 1 6 3

S ubc las s ing 1 1 6 4

Final Me tho ds and Pro pe rtie s 1 1 6 5

S haring Me tho ds and Pro pe rtie s Ac ro s s Ins tanc e s o f a Clas s : the S tatic Mo difie r 1 1 6 7

The ' this ' and ' s upe r' Ke ywo rds 1 1 6 9

Inne r Clas s e s 1 1 7 0

Abs trac t Clas s e s 1 1 7 1

Inte rfac e s 1 1 7 2

Te s ting Yo ur Co de 1 1 7 3

Pac kage s 1 1 7 4

JAR File s 1 1 7 5

Exc e ptio ns 1 1 7 5

(37)

Appendix C: XM L Primer 1 1 7 9

What is a M arkup Language? 1 1 8 0

Tags and Ele me nts 1 1 8 0

Attribute s 1 1 8 1

What is XM L? 1 1 8 1

Ho w XML Do c ume nts are Pro c e s s e d 1 1 8 6

The Bas ic Building Blo c ks o f XML 1 1 8 6

The XML De c laratio n 1 1 8 6

Ele m e nts 1 1 8 7

Attribute s 1 1 8 8

Charac te r Data 1 1 9 0

CDATA S e c tio n 1 1 9 0

Entity Re fe re nc e s 1 1 9 1

Pro c e s s ing Ins truc tio ns 1 1 9 3

Co mme nts 1 1 9 4

Name s pac e s 1 1 9 4

Document Type Definitions 1 1 9 5

The S tandalo ne De c laratio n 1 1 9 6

Ele m e nt De c laratio ns 1 1 9 7

Attribute De c laratio ns 1 2 0 2

No tatio n De c laratio ns 1 2 0 9

Entity De c laratio ns 1 2 1 0

Co nditio nal S e c tio ns 1 2 1 3

Thinking in Tre e s 1 2 1 3

Technology Overview 1 2 1 5

XML S c he mas 1 2 1 5

The Do c ume nt Obje c t Mo de l (DOM) 1 2 1 5

S imple API fo r XML ( SAX ) 1 2 1 8

Summary 1 2 1 9

Appendix D: Support, Errata, and p2p.wrox.com 1 2 2 1

The Online Forums at p2 p.wrox.com 1 2 2 2

Ho w to Enro ll fo r S uppo rt 1 2 2 2

Why This S ys te m Offe rs the Be s t S uppo rt 1 2 2 3

Checking the Errata Online at www.wrox.com 1 2 2 3

Finding an Erratum o n the We b S ite 1 2 2 4

Add an Erratum 1 2 2 5

Cus to m e r S uppo rt 1 2 2 5

Edito rial 1 2 2 5

The Autho rs 1 2 2 5

What We Can' t Ans we r 1 2 2 5

(38)
(39)

The life of the Oracle database programmer is in a state of flux. Oracle Corporation is advancing rapidly into the middle and presentation tiers of the enterprise application with an array of new products and technologies. Perhaps more significantly, with the launch of Oracle 8i, more and more enterprise features are being moved into the database, bringing with them a wealth of new programming possibilities.

There is no doubt that Oracle programmers will continue to be in high demand – Oracle database products still dominate the world market. But there is some work to be done to close the gap between the traditional database programming environment and today's world of the component-based

enterprise-oriented application. That's why Oracle has moved heavily into supporting standards such as Java and XML. And that's the gap that this book fills.

What this Book is About

This is a book about developing applications that use the Oracle 8i database. Since the launch of Oracle 8i, developers have had the option of working not only with PL/SQL but also with Java and XML directly within the database. Oracle Corporation has vigorously supported the integration of these languages, and their associated development tools, into their core database products. These new languages may, or may not, be familiar to database programmers, but the chances are that even if you are experienced in PL/SQL, many of the new programming opportunities in the Oracle environment will be unfamiliar.

(40)

Who Should Use this Book

This book is primarily aimed at programmers with a database background. Oracle has adopted Java and XML in a big way. As a result, a host of new Oracle middle tier and web tier applications have

appeared, based upon these and other new technologies. It is possible to continue following the PL/SQL stream, and to produce great applications, but sometime, someone is going to ask you to write your first Java stored procedure, an XML-enabled customer management system, or a wireless adapter for your existing PL/SQL web product.

This book will break down those barriers for you. You will see plenty of chapters with a mixture of the familiar and the unfamiliar. This will help you work out how these technologies can interact with, and enhance, each other.

How this Book is Structured

To help you use this book and structure your learning, we have divided it into the four sections outlined below. These are not rigid divisions, but they will help you navigate quickly to the area you need most.

Database. Two introductory chapters on the Oracle 8i platform and Enterprise Application Design lead into chapters on database architecture and connectivity, and how to design your database using Oracle Designer 6i. We don't attempt to cover all the database issues that you will need to know in order to work effectively with PL/SQL and Oracle. Some database knowledge, and some SQL programming, are assumed. These chapters will serve as a quick reference point and a source of vital knowledge when you hit problems in your own designs and implementations.

PL/SQL and the Web. In this section of the book, we focus on the web capabilities of Oracle's proprietary database language, PL/SQL. We will look at PL/SQL coding from the point of view of application design and from the point of view of making the best use of PL/SQL when it makes sense to use it in an enterprise application.

Java. Although the Java section is divided approximately into individual Java technologies, there is significant cross-over and you will find that each chapter covers several Java tools, as well as focusing on how to integrate your Java with Oracle, PL/SQL and XML. We cover Java Stored Procedures, JDBC, SQLJ, EJB, BC4J, JavaMail, Servlets and JSPs. Each chapter in this section is database-oriented, and provides a starter database and full set-up instructions. Check out the Java Primer in Appendix B first, if you need to get yourself up to speed.

XML. The idea behind XML is to provide a common communication and data representation language with which to bring together diverse platforms and enterprises. The chapters in this section will show you how to build applications based on an Oracle data tier and connect them to other tiers with XML. You will learn to use Oracle XML Developer's Kit, XML SQL utility, XSLT, ASP, SOAP, interMedia, and Portal-to-Go's SimpleResult XML, along with other techniques for building Java and PL/SQL-enabled applications. We provide an XML primer in Appendix C, for those who need to catch up with the basic XML notions.

(41)

The Database

❑ Chapter 1, Internet Programming with Oracle 8i. This chapter presents the Oracle 8i platform, the new tools and technologies that have appeared or been updated in Oracle 8i and Oracle Internet Application Server (iAS). In particular we set the scene for Oracle and Java, and talk about the new features and programming opportunities that this combination has introduced.

❑ Chapter 2, Enterprise Application Design. Here we take a side step and remind ourselves of why we need to learn all these new languages and design patterns. Whether you are developing a company intranet, a simple web storefront, or a commercial N-tier application, you should be aware of the principles that are emerging in this field. In the chapter, we will look at the evolution of the N-tier approach, and at the challenges it presents to the programmer.

❑ Chapter 3, Database Foundations. Complementing Chapter 16, this is a chapter that will stand you in good stead in your applications programming. This chapter is aimed at those who are moving from middle tier to database tier programming and who need to brush up on what goes on inside the database and how it works.

❑ Chapter 4, Scaling your Applications with Net8. Communicating remotely to the Oracle 8i database introduces a new element: the fallibility and idiosyncrasies of networks. Net8 is the successor to Oracle's SQL*Net, and provides an integrated and homogenous networking solution for Oracle products. However good your application code, you will invariably spend time troubleshooting connectivity problems. This chapter will help you minimize that overhead and give you valuable insight into what is going on beneath the covers when you connect to Oracle.

❑ Chapter 5, Enterprise Development with Designer 6i. Any database application (which means any enterprise database solution) should consider using Oracle Designer and repository-based development to build a manageable and maintainable database infrastructure. This chapter will progress from designing the initial data model and translating it into a database design, to full generation of the database definition code. We'll build the foundations of a web

application for an Education Center database, which we'll continue building in Chapter 10.

PL/SQL and the Web

❑ Chapter 6, PL/SQL Development. This is where the real programming starts. Whatever programs we use to access the database, our calls will be ultimately executed in PL/SQL. We concentrate on the fine art of effective, well-defined and re-usable PL/SQL packages. The chapter contains advice on how to program effectively in a group development environment and we build a test framework for reporting on the status of any P/SQL development effort. This will prepare us for developing with the PL/SQL web toolkit in the remaining chapters of this section of the book.

❑ Chapter 7, PL/SQL Server Pages (PSP). New to Oracle 8.1.6 is the PSP system for serving up entire web applications directly from the database. Using PL/SQL as a scripting language, we can write our PSP pages, compile them and upload them to the database. The pages are then accessed via any web server running a PL/SQL Gateway, such as Apache/mod_plsql on Oracle iAS.

(42)

❑ Chapter 9, A Stock Tracker using the PL/SQL Web Toolkit, XML and JavaScript. Some of the elegance and power of the PL/SQL Web Toolkit will be explored in this case study. We'll build a stock tracking application with a web front end, focusing on good design and clarity in the implementation. As well as showcasing the toolkit features, we'll show how it can work alongside other technologies such as XML, JavaScript and Cascading Style Sheets, to generate finished web applications.

❑ Chapter 10, Web PL/SQL Application Development using Designer 6i. Whereas the previous chapter focused on hand coding of PL/SQL procedures, we look here at how Oracle Designer 6i can generate entire PL/SQL based web applications based on our design specifications. We will extend our Education Center example from Chapter 5 and show how the powerful Web

PL/SQL Generator can enhance productivity and time-to-market for database-powered websites.

Java

❑ Chapter 11, Oracle JVM and Java Stored Procedures. Here we explain how PL/SQL and Java can work together. We look at the Oracle JVM, relating the use of Java to familiar database notions. The chapter progresses from getting your first Java stored procedure uploaded and callable from PL/SQL, to using Oracle Advanced Queuing and Java stored procedures with PL/SQL triggers.

❑ Chapter 12, Oracle Access with JDBC. Java Database Connectivity is the industry standard for accessing SQL databases from Java. Oracle supports JDBC with a number of Java database drivers and extended JDBC features for access to Oracle databases. In this chapter we explore the use of these drivers, with a sequence of clearly worked examples.

❑ Chapter 13, Connection Pooling and Caching. In this chapter, we build on Chapter 12, and move into the world of multiple concurrent JDBC access to the Oracle 8i database, from the middle-tier. We look at how we can reduce the burden on the database by pooling connection resources, instead of opening a new connection for each client. The chapter contains a complete example of a catalogue browser servlet, with middle-tier connection pooling using both JDBC 1.0 and the new JDBC 2.0 specification, and returning the results from the Oracle database.

❑ Chapter 14, Database Connectivity with SQLJ. Now that you have got to work on JDBC, you may have wondered whether there was any easier way of coding SQL into Java programs. SQLJ provides an interesting and productive way of writing more concise and maintainable database access code, using JDBC as the underlying connectivity technology. The chapter progresses through a number of clear examples, exploring the features of this ANSI standard, which is well supported, and has been enhanced, by Oracle.

❑ Chapter 15, Enterprise JavaBeans and Oracle. You will almost certainly have heard of EJBs, but you may not have heard of EJBs running inside an Oracle database. This chapter will introduce you to EJBs from the point of view of the J2EE specification, and then move on to show how we can get EJBs deployed in the Oracle 8i database. We will build a restaurant finder application with the searching and updating features coded into EJBs running in Oracle 8i.

(43)

❑ Chapter 17, Business Components for Java. In this chapter we will build a restaurant booking application with a substantial web interface. We'll use Oracle's BC4J development

environment, built into JDeveloper, to generate our application from scratch, modify it to our needs, and then deploy the business logic as an EJB to Oracle 8i. Then we will publish a JavaServer Pages front end to the Oracle HTTP Server, built into iAS.

❑ Chapter 18, A Discussion Forum with PL/SQL and Java. We extend here the work we did in Chapter 13 on connection pooling. We'll build a discussion forum with a JavaServer Pages interface. The forum will use PL/SQL stored procedures for database operations. We'll use Java code both inside and outside the database. We'll call PL/SQL procedures from Java using JDBC. And this is not all! Although completely self-contained, the case study will be further extended in Chapter 20.

❑ Chapter 19, An Overview of OracleinterMedia Text. Searching capability is a big issue in any enterprise application – the first thing many people do on reaching a website is to search for something. Searching is computationally intensive and therefore expensive. In this chapter we will study the elements of Oracle interMedia and the query language that is supported by this technology, as a way of collating information, creating indexes and optimizing searches.

❑ Chapter 20, Building a Search Engine using Java andinterMedia. We build on the previous two chapters, adding a search facility to the Discussion Forum developed in Chapter 18. Using interMedia, we index all messages in the forum archives, and we can then use JDBC through our connection pooling infrastructure, to get back search results from a wide range of search queries. We display the results using Java Server Pages.

XML

❑ Chapter 21, XML and Oracle. We explore the Oracle XML Developer's Toolkit. We will examine the Oracle Java DOM and SAX parsers that can be used by client or database Java. We will use XSLT transformation, and explore Oracle's notion of combining XML and SQL data access into a scripted page using the XML SQL Utility (XSU). We'll run the XSQL servlet to process these pages. The Oracle Transviewer JavaBeans provide components for building XML-enabled Java applications, and we'll have a look at those too. All of these XML features are demonstrated using worked examples.

❑ Chapter 22, A Case Study in Enterprise Application Development. In this chapter we will put the material we reviewed in Chapter 2 into practice. We'll build an efficient and effective enterprise solution for an internal data centralization problem. We'll use XML as our representation language, XSL, JavaBeans, and a servlet on our web tier, and an EJB running in Oracle 8i.

❑ Chapter 23, Application Integration using SOAP. SOAP is a platform-neutral communications protocol based on XML. It is heavily supported by Apache and Microsoft and is rapidly developing into an important standard. This chapter will show how we can build connectivity between Oracle, Microsoft, Apache and other commercial products using SOAP, and we will work through a substantial case study. Though not directly supported by Oracle yet, this looks like being one to get familiar with now, because it has a big future.

❑ Chapter 24, Wireless Applications with Oracle Portal-to-Go. As we move into the mobile age, there is more and more demand for diverse information sources to be available via wireless devices. In this chapter we will look at setting up the Portal-to-Go client and server

environment, and porting various network resources, such as HTML and LDAP, into a personalized wireless portal. We will examine the integrating protocol, SimpleResult XML, which maps resources to a common format before delivery to individual device types.

(44)

Appendices

As well as an appendix covering installation issues, we have also provided two primers in the appendices for those who are unfamiliar with, or need to brush up on, Java and XML:

❑ Appendix A, Installations Issues. The appendix covers installing Oracle 8i and many of the tools used in the book.

❑ Appendix B, Java Primer. Here we will help get you up to speed on Java. Anyone who is starting out in Java will appreciate the handy reference material and tutorials. Intermediate programmers might appreciate not having to carry another Java book around!

❑ Appendix C, XML Primer. This appendix contains a refresher on XML for the reader who isn't familiar with basic XML concepts, or just needs to get back up to speed.

❑ Appendix D, P2P, Support and Errata. Find out about Wrox Press support and the forums at P2P (Programmer to Programmer).

The Tools you Need for this Book

In this section we give you some advance warning of the software and tools you need to develop the applications in this book. You will need an Oracle 8i database. In order to obtain some reasonable performance from the database you will need a machine that exceeds certain minimum specifications (please see Appendix A for more details). The versions and editions of the database are covered in Chapter 1. You will need development kits, such as Sun Microsystems's JDK and Oracle's XDK. You will need a web server that can run servlets and JSPs. If you install Oracle iAS, then you will have an Apache installation that can be used for all the web applications, including those of the Portal-to-Go chapter. Alternatively, you will need to install Apache. In several chapters we use the Tomcat web server. This can be configured to run with Apache (either standalone or under iAS). To develop the BC4J application in Chapter 17 you will need Oracle JDeveloper.

All Oracle software products, including Oracle 8i, JDeveloper, Oracle iAS and Oracle Portal-to-Go, can be downloaded from the Oracle Technology Network (OTN or sometimes referred to as Technet) at the website http://technet.oracle.com.

Please note: This does not mean that Oracle products, or other downloadable software kits, are free! Before you download anything, please read the licensing agreement very carefully. Please ensure that you do not break the licensing agreement for any

software that you download.

Development Kits

JDK. For Oracle 8.1.5, you will probably want to be working with JDK 1.1.6. For Oracle 8.1.6 and above, you will need to work with JDK 1.2.1. These kits can be obtained from

http://java.sun.com.

XDK. This product, along with several other XML packages used in the book can be downloaded from OTN at http://technet.oracle.com. Please see Appendix A for installation details.

(45)

Web and Application Servers

Apache. You can download the Apache web server from the Apache Foundation at http://www.apache.org.

Tomcat. You can download the Tomcat web application server from the Jakarta Project at http://jakarta.apache.org.

JBoss. This J2EE open source application server is available from JBoss.org at http://www.jboss.com. JBoss is used only in Chapter 23.

Tools

❑ JDeveloper. This Java, XML, BC4J and Oracle-enabled Integrated Development Environment is available for download at OTN. We used JDeveloper 3.1.1.2 for Chapter 17. You will also be able to use JDeveloper to explore most of the code from this book (all chapters with Java), by downloading appropriate material from the Wrox website.

Designer 6i. This application can also be downloaded from OTN.

Conventions

We have used a number of different styles of text and layout in this book to help differentiate between the different kinds of information. Here are examples of the styles we use and an explanation of what they mean:

Code has several fonts. If it's a word that we're talking about in the text, for example when discussing a PL/SQL SELECT query, it's in this font. If it's a block of code that you can type as a program and run, then it's in a gray box:

public void close() throws EJBException, RemoteException

Sometimes you'll see code in a mixture of styles, like this:

<?xml version 1.0?> <Invoice>

<part>

<name>Widget</name> <price>$10.00</price> </part>

</invoice>

In cases like this, the code with a white background is code we are already familiar with; the line highlighted in grey is a new addition to the code since we last looked at it.

Advice, hints, and background information comes in this type of font.

(46)

Bullets appear indented, with each new bullet marked as follows:

Important Words are in a bold type font

❑ Words that appear on the screen, in menus like File or Window, are in a similar font to that you would see on a Windows desktop

❑ Keys that you press on the keyboard like Ctrl and Enter, are in italics

Customer Support

We've tried to make this book as accurate and enjoyable as possible, but what really matters is what the book actually does for you. Please let us know your views, either by returning the reply card in the back of the book, or by contacting us via email at feedback@wrox.com.

Source Code and Updates

As you work through the examples in this book, you may decide that you prefer to type in all the code by hand. Many readers prefer this because it's a good way to get familiar with the coding techniques that are being used.

Whether you want to type the code in or not, we have made all the source code for this book available at our web site at the following address:

http://www.wrox.com/

If you're one of those readers who likes to type in the code, you can use our files to check the results you should be getting - they should be your first stop if you think you might have typed in an error. If you're one of those readers who doesn't like typing, then downloading the source code from our web site is a must!

Either way, it'll help you with updates and debugging.

Errata

We've made every effort to make sure that there are no errors in the text or the code. However, to err is human, and as such we recognize the need to keep you informed of any mistakes as they're spotted and corrected. Errata sheets are available for all our books at http://www.wrox.com. If you find an error that hasn't already been reported, please let us know.

(47)
(48)
(49)

with Oracle 8i

We stand at a crossroads in the evolution of the Oracle database platform. Over the last five years Oracle has transformed itself from being a database provider, to being a complete solution provider for almost every possible enterprise application development requirement.

It has achieved this by embracing open standards languages and technologies such as XML, and the J2EE framework, and by web-enhancing its proprietary PL/SQL standard. This book is for

programmers who know their way around the core Oracle environment, but who need to catch up with the new features of this expanded platform.

Oracle's transformation has been the result of two things: the rise of the Internet as an application platform and the ever-growing demand to have front-to-backend data integration within the enterprise.

Organizations, in order to remain competitive, have to meet three basic criteria:

❑ An organization's data must be available any time and available quickly. With the rise of the Internet, organizations now compete in a global marketplace. This means that there can be no downtime. Data has to be available on a 24x7 basis. Having a stable, high performance database at the heart of your application is a must.

❑ An organization's data must be available from any place. Data has to be readily accessible to both employees and customers. Customers are no longer willing to tolerate organizations that do not "know" who they are.

Gambar

Table continued on following page
Table definitions
table above. Type "CODE" in the Name column.
table definitions. Therefore, especially since you have not made any changes to the server Model since
+7

Referensi

Dokumen terkait

Perbandingan Penyampaian Umpan Balik Seketika dan Terminal terhadap Hasil Belajar Shooting pada Siswa yang Mengikuti Ekstrakuikuler Bola Basket di SMAN 9 Bandung

Gedung H, Kampus Sekaran-Gunungpati, Semarang 50229 Telepon: (024)

Tujuan dari penelitian ini adalah untuk mengetahui bagaimana pemanfaatan smartphone dalam membantu anggota komunitas Love Suroboyo mendapatkan apa yang mereka

The word “scene” is omitted in the data above but it does not eliminate the meaning of source language text. The

Dalam keadaan normal tenaga kerja sudah tidak mau lagi menambah jumlah jam kerja, tetapi dalam kasus ini dimana berkah yang di hasilkan dari bekerja naik, maka tenaga kerja yang

Berdasarkan hasil analisis daya silang atau crossability (karakter biologi), analisis komponen utama dan analisis gerombol (karakter morfologi) didapatkan dua kelompok

Rekonturing dilakukan dengan pertimbangan kondisi gigi ankilosis yang masih baik dengan resorbsi akar minimal, infraklusi sedang dengan mahkota klinis yang cukup untuk dilakukan

Kusumaningtyas, Eni., Astuti., Darmono, 2008, Sensitivitas Metode Bioautografi Kontak dan Agar Ovorlay dalam Penentuan Senyawa Antikapang, Jurnal Ilmu Kefarmasian Indonesia