Java on AS/400 FAQ From jGuru
Generated Feb 9, 2010 2:22:17 PM

Location: http://www.jguru.com/faq/Java400
Ownership: http://www.jguru.com/misc/user-agree.jsp#ownership.

Are there any other FAQs available, specific to working with Java on the AS/400?
Location: http://www.jguru.com/faq/view.jsp?EID=138807
Created: Aug 30, 2000 Modified: 2000-08-30 16:55:13.971
Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7)

IBM maintains a list of resources available at http://www.as400.ibm.com/developer/java/qanda.html.

Where can I find technical documentation for the AS/400?
Location: http://www.jguru.com/faq/view.jsp?EID=139329
Created: Aug 31, 2000 Modified: 2000-08-31 17:21:14.422
Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100)

The AS/400 Online Library. From here you can go to the actual online manuals, to the AS/400 Information Center, the AS/400 Technical Studio, or the IBM Redbook Library .

Why should I care about the CRTJVAPGM command?
Location: http://www.jguru.com/faq/view.jsp?EID=139331
Created: Aug 31, 2000 Modified: 2000-08-31 17:22:44.982
Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100)

When the JAVA or RUNJAVA command is invoked, if an internal MI program object does not exist, OS/400 will create one. When this occurs with individual classes, the objects will be saved, so the main penalty here is first time use. However, with zip or jar files, while the same creation process is followed, the resulting objects are not saved, so the penalty is incurred on each run.

By using the CRTJVAPGM command beforehand, any possible runtime penalty is avoided. You can use the DSPJVAPGM command to find out whether the MI object exists.

How do I convert classic zoned or packed decimal data to Java types?
Location: http://www.jguru.com/faq/view.jsp?EID=139333
Created: Aug 31, 2000 Modified: 2000-08-31 17:21:34.582
Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100)

Use one of ResultSet's getBigDecimal() methods. The Toolbox also provides Data conversion and description classes for converting Java types to classic DDS types.
Comments and alternative answers

read byte of ebcdic and return 2 char string of each 4 bit pair
Author: Carl Berndt (http://www.jguru.com/guru/viewbio.jsp?EID=1157877), Mar 26, 2004
/** * Description: Read ebcdic byte, and get its * 4 bit pairs. */ private static String byteToString(byte inhexbyte) throws IOException { System.out.println("Read in byte " + inhexbyte); //ebcdic to java string //String hex = Integer.toHexString(-107); //ebcdic 95 String hex = Integer.toHexString(inhexbyte); StringBuffer digits = new StringBuffer("??"); int j = hex.length(); if (j >= 2) { char c1 = hex.charAt(j - 2); char c2 = hex.charAt(j - 1); digits.setCharAt(0, c1); digits.setCharAt(1, c2); } return digits.toString(); }

Where can I find the properties supported by the Toolbox and Native JDBC drivers?
Location: http://www.jguru.com/faq/view.jsp?EID=139334
Created: Aug 31, 2000 Modified: 2000-08-31 17:22:09.34
Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100)

See: JDBC Properties.

Why should I use a Collection rather than a standard AS/400 Library for my data?
Location: http://www.jguru.com/faq/view.jsp?EID=139338
Created: Aug 31, 2000 Modified: 2000-08-31 17:21:51.252
Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100)

A collection provides a logical grouping of SQL objects...[and] consists of a library, a journal, a journal receiver, a catalog, and optionally, a data dictionary. See: CREATE COLLECTION for the SQL command.

By creating a collection, all of the objects needed for SQL functionality, including Commit and Rollback are available. Otherwise you can only use autocommit mode or create your own journals and receivers.

Note that, with some restrictions if you created a data dictionary, you can create a Collection, then move files/tables to it from your old library.

