MITEC June 6 2006 IBM System i

Скачать презентацию MITEC June 6 2006 IBM System i Скачать презентацию MITEC June 6 2006 IBM System i

27ad8f247120f053612ce99278edb321.ppt

  • Количество слайдов: 49

MITEC – June 6, 2006 IBM System i 5 IBM Toolbox for Java : MITEC – June 6, 2006 IBM System i 5 IBM Toolbox for Java : Advanced TM Jeff Lee – [email protected] ibm. com

IBM System i 5 Trademarks and Disclaimers 8 IBM Corporation 1994 -2006. All rights IBM System i 5 Trademarks and Disclaimers 8 IBM Corporation 1994 -2006. All rights reserved. References in this document to IBM products or services do not imply that IBM intends to make them available in every country. The following terms are trademarks of International Business Machines Corporation in the United States, other countries, or both: AS/400 e-business on demand i 5/OS AS/400 e IBM OS/400 e. Server IBM (logo) System i 5 i. Series Rational is a trademark of International Business Machines Corporation and Rational Software Corporation in the United States, other countries, or both. Intel, Intel Logo, Intel Inside logo, Intel Centrino logo, Celeron, Intel Xeon, Intel Speed. Step, Itanium, and Pentium are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. Linux is a trademark of Linus Torvalds in the United States, other countries, or both. Microsoft, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both. UNIX is a registered trademark of The Open Group in the United States and other countries. Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. Other company, product or service names may be trademarks or service marks of others. Information is provided "AS IS" without warranty of any kind. All customer examples described are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual environmental costs and performance characteristics may vary by customer. Information concerning non-IBM products was obtained from a supplier of these products, published announcement material, or other publicly available sources and does not constitute an endorsement of such products by IBM. Sources for non-IBM list prices and performance numbers are taken from publicly available information, including vendor announcements and vendor worldwide homepages. IBM has not tested these products and cannot confirm the accuracy of performance, capability, or any other claims related to non-IBM products. Questions on the capability of non-IBM products should be addressed to the supplier of those products. All statements regarding IBM future direction and intent are subject to change or withdrawal without notice, and represent goals and objectives only. Contact your local IBM office or IBM authorized reseller for the full text of the specific Statement of Direction. Some information addresses anticipated future capabilities. Such information is not intended as a definitive statement of a commitment to specific levels of performance, function or delivery schedules with respect to any future products. Such commitments are only made in IBM product announcements. The information is presented here to communicate IBM's current investment and development activities as a good faith effort to help with our customers' future planning. Performance is based on measurements and projections using standard IBM benchmarks in a controlled environment. The actual throughput or performance that any user will experience will vary depending upon considerations such as the amount of multiprogramming in the user's job stream, the I/O configuration, the storage configuration, and the workload processed. Therefore, no assurance can be given that an individual user will achieve throughput or performance improvements equivalent to the ratios stated here. Photographs shown are of engineering prototypes. Changes may be incorporated in production models. 2 © 2006 IBM Corporation

IBM System i 5 IBM Toolbox for Java: Advanced Table of Contents §Introduction §User IBM System i 5 IBM Toolbox for Java: Advanced Table of Contents §Introduction §User spaces §Using the Toolbox on i 5/OS §JDBC (SQL) §Component list §Record-level database access (DDM) §JTOpen (open source) §HTML and Servlet classes §The AS 400 object §System Debugger and Debug Manager §Connection pooling §Command call and program call §Program Call Markup Language (PCML) §Jar. Maker §References §Data queues 3 © 2006 IBM Corporation

IBM System i 5 IBM Toolbox for Java: Advanced §The Toolbox/JTOpen is a set IBM System i 5 IBM Toolbox for Java: Advanced §The Toolbox/JTOpen is a set of Java classes and utilities which provide access to i 5/OS data and resources §Useful in client/server environments - any Java client! –Java client application –Java applet (in browser) –Java servlet - communicating with the i 5/OS from another web server Your Java program TM IBM Toolbox for Java Virtual Machine TCP/IP i. Series Access for Windows is not required! TCP/IP i 5/OS Host Servers IFS i 5/OS data and resources DB 2/400 4 *PGM *CMD © 2006 IBM Corporation

