Building AS/400 Client/Server Applications with Java
Total Page:16
File Type:pdf, Size:1020Kb
Building AS/400 Client/Server Applications with Java Bob Maatta, Dan Murphy International Technical Support Organization http://www.redbooks.ibm.com SG24-2152-02 International Technical Support Organization SG24-2152-02 Building AS/400 Client/Server Applications with Java July 1999 Take Note! Before using this information and the product it supports, be sure to read the general information in Appendix D, “Special Notices” on page 413. Third Edition (July 1999) This edition applies to OS/400 Version 3, Release Number 2 and later. Comments may be addressed to: IBM Corporation, International Technical Support Organization Dept. JLU Building 107-2 3605 Highway 52N Rochester, Minnesota 55901-7829 When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. © Copyright International Business Machines Corporation 1997, 1998, 1999. All rights reserved Note to U.S Government Users - Documentation related to restricted rights - Use, duplication or disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corp. Contents Contents ..................................................... iii Figures ......................................................ix Tables ......................................................xvii Preface ..................................................... xix The Team That Wrote This Redbook . ..................................xix CommentsWelcome............................................... xx Chapter 1. Object-Oriented Technology Overview ....................1 1.1 Before Object-Oriented Technology . .............................1 1.2Objects....................................................2 1.2.1EncapsulationofObjects...................................3 1.3ClassRelationships..........................................4 1.3.1Specialization...........................................4 1.3.2Composition............................................6 1.3.3 Collaboration............................................6 1.4Polymorphism...............................................7 1.5 Benefits of Object-Oriented Technology . ........................7 Chapter 2. Introduction to VisualAge for Java ......................11 2.1TheVisualAgeFamily........................................11 2.2VisualAgeforJavaOverview..................................12 2.2.1VisualAgeforJavaVersions...............................12 2.2.2IntegratedDevelopmentEnvironment........................14 2.2.3 Components and Features ................................14 2.3IntegratedDevelopmentEnvironment(IDE).......................16 2.3.1 Java Support...........................................16 2.3.2NavigatingwithinVisualAgeforJava.........................17 2.3.3 How It Fits Together . ..................................34 2.3.4BuildingaSampleApplication..............................39 2.3.5TeamDevelopment......................................66 2.3.6AppletsandAppletViewer................................70 2.3.7 Editor, Debugger, and SmartGuides . .......................73 2.4EnterpriseAccessBuilders(EAB)...............................82 2.4.1DataAccessBuilder(DAX)................................82 2.5 System Requirements and Prerequisites for Version 2.0. ............84 2.6MigrationfromVisualAgeforJavaVersion1.0to2.0................85 2.7 Upgrades Available for VisualAge for Java 2.0 .....................87 2.8Summary.................................................88 Chapter 3. AS/400 Toolbox for Java...............................89 3.1 Introduction to the AS/400 Toolbox for Java .......................89 3.1.1 Installing the Toolbox . ..................................90 3.1.2 V4R3 Enhancements. ..................................91 3.1.3 V4R4 Enhancements. ..................................92 3.1.4 Supported Platforms . ..................................94 3.1.5 Application Developer Usage . ............................95 3.1.6AS/400HostServers.....................................95 3.1.7AS400Object,Infrastructure,andSign-On....................95 3.2AS/400ToolboxforJavaandHostServers........................96 © Copyright IBM Corp. 1997, 1998, 1999 iii 3.2.1DataDescriptionsandConversions.........................97 3.2.2AS/400DataTypes..................................... 97 3.2.3RecordLevelConversions................................ 98 3.2.4JDBCSpecification..................................... 99 3.2.5Record-LevelFileAccess............................... 101 3.2.6IntegratedFileSystem.................................. 101 3.2.7Print................................................ 102 3.2.8Command........................................... 103 3.2.9ProgramCall......................................... 103 3.2.10 Data Queue ......................................... 104 3.3HowtheAS/400SystemFitsintoThisPicture.................... 104 3.3.1Security............................................. 105 3.3.2 National Language Support .............................. 105 3.3.3SaveandRestoreConsiderations......................... 106 3.3.4InstallationandRun-TimeConsiderations................... 106 3.3.5ErrorRecoveryConsiderations........................... 106 3.3.6 Mapping AS/400 Data Types to Java Data Types ............. 107 3.4 Introduction to Application Examples . ........................ 107 3.5 AS/400 Database Access ................................... 107 3.5.1JDBCInterface....................................... 108 3.5.2JDBCPerformanceTips................................ 109 3.5.3JDBCApplicationExample.............................. 114 3.5.4JDBCExampleClass................................... 116 3.5.5JDBCExampleDisplayAllClass........................... 124 3.5.6ReusableGUIPart..................................... 126 3.5.7 Stored Procedures. ................................... 127 3.5.8 JDBC Stored Procedure Application Example . ............. 128 3.5.9 StoredProcedureExample Class . ........................ 130 3.5.10DDMRecord-LevelAccessApplicationExample............. 137 3.5.11RLAExampleClass................................... 138 3.5.12DistributedProgramCallFeature......................... 143 3.5.13DistributedProgramCall(DPC)ApplicationExample.......... 144 3.5.14DPCExampleClass................................... 147 3.5.15 Data Queues ........................................ 154 3.5.16 Data Queue Application Example. ........................ 157 3.5.17 DataQueueExample Class .............................. 159 3.6NetworkPrint............................................. 167 3.6.1PrintExample........................................ 168 3.6.2 SpooledFileListExample Class............................ 169 3.7IntegratedFileSystemsAccess............................... 172 3.7.1IntegratedFileSystemExample.......................... 173 3.7.2IFSExampleClass..................................... 176 Chapter 4. AS/400 Toolbox for Java — GUI Classes ................ 181 4.1OverviewoftheGUIClasses................................. 181 4.1.1 AS/400 Panes ........................................ 181 4.1.2JDBC............................................... 183 4.1.3CommandCall........................................ 184 4.1.4 Data Queues ......................................... 184 4.1.5ErrorEvents.......................................... 184 4.1.6Jobs................................................ 185 4.1.7 Messages . ......................................... 185 4.1.8NetworkPrint......................................... 186 iv Building AS/400 Client/Server Applications with Java 4.1.9ProgramCall......................................... 186 4.1.10Record-LevelAccess.................................. 186 4.1.11 Users and Groups . ................................... 187 4.2JDBCExamples.......................................... 187 4.2.1UsingtheAS/400ToolboxClassesintheVCE............... 187 4.2.2SQLResultSetTablePane................................ 188 4.2.3SQLQueryBuilderPane.................................. 194 4.2.4SQLResultSetFormPane................................ 199 4.2.5 SQLResultSetModel ................................... 202 4.3RecordLevelAccessGUIExamples........................... 205 4.3.1RecordListFormPane................................... 205 4.3.2RecordListFormPaneUsingtheKeyedAccessExample........ 208 4.4Conclusion.............................................. 212 Chapter 5. AS/400 Toolbox for Java Modification 2................. 213 5.1 Upgrading the AS/400 Toolbox Contained in VisualAge for Java 2.0 . 213 5.2XML.................................................... 217 5.3PDML.................................................. 217 5.3.1PDMLExample....................................... 218 5.4 The Graphical Toolbox . ................................... 219 5.4.1 Installing the Graphical Toolbox on Your Workstation . ........ 220 5.5 JavaPlug-inforOperationsNavigator......................... 221 5.5.1SettingUptheGUIBuilder............................... 222 5.5.2StartingtheGUIBuilder................................. 223 5.5.3 Creating the New Panel Definition . ........................ 224 5.5.4 Modifying the Databean to Retrieve Data from the AS/400 System 229 5.5.5TestingtheApplication................................. 231 5.5.6AddinganOperationsNavigatorPlug-in.................... 232 5.5.7 Modifying the Windows Registry . ........................ 236 5.5.8TestingtheExtension.................................. 237 5.5.9 Adding a Second Panel to the PDML File ................... 238 5.5.10ModifyingtheSystemStatusEngineDataBean..............