Are there any mailing lists geared towards Java development on the AS/400?
Location: http://www.jguru.com/faq/view.jsp?EID=208640
Created: Sep 17, 2000 Modified: 2000-09-18 08:21:35.634
Author: Michael Justin (http://www.jguru.com/guru/viewbio.jsp?EID=208635) Question originally posed by John Zukowski PREMIUM (http://www.jguru.com/guru/viewbio.jsp?EID=7

Check out the JAVA400-L list.
Comments and alternative answers

JAVA101 List
Author: David Gibbs (http://www.jguru.com/guru/viewbio.jsp?EID=402507), Apr 13, 2001
There's also a new mailing list for learning java from the AS/400 perspective ... visit http://www.midrange.com/java101.shtml for information & subscription.
newsgroup for java on AS/400
Author: Richard Robinson (http://www.jguru.com/guru/viewbio.jsp?EID=395750), Aug 30, 2001
at newsserver ncc.hursley.ibm.com there are two newsgroups:

ibmpub.java.os400 ibmpub.java.os390

But the activity is minimal

;

I am using ResultSetMetaData.getColumnLabel() to create headers for a table. I have specified column labels on the table ( DB2 on an AS/400, ) which show up when I run an SQL statement directly over the table, but the method returns the same data as getColumnName(). Any ideas, help or explanation?
Location: http://www.jguru.com/faq/view.jsp?EID=210959
Created: Sep 20, 2000 Modified: 2000-09-28 02:59:44.977
Author: Sreeram Mohan (http://www.jguru.com/guru/viewbio.jsp?EID=51029) Question originally posed by Brenda Groenwald (http://www.jguru.com/guru/viewbio.jsp?EID=66017

Many drivers implement this method identically to getColumnName(), apparently because it is a "suggested" title, but always be sure you have the latest versions. For the AS/400 drivers in particular, which have gone open source, you can check at the JTOpen site for the to do list or suggest/implement something yourself.

Where do I get JDBC drivers for the AS/400's database?
Location: http://www.jguru.com/faq/view.jsp?EID=219413
Created: Sep 30, 2000 Modified: 2000-09-30 00:29:12.17
Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100)

The native driver and a version of the Toolbox for Java, which includes the type 4 driver, comes with OS/400. One can also purchase or get an evaluation copy of the latest "official" version of the Toolbox. However, the open source version, JTOpen, is generally more up to date and is free.

You can find both versions from the Java Home Page. For third party drivers, check Where can I find a comprehensive list of JDBC drivers, including the databases they support?

Why do I get "Invalid Cursor State" errors when I insert/update/delete data with executeQuery()?
Location: http://www.jguru.com/faq/view.jsp?EID=219416
Created: Sep 30, 2000 Modified: 2000-09-30 00:31:14.637
Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100)

The base answer is that you should be using executeUpdate() for these operations. The JDBC spec specifically "allows any query string to be passed through to an underlying DBMS driver" and this is probably why a number of databases will actually perform the requested operation. However, no ResultSet is returned. executeQuery() expects a ResultSet, and so reports the error when none is returned.
Comments and alternative answers

Not true
Author: sri karthi (http://www.jguru.com/guru/viewbio.jsp?EID=948693), Jul 14, 2002
I am facing the same issue. I am getting the Invalid Cursor State even with a select comment... My processing involves a query with 2 subqueries... I guess jdbc:odbc connection cannot handle complex queries... or some other setup is required in SQL server to handle queries...
Invalid cursor state
Author: Mlu Sincuba (http://www.jguru.com/guru/viewbio.jsp?EID=1210853), Nov 12, 2004
query = "SELECT * FROM Customer WHERE meterNum = " + "'"+ meterNumber + "'"; try { db.statement = db.connect.createStatement(); db.results = db.statement.executeQuery(query); postBalance = Integer.parseInt(db.results.getString("balance")); newBalance = postBalance + amount; if ( db.results.next() ) { query = "INSERT INTO Transaction (transDateTime, amount, postBalance, newBalance, meterNumber)"+ " VALUES('" + date + "','" + amount + "','"+ postBalance + "','" + newBalance + "','" + meterNumber + "')"; db.result = db.statement.executeUpdate(query); if (db.result==0){ out.println("Not saved"); db.connect.rollback(); } else out.println("Saved"); out.println("your post balance is: "+postBalance); out.println("</body></html>"); out.close(); } else{ out.println("Customer not found!"); out.println("</body></html>"); out.close(); } }
Re: Invalid cursor state
Author: manish arya (http://www.jguru.com/guru/viewbio.jsp?EID=1522865), Nov 28, 2009
use resultset.next(). i was getting same error but using resultset.next() solved the problem. Thanks, Manish Arya.

When I use the AS400JDBCDatabaseMetadata.getColumns(), the columns arrive in alphabetical order not in physical order. Is there a way other than SELECT * FROM... to get the physical order ?
Location: http://www.jguru.com/faq/view.jsp?EID=219792
Created: Sep 30, 2000 Modified: 2000-09-30 19:34:29.132
Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100) Question originally posed by isreal vinner (http://www.jguru.com/guru/viewbio.jsp?EID=208799

Unfortunately, if you look at the Toolbox documentation for AS400JDBCDatabaseMetaData.getColumns(), you'll see this statement:

"The following column in the description is not currently supported:

ORDINAL_POSITION"

I'm not aware of an alternative at this time. Obviously it is critical to read the driver documentation for (un)supported features.

How can I create a Java program that starts as a daemon every time the machine is powered on?
Location: http://www.jguru.com/faq/view.jsp?EID=228811
Created: Oct 15, 2000 Modified: 2000-10-18 18:10:56.728
Author: Rob Derr (http://www.jguru.com/guru/viewbio.jsp?EID=23285) Question originally posed by Daniel Hiller (http://www.jguru.com/guru/viewbio.jsp?EID=205800

Several methods come to mind. Let's see...

1. write a CL program that calls your java app and place a reference to that CL command in QSYS/QSTRUP. This java app should begin a new thread, then end to allow the QSTRUP job to continue. ie:


PGM
JAVA CLASS(myClass) PARM(myArg1) CLASSPATH('myclasspath')
ENDPGM

2. Use ADDAJE to add an autostart job entry (warning: this involves altering subsystem QSYS.)

3. use ADDJOBSCDE to schedule the program to run after IPL.

The first method is probably the best while the third is the easiest.

Are there any IDEs or addons and tools for IDEs that are aimed specifically at the AS/400? What do Java400 developers use?
Location: http://www.jguru.com/faq/view.jsp?EID=234382
Created: Oct 23, 2000 Modified: 2000-10-23 19:39:49.807
Author: Todd Mason (http://www.jguru.com/guru/viewbio.jsp?EID=47921) Question originally posed by John Zukowski PREMIUM (http://www.jguru.com/guru/viewbio.jsp?EID=7

IBM's Visual Age for Java Enterprise comes with a feature called "ET/400": Enterprise Toolkit 400. It allows the developer to easily export Java source and class files to the AS/400, as well as performing AS/400 optimized Java program creation. ET/400 also contains a feature that allows you to remotely run and debug Java programs on the AS/400. I have recently heard that IBM has created a AS/400 specfic version of Visual Age that it is bundling with some of its other development tools, but I don't have any details.
Comments and alternative answers

The output from any Java IDE can be sent to and will...
Author: Luis Colorado (http://www.jguru.com/guru/viewbio.jsp?EID=268988), Dec 6, 2000
The output from any Java IDE can be sent to and will work with the AS/400 (Aleluya for Java openness). Some advanced versions of Visual Age (I don't remember if the Professional or Enterprise Edition) allows you to get legacy AS/400 green screen designs and import them to the VA visual editor, and do some other fancy stuff specific to the AS/400.

How do I package my Java application for deployment to an AS/400 box?
Location: http://www.jguru.com/faq/view.jsp?EID=238610
Created: Oct 27, 2000 Modified: 2000-10-28 06:49:12.549
Author: Todd Mason (http://www.jguru.com/guru/viewbio.jsp?EID=47921) Question originally posed by John Zukowski PREMIUM (http://www.jguru.com/guru/viewbio.jsp?EID=7

Java source and class files reside in the AS/400's IFS ( Integrated File System, ) as ASCII text files. You can create a Java source file in IFS via several different mechanisms:

  • 1. Create the Java source file on an attached PC and save or copy it to AS/400 IFS via a mapped network drive.
  • 2. Create the Java source file on another machine and transfer the source file to the AS/400 via binary mode FTP.
  • 3. Create the Java source library member on the AS/400 using Source Entry Utility (SEU). SEU creates an EBCDIC source library member. You then use the Copy To Stream File (CPYTOSTMF) command to copy the source library member to an IFS file and convert it to ASCII.
  • 4. Create the Java source file on AS/400 using the EDTF command.
Java class files are deployed unchanged to the IFS in the same manner as Java source files.

On pre V4R5 versions of OS/400 it is also recommended that you run CRTJVAPGM on any class or jar files you deploy to optimize them for the AS/400 environment.

In V4R5 and later the JIT is the default option so the CRTJVAPGM is not quite so critical.

This link to AS/400 Java Deployment has all the details:

How can I programmatically determine the level of the AS/400 Toolbox for Java?
Location: http://www.jguru.com/faq/view.jsp?EID=246792
Created: Nov 6, 2000 Modified: 2000-11-06 18:14:58.152
Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100)

Download and use the AboutToolbox class.

Where can i get instructions on how to use JNI on AS/400?
Location: http://www.jguru.com/faq/view.jsp?EID=261330
Created: Nov 23, 2000 Modified: 2000-11-23 20:09:43.025
Author: Davanum Srinivas (http://www.jguru.com/guru/viewbio.jsp?EID=2011)

http://www.as400.ibm.com/developer/java/devkit/rzaham70.htm

I want to use the Developer Kit's native JDBC driver to retrieve data from other AS/400s on a network. I've added the proper Relational Database Entries, but when I try to connect to the remote machines, I get "SQL package QSQCLIPKGN in QGPL not found at DRDA Server." Any clues?
Location: http://www.jguru.com/faq/view.jsp?EID=274042
Created: Dec 9, 2000 Modified: 2000-12-10 14:22:40.699
Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100) Question originally posed by Holley Davis (http://www.jguru.com/guru/viewbio.jsp?EID=139992

If you're at V4R3 or below, the recommendation is to use the Toolbox driver rather than the native driver.

If you're at V4R4 or later, and up to date on PTFs, this problem is, in theory, fixed. However, due to varying isolation levels and other gremlins, you may still get this message and not be able to connect. In that case you should run:

JAVA CLASS( com.ibm.db2.jdbc.app.DB2PackageCreator ) PARM( 'system' 'user' 'password' )

where 'system' is the remote system that is the target for the JDBC driver.

It appears that UserID and Password should be all in capital letters and you may need to run the DB2PackageCreator application twice to get all of the necessary SQL packages created. For more details, see: F14 and F15.

How do I get and install JDK 1.3?
Location: http://www.jguru.com/faq/view.jsp?EID=282129
Created: Dec 19, 2000 Modified: 2000-12-19 15:56:26.805
Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100) Question originally posed by karthik keyan (http://www.jguru.com/guru/viewbio.jsp?EID=270637

For V4R5, see V4R5 5769-JV1 Option 5 (JDK 1.3) AS/400 Install Instructions. This is off of the Java Deployment page. There should also be instructions 'soon', presumably off the same page, for V4R4. For those who can't wait, here was the response from Jeff Lee of the AS/400 Toolbox for Java team:

V4R4 5769-JV1 Option 5 (JDK 1.3) AS/400 Install Instructions

Introduction

This document describes what you need to do to get JDK 1.3 (also known as Java 2 version 1.3) operational on your AS/400. This is contained in PTF 5769-JV1 SF63322.

Before You Begin

In order for JDK 1.3 to work on your AS/400, you must first have V4R4M0 installed with PTF CUM package C0147440 or later. You must also have 5769-JV1 Option *BASE installed. You may then optionally install option 1 (JDK 1.1.6) and/or option 2 (JDK 1.1.7).

Since some Java applications may not work with JDK 1.3, you may want to have one of these options installed. For example, a version of WebSphere requires JDK 1.1.7.

Follow the instructions below to install the Java group PTF and 5769-JV1 Option 5.

It is very important that you install the Java group PTF before you install option 5. Do not install option 5 until you have the correct level of the Java group PTF installed.

Java Group PTF

Order and install the Java group PTF, SF99067. Follow the instructions included with the group PTF. Use the following command to verify that the correct level of the group PTF has been installed:

DSPDTAARA QJAVA/SF99067

Output will show 'Group PTF#: SF99067-06' along with a date. If you have '-05' or less displayed, you need to reorder the PTF to get the most updated version.

To install the group PTF do the following:

on the AS/400 command line enter GO PTF

select option 8

specify PTF type 1 (all PTF's) and automatic IPL Y.

Install 5769-JV1 Option 5

JDK 1.3 is product 5769-JV1 Option 5. This is contained in PTF 5769-JV1 SF63322. You will need to order this PTF. It will be sent to you on a CD. Read the cover letter; it contains additional information.

Load the CD containing the PTF in the drive and enter:

RSTLICPGM LICPGM(5769JV1) OPTION(5) DEV(OPTxx)

where OPTxx is the ID of your CD drive.

Set up Symbolic Links

In JDK 1.3, functions like JDBC, SSL, and JNDI are JDK extensions. To use a JDK extension, first find the ".jar" file in the '/QIBM/ProdData/Java400/ext/' directory. Then, a symbolic link needs to be established once to make the files a part of the '/QIBM/UserData/Java400/ext/' directory. This is so that the class loader can find them. For example, to establish the symbolic link for JDBC, use the following command:

ADDLNK OBJ('/QIBM/ProdData/Java400/ext/db2_classes.jar')

NEWLNK('/QIBM/UserData/Java400/ext/db2_classes.jar')

Other non-IBM provided extensions (in ".jar" files) can be loaded directly into the '/QIBM/UserData/Java400/ext/' directory.

Verify the Functionality of JDK 1.3

Use the following command to verify that JDK 1.3 is working on your system:

JAVA CLASS(com.ibm.as400.system.Hello) PROP((java.version 1.3))

A screen should be displayed that shows:

Hello World

Java program completed

Press enter on this screen to return to the AS/400 command entry screen.

If this command does not work, then you need to contact your service representative for help in getting JDK 1.3 to work on your system.

Using JDK 1.3 on Your AS/400

In V4R4, 5769-JV1 supports Options 1-5. The default JDK used on the system is listed by order of preference below.

1.Option 3 (JDK 1.2)

2.Option 5 (JDK 1.3)

3.Option 4 (JDK 1.1.8)

4.Option 2 (JDK 1.1.7)

5.Option 1 (JDK 1.1.6)

For example, if the AS/400 has all 5 supported options installed, Option 3 (JDK 1.2) is the default.

To force the use of JDK 1.3 when using JAVA, you will need to specify the 'java.version=1.3' property as in the Verify example above.

To make JDK 1.3 the default when JDK 1.2 is installed, set the java.version property to 1.3 in the SystemDefault.properties file. (ie. Specify "java.version=1.3" inside the file) The SystemDefault.properties file is not shipped as part of the JDK 1.3 LPP; it is a text file that is created by the user. There are two places the file can be placed:

User Home : /home/userid/SystemDefault.properties

Java Home : /QIBM/UserData/Java400/SystemDefault.properties

The priority in which properties are used is:

1.User specifies on the JAVA command

2.User Home

3.Java Home

4.environment variable

It is advised to place the SystemDefault.properties only in your User Home, as placing it in Java Home will cause ALL users on the systems to pick up the values in this file, whether they want to or not.

The JV1 product has a separate option for each level of the JDK. JDK 1.3 pushes the number of options to 5. In general, you should only load the levels of JDK required by the applications you use. Loading additional options will just take up extra disk space on your AS/400. For example, if you run an application and it requires JDK 1.3 then I would load only *BASE and option 5. If you get another app and it requires another level of the JDK then load it at that time.

Comments and alternative answers

RE: How do I get and install JDK 1.3?
Author: Larry Neylon (http://www.jguru.com/guru/viewbio.jsp?EID=865515), May 7, 2002
I found that I could not compile anything after installation as the JDK could not find it's own base classes and therefore didn't know what String was, etc.

I reapplied the SF99068 after the JDK install and this fixed it.


Re: RE: How do I get and install JDK 1.3?
Author: Ed Davison (http://www.jguru.com/guru/viewbio.jsp?EID=1147045), Mar 1, 2004
Hi, Our Ops team have installed the JDK 1.3 PTFs to our AS400, running V4R4. Previously we had been running 1.1.7. Unfortunately I have not been able to compile any java on this machine since the JDK install. I get a "Cannot Resolve Symbol" error message on various lines of my code, such as, at various full stops(not all), at "String". Is this the same problem that you had Larry when you said that you had problems compiling after you installed JDK 1.3? Once the PTFs have been applied do I need to do any further configuration to use JDK 1.3? I have created a SystemsDefault.properties file with the java.version=1.3 in it! I appreciate that it's been some time since you experienced this problem, but perhaps you can remember something that might help me! Thanks
Anyone have cd with V4R5 and SF99068/SF63319
Author: Stijn Theunis (http://www.jguru.com/guru/viewbio.jsp?EID=1298923), May 30, 2006
Anyone have cd with V4R5 and SF99068/SF63319 We have customer at v4r5 and we want to upgrade the java to JDK 1.3 but by IBM we get an "V4R5 not supported anymore" so .. have anyone this on cd, tape, ??? thank, Stijn

How can I use the library list to access tables and files with JDBC?
Location: http://www.jguru.com/faq/view.jsp?EID=284877
Created: Dec 22, 2000 Modified: 2000-12-24 21:25:31.127
Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100)

Set the 'naming' driver property to 'system'. This works for both the Toolbox and native driver. One caution, the library list used comes from the job description associated with the job, which is not necessarily the current library list.


// Create a properties object.
Properties p = new Properties();
 
// Set the properties for the connection.
p.put("naming", "system");
 
// Connect using the properties object.
Connection con = DriverManager.getConnection(
   "jdbc:db2:localhost", p );

Are there any JDBC drivers available that support using SSL to communicate between the Java program and the database server?
Location: http://www.jguru.com/faq/view.jsp?EID=289193
Created: Dec 29, 2000 Modified: 2000-12-29 20:14:34.385
Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7) Question originally posed by John Zukowski PREMIUM (http://www.jguru.com/guru/viewbio.jsp?EID=7

For Oracle, the JDBC-OCI driver can use SSL with native threads, but not with green threads. The JDBC-Thin driver cannot use SSL, but can use ANO encryption instead.

JDataConnect provides a whole FAQ for their SSL support.

The IDS JDBC Driver supports SSL also.

The the Novell JDBC Driver for NDS driver uses SSL by default, and must be disabled to not use.

WebLogic / Tengah supports SSL when your protocol begins with t3s (jdbc:weblogic:t3s I guess, or just create the T3Client with a t3s URL).

Cloudscape supports SSL through a special extended URL with the RmiJdbc driver. (jdbc:cloudscape:weblogic-ssl:)

The HiT driver supports SSL communications with JDBC and DB2.

This list is not meant to be exhaustive. Feel free to add feedback if you know of any others.

Joe Sam Shirah adds:

The AS/400 Toolbox for Java will also support SSL Connections, although there must be a specific match between Toolbox and OS/400 versions. In addition, the Connection must be made in a way specific to the Toolbox driver.

Comments and alternative answers

how can i use ssl in my app
Author: anil dash (http://www.jguru.com/guru/viewbio.jsp?EID=874769), May 11, 2002
how can i use ssl in my app can u send me a sample code for that anil
StarSQL for Java JDBC driver supports SSL
Author: David Brown (http://www.jguru.com/guru/viewbio.jsp?EID=1232510), Mar 14, 2005
StarSQL for Java (a type 4 driver for accessing DB2, including AS/400, via DRDA) supports SSL.

see http://www.starquest.com

On the client side, SSL is set up by using the appropriate port (default 448 rather than 446) and including an extra .jar file in the Classpath.

The Users Guide contains info on setting up the AS/400 for SSL :

StarSQL for Java User's Guide 79

Configuring Support for the SSL Protocol

To configure an iSeries host system to use the Secure Sockets Layer (SSL) protocol you must have the following components:

  • OS/400 v5r1 or later
  • 5722-SS1 option 34
  • Digital Certificate Manager
  • 5722-TC1 TCP/IP Connectivity Utilities
  • 5722-DG1 IBM HTTP Server
  • Either 5722-AC2 (56-bit) or 5722-AC3 (128-bit) Cryptographic Access Provider

    Preparing Hosts for StarSQL Access

    Following are general procedures for configuring SSL on the iSeries host. Refer to your IBM documentation for details, especially the AS/400 documentation and the IBM iSeries Wired Network Security OS/400 V5R1 DCM and Cryptography Enhancements Redbook.

    1. Start the Admin HTTP instance and use a browser to configure the Digital Certificate Manager.
    a. Create a local Certificate Authority or obtain a certificate from a public Internet Certificate Authority.
    b. Create a *SYSTEM certificate store.
    c. Use Manage Applications to assign a server certificate to the OS/400 DDM/DRDA server.
    d. After you assign the certificate, restart the DDM/DRDA server:
    ENDTCPSVR *DDM
    STRTCPSVR *DDM
    

    2. If necessary, set the port on which the DDM/DRDA server listens for SSL conversations. The default port for SSL is 448.

  • How can I use the library list for specific objects with the Toolbox? "*LIBL" doesn't seem to work properly.
    Location: http://www.jguru.com/faq/view.jsp?EID=289598
    Created: Dec 29, 2000 Modified: 2000-12-29 23:49:41.222
    Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100)

    '*' is used for a wildcard character. Instead, use surrounding '%' signs, as
    "%LIBL%"
    . For example, to find the message queue MYMSGQ, use:

    "/QSYS.LIB/%LIBL%.LIB/MYMSGQ.MSGQ"

    Comments and alternative answers

    % Not working for me
    Author: Chris Wolcott (http://www.jguru.com/guru/viewbio.jsp?EID=1214466), Dec 3, 2004
    We have a JAVA app that uses *DTAQs to comunicate with AS/400 apps. Currently the QSYS path is hardcoded into the .properties file, but it wopuld solve a LOT of problems if I could get it to pull from the *LIBL instead. I do not know the inner workings of this JAVA app, but if I change the path in the .properties file from /QSYS.LIB/LIBRARY.LIB/DTAQ1.DTAQ to /QSYS.LIB/%USRLIBL%.LIB/DTAQ1.DTAQ as per the above answer I get this:
    com.ibm.as400.access.ObjectDoesNotExistException: /QSYS.LIB/%USRLIBL%.LIB/DTAQ1.DTAQ: Library does not exist.
    	at java/lang/Throwable.<init>(Throwable.java:195)
    	at java/lang/Exception.<init>(Exception.java:41)
    	at com/ibm/as400/access/BaseDataQueueImplNative.buildException(BaseDataQueueImplNative.java:322)
    	at com/ibm/as400/access/BaseDataQueueImplNative.processRetrieveAttrs(BaseDataQueueImplNative.java:229)
    	at com/ibm/as400/access/DataQueue.retrieveAttributes(DataQueue.java:308)
    	at com/ibm/as400/access/BaseDataQueue.open(BaseDataQueue.java:253)
    	at com/ibm/as400/access/DataQueue.read(DataQueue.java:293)
    

    If I use just %LIBL%, I do not get an error but the log does not show any activity over the queues even though I know they are being written to. Do I need to have the QSYSObjectPathName class added to this app, or should this work? (V5R2M0 JVM4.1)
    Re: % Not working for me - Doh!
    Author: Chris Wolcott (http://www.jguru.com/guru/viewbio.jsp?EID=1214466), Dec 3, 2004
    My Bad, yes it is working. I have to copy the log to open it with WordPad, and Windows appearently 'cached' the original version I opened, so when I recopied it it was still the original log file, not the one showing the traffic.

    I would be interested in learning why the %USRLIBL% didn't work through.

    How can I print out a file to the printer directly using Java on an AS/400?
    Location: http://www.jguru.com/faq/view.jsp?EID=290175
    Created: Dec 31, 2000 Modified: 2001-01-01 05:51:55.876
    Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100) Question originally posed by vincent dennis (http://www.jguru.com/guru/viewbio.jsp?EID=226514

    The most basic method is to use System.out.println() and submit the job to batch. As Running Java in a batch job discusses, default handling sends System.err and System.out to a spooled file. The section also mentions methods of redirecting these streams.

    If you want to make use of your own printer files rather than the QPRINT/QSYSPRT variety, the Toolbox/JTOpen has several Network print classes that can be used.

    Davanum Srinivas also contributed to this answer.

    Why do my transactions fail when I invoke executeUpdate()? I've set autocommit to false, but I get the SQLException: "The file is not valid for the operation" and getTransactionIsolation() returns TRANSACTION_UNCOMMITED.
    Location: http://www.jguru.com/faq/view.jsp?EID=313818
    Created: Jan 27, 2001 Modified: 2002-03-23 23:05:30.986
    Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100) Question originally posed by Maribel Marco (http://www.jguru.com/guru/viewbio.jsp?EID=281878

    Transactions require underlying support. In general, there must be

    1) A database table.

    2) The database must support transactions.

    3) Any setup required by the specific database to allow transactions must be performed.

    For example, the AS/400 supports transactions via a process called journaling. Journals must be specifically created and operational or SQL Collections, rather than standard libraries, must be created for automatic journals.

    To check whether transactions are valid, use DatabaseMetaData.supportsTransactions().

    Comments and alternative answers

    autocommit
    Author: Charles Xavier (http://www.jguru.com/guru/viewbio.jsp?EID=384410), Mar 28, 2001
    If the autocommit status has been set to false, then shouldn't there be an explicit call to commit the transaction using the commit method of the Connection object ?
    Re: autocommit
    Author: N Jain (http://www.jguru.com/guru/viewbio.jsp?EID=795169), Mar 13, 2002
    See if there is a journal on the file that you are trying to update.
    Re: autocommit
    Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100), Mar 23, 2002
    Of course, but the focus of the question was transactional support. If that is not there, commit won't work.

    Are there any Java classes available that provide SQL builder/SQL by example functionality?
    Location: http://www.jguru.com/faq/view.jsp?EID=317300
    Created: Jan 31, 2001 Modified: 2001-01-31 10:23:18.737
    Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100) Question originally posed by Yongfeng Xiao (http://www.jguru.com/guru/viewbio.jsp?EID=216776

    One resource is the SQLQueryBuilderPane contained in JTOpen. Although much of the code in JTOpen is oriented towards and specific to the AS/400, this class and many others may be used in any Java application. The price is right ( free ) and the ( open ) source is available for download.
    Comments and alternative answers

    Another free and open source ( GPL ) resource is Admin...
    Author: Christopher Bowland (http://www.jguru.com/guru/viewbio.jsp?EID=217833), Feb 2, 2001
    Another free and open source ( GPL ) resource is Admin Tool.

    Toolbox driver vs native IBM driver My program works fine from winNT and on the AS/400 using the Toolbox driver( com.ibm.as400.access.AS400JDBCDriver). However, it doesn't work using the native driver (com.ibm.db2.jdbc.app.DB2Driver). What did I miss?
    Location: http://www.jguru.com/faq/view.jsp?EID=409377
    Created: Apr 25, 2001
    Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100) Question originally posed by gio per (http://www.jguru.com/guru/viewbio.jsp?EID=399906

    I can't be sure from the information given, but the most likely cause is that not only the driver class but also the JDBC database URL is different for the two drivers. For the Toolbox driver, use:
    
    jdbc:as400://MACHINENAME/COLLECTIONNAME
    

    For the native driver, use:

    
    jdbc:db2:localhost/COLLECTIONNAME
    
    Comments and alternative answers

    difference between native ibm driver and the toolbox driver
    Author: Wessel van Norel (http://www.jguru.com/guru/viewbio.jsp?EID=986593), Aug 21, 2002
    From:
    http://www-919.ibm.com/developer/jdbc/Faqs/JDBCFAQ.html#A2
    The native JDBC driver is a part of the AS/400 JVM, and performs better than the toolbox JDBC driver.
    The toolbox driver runs on any JVM.
    The current advice to customers is this:
    When you are running on the AS/400 directly, use the native JDBC driver.
    When your program runs from another JVM and will access the AS/400 use the toolbox driver.

    ***
    So the native driver does not work with the NT JVM, that's why you couldn't get it to work.

    Wessel

    The RPG programm should act as a part of a transaction. That means, do some update via JDBC, call RPG, do some more updates via JDBC. Then do a commit or rollback that should affect all the updates from JDBC *AND* from the RPG program.Is there a possible way to do this?
    Location: http://www.jguru.com/faq/view.jsp?EID=461812
    Created: Jul 25, 2001
    Author: sepp muegeli (http://www.jguru.com/guru/viewbio.jsp?EID=343798) Question originally posed by sepp muegeli (http://www.jguru.com/guru/viewbio.jsp?EID=343798

    One way I've found is:

    1. Use commitment control from JDBC as usual ( auto-commit off, transaction isolation level != none ).
    2. Use the keyword "COMMIT" in the file specification section in the RPG program.
    3. Create the ILE-RPG program with activation group *CALLER

    The stored procedure should now run under the commitment control of the calling JAVA program.

    Is there a way to detect the AS/400 File EOF or BOF?
    Location: http://www.jguru.com/faq/view.jsp?EID=500026
    Created: Sep 19, 2001
    Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100) Question originally posed by Vengoal Chang (http://www.jguru.com/guru/viewbio.jsp?EID=475271

    Because of the terms you are using, I assume you are referring to Record Level Access ( JTOpen covers a lot of territory ). I personally don't use the RLA classes for a number of reasons ( put portability first ), but a quick review of the API documentation ( hint ) for AS400File shows that readNext() and readPrevious() return null for EOF and BOF respectively.

    What ports does the AS/400 Toolbox JDBC driver ( com.ibm.as400.access.AS400JDBCDriver ) use?

    My application needs to use JDBC through a firewall.
    Location: http://www.jguru.com/faq/view.jsp?EID=799495
    Created: Mar 15, 2002
    Author: Eric Kramer (http://www.jguru.com/guru/viewbio.jsp?EID=760621) Question originally posed by Sean Sullivan (http://www.jguru.com/guru/viewbio.jsp?EID=203382
    Here's a wonderfully helpful document from IBM summarizing the ports used by the various Toolbox features (including JDBC):

    Server Ports Used

    From it, it appears that JDBC will require ports: 449, 8470, 8471, and 8476. If you're using SSL (which I'm going to guess you're not), there are different corresponding ports listed.

    Also, we've had many headaches when there's a firewall between the two boxes. You'll want to configure your app server (if you're using one) for a minimum pool size of zero since if your connection(s) lay idle, the firewall may disconnect them ungracefully...