Sun Educational Services - SL-301 Distributed Programming With Java Technology.pdf

(2595 KB) Pobierz
Distributed Programming With Java
Technology
SL-301
Student Guide
With Instructor Notes
®
Sun Microsystems Inc.
MS BRM01-209
500 Eldorado Blvd.
Broomfield, Colorado 80021
U.S.A.
Revision C.1, March 2000
Copyright © 2000 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California 94303, U.S.A. All rights reserved.
This product or document is protected by copyright and distributed under licenses restricting its use, copying,
distribution, and decompilation. No part of this product or document may be reproduced in any form by any means
without prior written authorization of Sun and its licensors, if any.
Third-party software, including font technology, is copyrighted and licensed from Sun suppliers.
Sun, Sun Microsystems, the Sun Logo, Java, Java 2, JDK, Solaris, JavaSoft, JDBC, JavaBeans, Write Once Run Anywhere,
100% Pure Java, and Java Web Server are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and
other countries.
All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc.
in the U.S. and other countries. Products bearing SPARC trademarks are based upon an architecture developed by Sun
Microsystems, Inc.
Netscape Navigator is a trademark of Netscape Communications Corporation.
UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd.
The OPEN LOOK and Sun Graphical User Interface was developed by Sun Microsystems, Inc. for its users and licensees.
Sun acknowledges the pioneering efforts of Xerox in researching and developing the concept of visual or graphical user
interfaces for the computer industry. Sun holds a non-exclusive license from Xerox to the Xerox Graphical User Interface,
which license also covers Sun’s licensees who implement OPEN LOOK GUIs and otherwise comply with Sun’s written
license agreements.
U.S. Government approval required when exporting the product.
RESTRICTED RIGHTS: Use, duplication, or disclosure by the U.S. Govt is subject to restrictions of FAR 52.227-14(g)
(2)(6/87) and FAR 52.227-19(6/87), or DFAR 252.227-7015 (b)(6/95) and DFAR 227.7202-3(a).
DOCUMENTATION IS PROVIDED "AS IS" AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS,
AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH
DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
Please
Recycle
Contents
About This Course....................................................................................
xiii
Course Goal ....................................................................................... xiii
Course Overview .............................................................................. xiv
Course Map......................................................................................... xv
Module-by-Module Overview ........................................................ xvi
Course Objectives........................................................................... xviii
Skills Gained by Module.................................................................. xix
Guidelines for Module Pacing ......................................................... xx
Topics Not Covered.......................................................................... xxi
How Prepared Are You?................................................................. xxii
Introductions .................................................................................. xxiii
How to Use Course Materials ...................................................... xxiv
Course Icons and Typographical Conventions ......................... xxvi
Icons ......................................................................................... xxvi
Typographical Conventions ................................................ xxvii
Notes to the Instructor.................................................................... xxix
Philosophy ...............................................................................xxix
Course Tools ............................................................................xxix
Instructor Setup Notes .................................................................. xxxii
Overview of Distributed Computing.....................................................1-1
Objectives ............................................................................................1-1
Relevance............................................................................................ 1-2
Additional Resources ....................................................................... 1-3
History of Computing ...................................................................... 1-4
Distributed Computing.................................................................... 1-6
Importance of Distributed Computing ..................................1-7
Characteristics of Distributed Computing ............................1-8
Design Considerations ..................................................................... 1-9
Latency........................................................................................1-9
Partial Failure ............................................................................1-9
Distributed Programming Architectures..................................... 1-11
Overview of Daemon Processes ...........................................1-12
Using Java Technologies to Implement Daemons .............1-13
iii
Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services, March 2000, Revision C.1
Third-Party Java Technologies Using Daemons ................1-15
Understanding Daemons.......................................................1-15
Overview of Remote Procedure Call ...................................1-16
Third-Party Java Technologies Using RPC .........................1-17
Understanding Remote Procedure Call (RPC) ...................1-17
Overview of Remote Objects.................................................1-18
Implementing Remote Objects With Java Technologies ...1-19
Understanding Remote Objects ............................................1-20
Overview of Object Bus Systems ..........................................1-21
JavaBeans InfoBus...................................................................1-22
Understanding Object Bus Systems .....................................1-23
Overview of Mobile Agents ..................................................1-24
Understanding Mobile Agents..............................................1-26
Supporting Technologies for Distributed Computing .............. 1-27
Naming Service .......................................................................1-28
Security Service .......................................................................1-28
Transaction Service .................................................................1-28
Event Service............................................................................1-29
Message Queueing..................................................................1-29
Supporting Technologies .......................................................1-30
Check Your Progress ...................................................................... 1-31
Think Beyond .................................................................................. 1-32
Java Database Connectivity (JDBC)
.......................................................2-1
Objectives ............................................................................................2-1
Relevance............................................................................................ 2-2
Additional Resources ....................................................................... 2-2
Introduction ....................................................................................... 2-3
JDBC Drivers and Driver Managers............................................... 2-4
java.sql
Package ............................................................................ 2-7
JDBC Flow........................................................................................ 2-10
JDBC Programmer’s Interface ....................................................... 2-11
JDBC Example .........................................................................2-12
Exercise: Compiling a JDBC Application .................................... 2-14
Preparation...............................................................................2-14
Tasks .........................................................................................2-14
Exercise Summary...................................................................2-15
Using JDBC Drivers ................................................................2-16
Exercise: Loading a Driver............................................................. 2-18
Tasks .........................................................................................2-18
Exercise Summary...................................................................2-19
Exercise: Loading Driver 2 (Optional) ......................................... 2-22
Tasks .........................................................................................2-22
Specifying a Database.............................................................2-24
NIS Name Resolution Example ............................................2-26
Opening a Database Connection ..........................................2-27
iv
Distributed Programming With Java Technology
Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services, March 2000, Revision C.1
Exercise: Connecting to a Database.............................................. 2-29
Tasks .........................................................................................2-29
Exercise Summary...................................................................2-30
Submitting a Query ................................................................2-31
Using a Prepared Statement ..................................................2-33
Using Callable Statements .....................................................2-36
Receiving Results ....................................................................2-38
Exercise: Executing an SQL Query ............................................... 2-40
Tasks .........................................................................................2-40
Exercise Summary...................................................................2-41
JDBC Driver Architecture .............................................................. 2-44
JDBC Driver Categories .........................................................2-44
Application Designs ....................................................................... 2-46
Two-Tier Application Designs ..............................................2-46
Three-Tier Application Designs............................................2-47
Applets.............................................................................................. 2-48
Applets and Traditional Database Applications ................2-49
Performance Considerations .................................................2-49
Security Limitations................................................................2-49
Exercise: Building a JDBC Application (Optional)..................... 2-50
Preparation...............................................................................2-50
Tasks .........................................................................................2-50
Exercise Summary...................................................................2-52
More Information............................................................................ 2-53
Check Your Progress ...................................................................... 2-54
Think Beyond .................................................................................. 2-55
Remote Method Invocation (RMI)
.........................................................3-1
Objectives ............................................................................................3-1
Relevance............................................................................................ 3-2
Additional Resources ....................................................................... 3-4
What Is Java RMI?.....................................................................3-5
RMI Characteristics...................................................................3-7
RMI Application Architecture.................................................3-9
What Is Serialization? .............................................................3-10
Object Serialization Architecture ..........................................3-12
Writing and Reading to and from an Object Stream .........3-13
Object Streams .........................................................................3-16
The
Externalizable
Interface.............................................3-18
Exercise: Serialization..................................................................... 3-19
Tasks .........................................................................................3-19
Exercise Summary...................................................................3-21
Creating an RMI Application ........................................................ 3-22
Steps to Create an RMI Application.....................................3-23
Deploying an RMI Application.............................................3-29
v
Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services, March 2000, Revision C.1
Zgłoś jeśli naruszono regulamin