IBM System i 5 §Toolbox runs optimized on i 5/OS - makes direct API IBM System i 5 §Toolbox runs optimized on i 5/OS - makes direct API calls using JNI –Your application code is the same - the Toolbox selects its own implementation based on whether it is running on the i 5/OS or not §Useful in server environments - any Java server –Server to a client application –Server application –Java servlet - running on i 5/OS Your Java program TM IBM Toolbox for Java TCP/IP JNI i 5/OS Host Servers i 5/OS data and resources IFS DB 2/400 5 *PGM *CMD © 2006 IBM Corporation

IBM System i 5 Considerations for running the Toolbox under i 5/OS API set IBM System i 5 Considerations for running the Toolbox under i 5/OS API set to use: §Native JDBC driver vs Toolbox JDBC driver §java. io. File vs IFSFile §Portability vs complexity Ÿ JNI vs Program. Call / Command. Call CRTJVAPGM on Toolbox file §jt 400. jar or jt 400 Native. jar AS 400 object can use current job's user ID and password §When Java program and data are on the same system running i 5/OS §When Java program on one system running i 5/OS and data is on another system running i 5/OS Many Toolbox components can stay in the current job using native API calls instead of a server job. §Other functions still use server job §Command. Call and Program. Call do this conditionally Ÿ based on whether the command or program is threadsafe Ÿ see the set. Thread. Safe() method 6 © 2006 IBM Corporation

IBM System i 5 Component list (part 1) Component Toolbox includes… Native optimization AS IBM System i 5 Component list (part 1) Component Toolbox includes… Native optimization AS 400 object • • • • • AS 400 JPing/JPing Authentication (com. ibm. as 400. security. auth package) Clustered Hashtables Command call Connection pool Data area Data conversion Data description Data queue Digital cerificate Environment variable File Transfer Protocol (FTP) Graphical Toolbox (com. ibm. as 400. ui. * package) GUI classes (com. ibm. as 400. vaccess package) HTML classes (com. ibm. as 400. util. html package) - Components in com. ibm. as 400. access package unless otherwise noted 7 © 2006 IBM Corporation • •

IBM System i 5 Component list (part 2) Component Toolbox includes… Native optimization Integrated IBM System i 5 Component list (part 2) Component Toolbox includes… Native optimization Integrated file system (IFS) • • • • Use java. io. File Jar. Maker Java application call Java program information JDBC Job and job log Message file Message queue Micro Edition classes (com. ibm. as 400. micro package) Net. Server Permissions Print (e. g. spooled files, printers) Product license PTF, PTFCover. Letter Product, Product. List - Components in com. ibm. as 400. access package unless otherwise noted 8 © 2006 IBM Corporation Use native JDBC driver

IBM System i 5 Component Toolbox includes… Native optimization Program call • • Program IBM System i 5 Component Toolbox includes… Native optimization Program call • • Program Call Markup Language (PCML & XPCML) (com. ibm. as 400. data package) Proxy server Record-level database access Record Format Markup Language (RFML) Resource framework (com. ibm. as 400. resource package) • Secure Sockets Layer (SSL) Service program call Servlet classes (com. ibm. as 400. util. servlet package) Software resources System Debugger (tes. jar) System pool System status System value Toolbox installer • • • Users and groups • User Space • Validation list • - Components in com. ibm. as 400. access package unless otherwise noted 9 © 2006 IBM Corporation • • •

IBM System i 5 JTOpen (Open Source) All of the primary Toolbox packages are IBM System i 5 JTOpen (Open Source) All of the primary Toolbox packages are open source! http: //jt 400. sourceforge. net § Part of IBM's open source development community § Use source as a debug tool § Submit new function under the IBM Public License (IPL) § Modify source for your use § Submit problem reports and bug fixes Two versions of the Toolbox: §Licensed program Ÿ Supported by IBM Ÿ Fixes delivered by PTFs §Open source version Ÿ Supported by open source community Ÿ Now officially supported by IBM Service! Ÿ Includes source from non-IBM contributors Ÿ New functions and fixes available here first! 10 © 2006 IBM Corporation Latest version is JTOpen 5. 1. 1

