× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: RE: Yet Another Newbie Question
  • From: "Buckingham, Ed" <Buckingham@xxxxxx>
  • Date: Wed, 22 Nov 2000 13:20:29 -0500

Once again that was the case.  I tried adding a couple of parms (i.e. Lib &
File name) and that was what it was looking for. Thanks for all of your
help.


> -----Original Message-----
> From: Blair Wyman [SMTP:blairw@us.ibm.com]
> Sent: Wednesday, November 22, 2000 12:51 PM
> To:   JAVA400-L@midrange.com
> Subject:      RE: Yet Another Newbie Question
> 
> 
> Based on the error message, which points to line 6, the problem is that
> the
> program apparently expects some command line parameters that aren't being
> passed.
> 
> ArrayIndexOutOfBoundsException is signalled when an attempt is made to
> access an non-existent element of an array -- in this case, the array in
> question is the array of java.lang.String called "argv".  The reference to
> argv[0] and/or argv[1] signals the exception.
> 
> Clearly, the program wants a couple of parameters, but what are they?
> (Inspection of the code suggests they are the parameters to the
> QSYSObjectPathName constructor, so I'm going to guess they are "library"
> and "filename".)
> 
> Not to get too pedantic, but there are a couple of ways the code could be
> changed to avoid this somewhat confusing exception.
> 
> An explicit check for the length of the array would work:
> 
> ---------8<---- snip -----8< --------
> import com.ibm.as400.access.*;
> class TestRecordLevelAccess
> {
>   public static void main(String argv[]) {
>     if (argv.length < 2) {
>       System.err.println("usage: TestRecordLevelAccess <library>
> <filename>");
>       System.exit(1);
>     }
>     AS400 system = new AS400();
>     String filePath = (new QSYSObjectPathName(argv[0],
> argv[1],"FILE")).getPath();
>     // ...
> ---------8<---- snip -----8< --------
> 
> 
> ...or a "try/catch" could be put up (though it would be overkill, IMHO):
> 
> ---------8<---- snip -----8< --------
> import com.ibm.as400.access.*;
> class TestRecordLevelAccess
> {
>   public static void main(String argv[]) {
>     AS400 system = new AS400();
>     try {
>       String filePath = (new QSYSObjectPathName(argv[0],
> argv[1],"FILE")).getPath();
>     } catch(ArrayIndexOutOfBoundsException e) {
>       System.err.println("usage: TestRecordLevelAccess <library>
> <filename>");
>      System.exit(1);
>     }
>     //...
> ---------8<---- snip -----8< --------
> 
> -blair
> 
> Blair Wyman -- IBM Rochester -- (507) 253-2891
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> "The first principle is that you must not fool yourself -
>   and you are the easiest person to fool."   -- Richard P. Feynman
> 
> +---
> | This is the JAVA/400 Mailing List!
> | To submit a new message, send your mail to JAVA400-L@midrange.com.
> | To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
> | To unsubscribe from this list send email to
> JAVA400-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner: joe@zappie.net
> +---
+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.