Read MVS DataSet from java program

1.2k views Asked by At

I'm trying to access to a DataSet called X.Y.Z; my code is:

ZFile zFile = new ZFile("//X.Y.Z","r");
    try {
        String enc = ZUtil.getDefaultPlatformEncoding();
        InputStream is = zFile.getInputStream();
        BufferedReader rdr = new BufferedReader(new InputStreamReader(is, enc));
        String line;
        while ((line = rdr.readLine()) != null) {
            System.out.println(line);
        };
    }finally {
        zFile.close();
    }

I get this exception:

com.ibm.jzos.ZFileException: X.Y.Z: Filename is not a valid MVS dataset or DD name; errno=99 errno2=0x0 last_op=0 errorCode=0x0
    at com.ibm.jzos.ZFile.checkSecurityManager(ZFile.java:1592)
    at com.ibm.jzos.ZFile.<init>(ZFile.java:475)
    at it.Main.test(MainApp.java:20)
com.ibm.jzos.ZFileException: //'X.Y.Z': fopen() failed; EDC5049I The specified file name could not be located.; errno=49 errno2=0xc00b0641 last_op=50 errorCode=0x21708
    at com.ibm.jzos.ZFile.fopen(Native Method)
    at com.ibm.jzos.ZFile.doZFileOpen(ZFile.java:613)
    at com.ibm.jzos.ZFile.<init>(ZFile.java:476)
    at it.Main.test(MainApp.java:22)

Any suggestion? Thanks.

1

There are 1 answers

0
meat On BEST ANSWER

If the double slash notation is used to refer to a data set on z/OS, it assumes the data set's high level qualifier (HLQ) is the user id of the current user. For example, //X.Y.Z would resolve to MEAT.X.Y.Z assuming my username was my user id on z/OS. Quotes should be added if the data set specified is the fully-qualified data set name. In your case, //'X.Y.Z' would resolve to X.Y.Z.