IBM System i 5 The AS 400 object Represents a connection to the i IBM System i 5 The AS 400 object Represents a connection to the i 5/OS Encapsulates security/identity §Password caching available §Establish a default User. ID §Sign-on GUI if User. ID/password not supplied by application §Change password GUI when appropriate §Provides Secure Sockets Layer (SSL) communication –Encryption and server authentication Most Toolbox classes use the AS 400 object 11 © 2006 IBM Corporation

IBM System i 5 When running on i 5/OS, Toolbox can pick up current IBM System i 5 When running on i 5/OS, Toolbox can pick up current job's user ID and password §Use default constructor or *CURRENT new AS 400(); new AS 400("localhost", "*CURRENT"); Represents a connection to the i 5/OS §Single vs multiple identities §Single vs multiple connections §Implicit vs explicit connection AS 400 sys = new AS 400(); // if on client, will prompt for system, uid, pwd AS 400 sys 2 = new AS 400("my. System"); // if on client, will prompt for uid, pwd AS 400 sys 3 = new AS 400("my. System", "uid 1", "pwd 1"); AS 400 sys 4 = new AS 400("my. System", "uid 2", "pwd 2"); Command. Call cc = new Command. Call(sys); Command. Call cc 2 = new Command. Call(sys); Command. Call cc 3 = new Command. Call(sys 3); Command. Call cc 4 = new Command. Call(sys 4); 12 // cc and cc 2 will share a connection // cc 3 and cc 4 tasks will go against // different profiles © 2006 IBM Corporation

IBM System i 5 Connection pooling can improve performance §Each new connection to the IBM System i 5 Connection pooling can improve performance §Each new connection to the server can be an expensive operation §Pooling means reusing AS 400 objects - i. e. keeping the connection open for later §Saves frequent disconnects and reconnects §Common scenario: servlets ƒ Without pooling: Create a new AS 400 object for each invocation of the servlet ƒ With pooling: Grab a preconnected AS 400 object from the pool for each invocation of the servlet, return it when done! §Connections will be added as needed Connection pool 13 © 2006 IBM Corporation

IBM System i 5 Set up the connection pool AS 400 Connection. Pool pool IBM System i 5 Set up the connection pool AS 400 Connection. Pool pool = new AS 400 Connection. Pool(); pool. set. Max. Connections(128); // Preconnect 5 connections to the AS 400. COMMAND service. pool. fill("my. AS 400", "my. User. ID", "my. Password", AS 400. COMMAND, 5); Connection pool Use a connection from the pool AS 400 connection = pool. get. Connection("my. AS 400", "my. User. ID", "my. Password", AS 400. COMMAND); Connection pool Command. Call cmd = new Command. Call(connection); cmd. run("CRTLIB FRED"); Return it to the pool when done Connection pool. return. Connection. To. Pool(connection); 14 © 2006 IBM Corporation

IBM System i 5 Command call and program call Make use of legacy code IBM System i 5 Command call and program call Make use of legacy code and system APIs Java program AS 400 system = new AS 400(); Command. Call cc = new Command. Call(system); cc. run("CRTLIB NEWLIB"); Input parameters Output parameters and messages AS 400 system = new AS 400(); Program. Parameter[] parm. List = new Program. Parameter[n]; parm. List[0] = new Program. Parameter(data); . . . Program. Call pc = new Program. Call(system, "/QSYS. LIB/MYLIB. LIB/MYPGM. PGM", parm. List); pc. run(); 15 © 2006 IBM Corporation

IBM System i 5 Program Call Markup Language (PCML) Describe program calls using XML IBM System i 5 Program Call Markup Language (PCML) Describe program calls using XML Parameter handling in traditional Toolbox Program. Call can be tedious. PCML: §Simplifies data description and conversion §Iterative development without recompile Input parameters Output parameters and messages 16 © 2006 IBM Corporation

IBM System i 5 Traditional Program Call vs PCML Call Retrieve User Information API IBM System i 5 Traditional Program Call vs PCML Call Retrieve User Information API using PCML type="int" type="char" type="byte" type="int" type="char" type="byte" type="int" type="char" length="4" length="10" length="7" length="6" length="1" length="4" length="10" length="8" length="1" length="4" length="8" length="4" length="10" usage="output"/> usage="output"/> usage="output"/> usage="output"/> usage="output" usage="input" struct="usri 0100"/> /> init="USRI 0100" /> init="*CURRENT" /> init="0" /> pcml = new Program. Call. Document(as 400 System, "qsyrusri"); pcml. set. Value("qsyrusri. receiver. Length", new Integer((pcml. get. Outputsize("qsyrusri. receiver")))); rc = pcml. call. Program("qsyrusri"); value = pcml. get. Value("qsyrusri. receiver. bytes. Returned"); 17 © 2006 IBM Corporation

IBM System i 5 Traditional Program Call vs PCML Call Retrieve User Information API IBM System i 5 Traditional Program Call vs PCML Call Retrieve User Information API using traditional Program. Call AS 400 Bin 4 bin 4 = new AS 400 Bin 4(); AS 400 Text char 6 = new AS 400 Text(6, as 400 System); AS 400 Text char 7 = new AS 400 Text(7, as 400 System); AS 400 Text char 8 = new AS 400 Text(8, as 400 System); AS 400 Text char 10 = new AS 400 Text(10, as 400 System); Program. Call pc = new Program. Call(as 400 System); pc. set. Program("/QSYS. LIB/QSYRUSRI. PGM"); Program. Parameter[ ] parms = new Program. Parameter[5]; parms[0] = new Program. Parameter(100); parms[1] = new Program. Parameter(bin 4. to. Bytes(100)); parms[2] = new Program. Parameter(char 8. to. Bytes("USRI 0100")); parms[3] = new Program. Parameter(char 10. to. Bytes("*CURRENT")); byte[ ] error. Area = new byte[32]; parms[4] = new Program. Parameter(error. Area, 32); pc. set. Parameter. List(parms); pc. run(); byte[ ] data = parms[0]. get. Output. Data(); int value = ((Integer) bin 4. to. Object(data, 4)). int. Value(); 18 © 2006 IBM Corporation

IBM System i 5 Data Queues Store data entries in a queue for processing IBM System i 5 Data Queues Store data entries in a queue for processing §Good for message passing across multiple processes §Data. Queue or Keyed. Data. Queue §Supports clear, peek, read, and write operations §Entries on queue can be ordered LIFO or FIFO §Authority parameter useful to limit access §Persistent Entries are in the form of Data. Queue. Entry objects §Return entry data as bytes (no data conversion) §Return entry data as a String (converted to Unicode) §Entry size set when queue is created (max. 64 KB) 19 © 2006 IBM Corporation

IBM System i 5 Data Queues Example: Using a Data. Queue Process A Process IBM System i 5 Data Queues Example: Using a Data. Queue Process A Process B // Create a Data. Queue object to represent a specific data queue. AS 400 system = new AS 400("MYSYSTEM", "MYUSERID", "MYPASSWORD"); Data. Queue dq = new Data. Queue(system, "/QSYS. LIB/MYLIB. LIB/MYQUEUE. DTAQ"); // If it doesn't exist, create it. if (!dq. exists()) { dq. create(1024); // Entry length is 1 KB } while (some. Condition == true) { // Wait forever until an entry appears on the queue, then read it. Data. Queue. Entry entry = dq. read(); // Write something to the queue. // The other process will read it. dq. write("Some useful information. "); // When all done with the queue, delete it. dq. delete(); // Process the entry's data. String information = entry. get. String(); } 20 © 2006 IBM Corporation

IBM System i 5 User Spaces Store data in an indexed memory IBM System i 5 User Spaces Store data in an indexed memory "space" §Good for sharing common data across multiple processes §Supports read and write operations §Specify offset to index inside the user space §Set initial value and length properties §Max. length is just under 16 MB §Authority parameter useful to limit access §Persistent Some i 5/OS APIs return output data in a user space instead of in a Program. Call output parameter 21 © 2006 IBM Corporation

IBM System i 5 RFML (Record Format Markup Language) Very similar to PCML (Program IBM System i 5 RFML (Record Format Markup Language) Very similar to PCML (Program Call Markup Language) While PCML is designed only for Program Parameters, RFML is useful for parsing/composing: Ÿ Data queue entries Ÿ User spaces Ÿ Physical file records Ÿ Data buffers Specify record formats using XML; get/set field values Segregate the data layout from the program logic 22 © 2006 IBM Corporation

IBM System i 5 RFML vs. Field. Description Example: Composing a customer record Without IBM System i 5 RFML vs. Field. Description Example: Composing a customer record Without RFML: import com. ibm. as 400. access. AS 400 Text; import com. ibm. as 400. access. AS 400 Unsigned. Bin 2; import com. ibm. as 400. access. AS 400 Zoned. Decimal; import com. ibm. as 400. access. Binary. Field. Description; Using RFML: import com. ibm. as 400. access. Character. Field. Description; import com. ibm. as 400. access. Record. Format; import com. ibm. as 400. data. Record. Format. Document; import com. ibm. as 400. access. Zoned. Decimal. Field. Description; Record. Format. Document rfml. Doc = new Record. Format. Document("customer"); Record. Format rec. Fmt = new Record. Format("cusrec"); ( In a separate file named "customer. rfml": ) AS 400 Unsigned. Bin 2 conv 1 = new AS 400 Unsigned. Bin 2(); Binary. Field. Description desc 1 = new Binary. Field. Description(conv 1, "cusnum"); rec. Fmt. add. Field. Description(desc 1); AS 400 Text conv 2 = new AS 400 Text(8, 37); Character. Field. Description desc 2 = new Character. Field. Description(conv 2, "lstnam"); rec. Fmt. add. Field. Description(desc 2); AS 400 Zoned. Decimal conv 3 = new AS 400 Zoned. Decimal(6, 2); Zoned. Decimal. Field. Description desc 3 = new Zoned. Decimal. Field. Description(conv 3, "baldue"); rec. Fmt. add. Field. Description(desc 3); 23 © 2006 IBM Corporation

IBM System i 5 JDBC The Java standard for database access Write Java programs IBM System i 5 JDBC The Java standard for database access Write Java programs in terms of standard JDBC interfaces, then plug in any JDBC driver - to work with any database! §Java gives you platform independence, JDBC gives you database independence java. sql package in Java Developers Kit SQL is used extensively §Based on X/Open SQL Call Level Interface Also supports: §Database definitions, manipulations, and queries §Stored procedures §Catalog methods §Transactions (commit, rollback, isolation levels, distributed) 24 © 2006 IBM Corporation

IBM System i 5 JDBC The Java standard for SQL database access Java program IBM System i 5 JDBC The Java standard for SQL database access Java program JDBC Driver Manager Another JDBC Driver Other Database 25 "Native" DB 2 JDBC Driver IBM Toolbox for Java JDBC Driver DB 2/400 Database © 2006 IBM Corporation JDBC to ODBC Bridge ODBC Driver Other Database

IBM System i 5 JDBC Registering a JDBC driver A JDBC driver must be IBM System i 5 JDBC Registering a JDBC driver A JDBC driver must be registered with the Driver. Manager: §Most JDBC drivers will register themselves when they are loaded w. Class. for. Name("JDBC. driver. class. name"); // this is the preferred method §You can also register JDBC drivers explicitly w. Driver. Manager. register. Driver(new JDBC. driver. class. name()); §The Driver. Manager can now dispatch requests to the registered JDBC driver // Register using a Java property java -Djdbc. drivers=com. ibm. as 400. access. AS 400 JDBCDriver my. Program // Register by writing Java code java. sql. Driver. Manager. register. Driver(new com. ibm. as 400. access. AS 400 JDBCDriver()); java. sql. Driver. Manager. register. Driver(new com. ibm. db 2. jdbc. app. DB 2 Driver()); 26 © 2006 IBM Corporation

IBM System i 5 JDBC Connecting to a database §Use the Driver. Manager to IBM System i 5 JDBC Connecting to a database §Use the Driver. Manager to connect to a database w. Connection connection = Driver. Manager. get. Connection("jdbc: yourdatabase's-URL"); §Userid and password are optional §The Driver. Manager will dispatch the connection request to the appropriate JDBC driver §Some drivers recognize additional connection properties Properties conn. Props = new Properties(); conn. Props. put("cursor hold", "0"); conn. Props. put("date format", "iso"); Connection c = Driver. Manager. get. Connection("jdbc: as 400: //my. System", conn. Props); 27 © 2006 IBM Corporation

IBM System i 5/OS JDBC driver choices IBM Toolbox for Java JDBC driver com. IBM System i 5/OS JDBC driver choices IBM Toolbox for Java JDBC driver com. ibm. as 400. access. AS 400 JDBCDriver §Communicates with the database host server using TCP/IP sockets §Provides extended dynamic performance optimizations §Great for: w. Client/server applications w. Applets w. Servlets where the Web server and data are not on the same i 5/OS system "Native" DB 2 JDBC driver com. ibm. db 2. jdbc. app. DB 2 Driver §Communicates with the database using direct CLI calls §Great for: w. Server applications w. Servlets where the Web server and data are on the same i 5/OS system §Toolbox JDBC driver can switch to use the DB 2 driver w. Use the JDBC property "driver=native" on the connection URL 28 © 2006 IBM Corporation

IBM System i 5 JDBC Code your program to be configurable §Don't hardcode a IBM System i 5 JDBC Code your program to be configurable §Don't hardcode a JDBC driver ƒ Allow your end users to plug in other JDBC drivers ƒ Now your program works with any database! §Differences between JDBC drivers: ƒ ƒ Driver class name (needed for registering with the Driver. Manager) URL syntax (needed for connecting) Properties (used for customizing connection properties) Subtle SQL differences §Most of the logic and code will be the same! Database X 29 © 2006 IBM Corporation i. Series

IBM System i 5 JDBC Statements Statement IBM System i 5 JDBC Statements Statement "handles" are needed to issue SQL statements: §Statement statement = connection. create. Statement(); §statement. execute. Update("INSERT INTO MYTABLE (COL 1) VALUES (45)"); §Result. Set rs = statement. execute. Query("SELECT * FROM MYTABLE"); Use Prepared. Statements when executing an SQL statement multiple times, or when parameters are needed: §Prepared. Statement ps = connection. prepare. Statement("INSERT INTO MYTABLE (? )"); §ps. set. Int(1, 45); §ps. execute. Update(); 30 © 2006 IBM Corporation

IBM System i 5 JDBC Statements (continued) Use Callable. Statements when calling a stored IBM System i 5 JDBC Statements (continued) Use Callable. Statements when calling a stored procedure Callable. Statement cs = connection. prepare. Call("CALL MYPROC (? , ? )"); cs. set. Int(1, 88); cs. set. Int(2, 99); cs. register. Out. Parameter(2, Types. INTEGER); cs. register. Out. Parameter(3, Types. VARCHAR); cs. execute. Update(); int n = cs. get. Int(2); String x = cs. get. String(3); 31 © 2006 IBM Corporation

IBM System i 5 JDBC Result. Sets contain the result data from a query IBM System i 5 JDBC Result. Sets contain the result data from a query §Result. Set rs = statement. execute. Query("SELECT * FROM MYTABLE"); §String value = rs. get. String("COLUMNA"); Result. Set. Meta. Data objects describe the columns in a Result. Set §Result. Set. Meta. Data rsmd = rs. get. Meta. Data(); §String column. Name = rsmd. get. Column. Name(1); §int display. Size = rsmd. get. Column. Display. Size(1); 32 © 2006 IBM Corporation

IBM System i 5 JDBC What else is there? Database. Meta. Data §Information about IBM System i 5 JDBC What else is there? Database. Meta. Data §Information about tables, columns, procedures, . . . SQLExceptions and SQLWarnings §Used for error handling JDBC 2. 0 (only available under Java 2) §Updatable, Scrollable result sets §LOBs (Large objects) §Batch updates §Connection Pooling §Data sources §Row sets §Distributed transactions JDBC 3. 0 (new in JTOpen and V 5 R 2 Toolbox) §Savepoints §Parameter meta data §New BLOB and CLOB methods §Independent auxiliary storage pools (IASPs) 33 © 2006 IBM Corporation

IBM System i 5 IBM Toolbox for Java JDBC specifics Connection properties §Can be IBM System i 5 IBM Toolbox for Java JDBC specifics Connection properties §Can be set in Driver. Manager. get. Connection(): Properties conn. Props = new Properties(); conn. Props. put("cursor hold", "true"); conn. Props. put("date format", "iso"); Connection c = Driver. Manager. get. Connection("jdbc: as 400: //my. System", conn. Props); §. . . or in the URL: Connection c = Driver. Manager. get. Connection("jdbc: as 400: //my. System; cursor hold=false; date format=iso", conn. Props); 34 © 2006 IBM Corporation

IBM System i 5 IBM Toolbox for Java JDBC specifics Some helpful connection properties: IBM System i 5 IBM Toolbox for Java JDBC specifics Some helpful connection properties: Connection property Description "libraries" Specify a library list, e. g. "MYLIB, *LIBL, ANOTHER" "date format", "time format" Specify the format for String representations of dates and times, e. g. "iso", "mdy", "usa" "naming" Specify the naming convention for qualified table names, either "sql" (for collection. table) or "system" (for library/file) Define block size for fetching multiple rows, can greatly improve performance "block criteria", "block size" "extended dynamic", "package cache", etc. "secure" "translate binary" Use extended dynamic support. Improves performance when same statements are prepared repeatedly - even across different runs of the program Use Secure Sockets Layer (SSL) Specify "true" if you have text strings stored in binary columns (some legacy programs do this) There are many other connection properties. . . 35 © 2006 IBM Corporation

IBM System i 5 Record-level database access Fast access to i 5/OS database files IBM System i 5 Record-level database access Fast access to i 5/OS database files Provides access to physical and logical files: §Access records sequentially, by record number or key §Support for locking §Support for transactions (commit and rollback) Options for describing the Record Format: §The programmer can write the code §The Toolbox can retrieve the record format at development-time and output Java source code §The Toolbox can retrieve the record format at run-time Fast! 36 When running on i 5/OS, direct API calls are made instead of using the host server (these are known as "native optimizations") © 2006 IBM Corporation

IBM System i 5 Record-level database access Fast access to i 5/OS database files IBM System i 5 Record-level database access Fast access to i 5/OS database files QSYSObject. Path. Name file. Name = new QSYSObject. Path. Name("QIWS", "QCUSTCDT", "FILE"); Sequential. File file = new Sequential. File(as 400, file. Name. get. Path()); file. set. Record. Format(); // Loads the record format directly from the server. file. open(); Record data = file. read. Next(); while (data != null) { System. out. print((String)data. get. Field("INIT") + " "); System. out. print((String)data. get. Field("LSTNAM") + " "); System. out. println((Big. Decimal)data. get. Field("BALDUE")); data = file. read. Next(); } 37 © 2006 IBM Corporation

IBM System i 5 Record-level database access Fast access to i 5/OS database files IBM System i 5 Record-level database access Fast access to i 5/OS database files Performance tips §Avoid retrieving the record format multiple times. Retrieve it once and save a reference to it or hard code the record format §Blocking factor means record caching. Experiment with different sizes or specify zero and let the Toolbox determine the blocking factor. §Blocking factor is valid only when the file is opened for READ_ONLY or WRITE_ONLY access. §Opening keyed files is slower than opening sequential files. Use sequential files unless you need to specifically search by key. 38 © 2006 IBM Corporation

IBM System i 5 HTML and Servlet classes Web components create tables and forms IBM System i 5 HTML and Servlet classes Web components create tables and forms Provides access to database files: §Access database file with Record Level Access or SQL via JDBC §Includes Meta Data Provides classes to display data: §Display data in tables or forms §Toolbox provides converters that will produce HTML tables or forms based on the row data HTMLTable. Converter converter = new HTMLTable. Converter(); Result. Set result. Set = statement. get. Result. Set(); SQLResult. Set. Row. Data rowdata = new SQLResult. Set. Row. Data(result. Set); String[ ] html = converter. convert(rowdata); out. println(html[0]); 39 © 2006 IBM Corporation

IBM System i 5 Web components create tables and forms §Classes for generating HTML IBM System i 5 Web components create tables and forms §Classes for generating HTML output §Useful for servlets, report generating, etc. // Execute an SQL statement and get the result set. Statement statement = connection. create. Statement(); statement. execute("SELECT * FROM QIWS. QCUSTCDT"); Result. Set result. Set = statement. get. Result. Set(); // Create the SQLResult. Set. Row. Data object and initialize to the result set. SQLResult. Set. Row. Data row. Data = new SQLResult. Set. Row. Data(result. Set); // Create an HTML converter object and convert the row. Data to HTMLTable. Converter conv = new HTMLTable. Converter(); HTMLTable[ ] html = convert. To. Tables(row. Data); // Display the HTML table generated by the converter. out. println(html[0]); 40 © 2006 IBM Corporation

IBM System i 5 HTML and Servlet classes Web components create tree hierarchy Provides IBM System i 5 HTML and Servlet classes Web components create tree hierarchy Provides classes to display the Integrated File System: §Display contents of the Integrated File System §Toolbox provides classes to create and display a customized and traversable tree HTMLTree tree = new HTMLTree(HTTPrequest) IFSJava. File root = new IFSJava. File(system. Object, "/QIBM"); Dir. Filter filter = new Dir. Filter(); File[] dir. List = root. list. Files(filter); for (int i=0; i

IBM System i 5 HTML and Servlet classes Web components create tree hierarchy 42 IBM System i 5 HTML and Servlet classes Web components create tree hierarchy 42 © 2006 IBM Corporation

IBM System i 5 System Debugger and Debug Manager Ÿ Supports all ILE languages: IBM System i 5 System Debugger and Debug Manager Ÿ Supports all ILE languages: C, C++, RPG, Java, Cobol, CL Ÿ Point and click breakpoint manipulation in source code Ÿ Automatic variable evaluation with mouse and local variable display Ÿ Program call stack and thread display Ÿ Available via PTF for V 5 R 1 (5722 -SS 1 SI 02871 and 5722 -JC 1 SI 02849) Ÿ Requires JDK 1. 3 and tes. jar, jt 400. jar, and jhall. jar Ÿ Invoke with the following: 43 java utilities. Debug. Mgr or java utilities. Debug -s system -u user © 2006 IBM Corporation

IBM System i 5 Jar. Maker Reduce jar file sizes §The V 5 R IBM System i 5 Jar. Maker Reduce jar file sizes §The V 5 R 2 jt 400. jar file is 3. 4 MB, the newer JTOpen 5. 1 is approximately 4. 2 MB. §A given program typically only needs a small portion of the code (e. g. only Command. Call or only JDBC). §AS 400 Toolbox. Jar. Maker pares down jt 400. jar to contain only the code you need. §Jar. Maker also works on jar files other than jt 400. jar. java utilities. AS 400 Toolbox. Jar. Maker -source jt 400. jar -destination jt 400 Small. jar component Command. Call -ccsid 37 -no. Proxy -exclude. Some. Dependencies jt 400. jar 4. 2 MB 44 jt 400 Small. jar 0. 3 MB © 2006 IBM Corporation

IBM System i 5 References Where can I get more information? http: //www. ibm. IBM System i 5 References Where can I get more information? http: //www. ibm. com/servers/eserver/iseries/toolbox/ §News, downloads, FAQs, service packs, articles, COMMON labs http: //jt 400. sourceforge. net §JTOpen - open source, bug reporting, feature requests http: //www. ibm. com/servers/eserver/support/iseries/index. html §System i 5 Technical Forums - including IBM Toolbox for Java/JTOpen Forum IBM Toolbox for Java Programmers Guide §Shipped with the IBM Toolbox for Java §Contains overview, full API documentation (javadoc), and code examples §Available in the i 5/OS Information Center §Link off of the Toolbox home page Building AS/400 Client/Server Applications with Java §Redbook SG 24 -2152 -02 45 © 2006 IBM Corporation

IBM System i 5 IBM Toolbox for Java home page 46 © 2006 IBM IBM System i 5 IBM Toolbox for Java home page 46 © 2006 IBM Corporation

IBM System i 5 IBM Toolbox for Java/JTOpen Forum 47 © 2006 IBM Corporation IBM System i 5 IBM Toolbox for Java/JTOpen Forum 47 © 2006 IBM Corporation

IBM System i 5 Toolbox Programmer's Guide 48 © 2006 IBM Corporation IBM System i 5 Toolbox Programmer's Guide 48 © 2006 IBM Corporation

IBM System i 5 Javadoc 49 © 2006 IBM Corporation IBM System i 5 Javadoc 49 © 2006 IBM Corporation




  • Мы удаляем страницу по первому запросу с достаточным набором данных, указывающих на ваше авторство. Мы также можем оставить страницу, явно указав ваше авторство (страницы полезны всем пользователям рунета и не несут цели нарушения авторских прав). Если такой вариант возможен, пожалуйста, укажите об этом.