是否可以使用Java从AS400返回对象列表?

时间:2014-07-10 10:16:35

标签: java ibm-midrange jtopen

我试图根据库名称从AS400中检索对象列表(无论哪种类型)。

我尝试通过命令调用使用 WRKOBJ LibName / * all ,但收到的错误提示我无法在此设置中使用命令WRKOBJ(未提供其他反馈)。

当前代码:

    StringBuffer getObjects = new StringBuffer("wrkobj " + library + "/*all");
    CommandCall call = new CommandCall(as400);

    if(call.run(getObjects.toString())){

            objectsFound = true;
            logger.debug("Lib: " + library + "  returned objects");

    }else{

            // Hold error message to display in joption pane
            errorMessages = new StringBuffer();
            // Show the messages (returned whether or not there was an error.)
            messagelist = call.getMessageList();

            for (int i = 0; i < messagelist.length; i++){

                // Show each message.
                logger.debug(messagelist[i].getText());
                errorMessages.append(messagelist[i].getText() + "\n");

            }
        }

我仍然在寻找解决方案,所以如果我发现任何东西,我会发布,但任何有任何想法或能指出我正确方向的人我都会感激它!

3 个答案:

答案 0 :(得分:2)

是的,但你需要使用jt400.jar(这是jtopen标签涵盖的内容)“

如果您只需要名称,IFSFile类支持在QSYS对象上列出文件名。

答案 1 :(得分:1)

也许JT400类ObjectList会更好吗?它的目的就是为了做到这一点。

答案 2 :(得分:0)

您还可以使用JDBC获取有关库中对象的更多详细信息。这是使用JTOpen附带的JDBC客户端的示例。

~> java -cp jt400.jar com.ibm.as400.access.jdbcClient.Main jdbc:as400:SYSTEMNAME USERID PASSWORD  
>call QSYS.QCMDEXC(' DSPOBJD OBJ(EBERHARD/*ALL) OBJTYPE(*ALL) DETAIL(*SERVICE) OUTPUT(*OUTFILE) OUTFILE(QTEMP/OBJECTS)                  ', 000000100.00000)
>select * from qtemp.objects fetch first 10 rows only
ODDCEN,ODDDAT,ODDTIM,ODLBNM,ODOBNM,ODOBTP,ODOBAT,ODOBFR,ODOBSZ,ODOBTX,ODOBLK,ODOBDM,ODCCEN,ODCDAT,ODCTIM,ODOBOW,ODSCEN,ODSDAT,ODSTIM,ODSCMD,ODSSZE,ODSSLT,ODSDEV,ODSV01,ODSV02,ODSV03,ODSV04,ODSV05,ODSV06,ODSV07,ODSV08,ODSV09,ODSV10,ODSVMR,ODRCEN,ODRDAT,ODRTIM,ODCPFL,ODSRCF,ODSRCL,ODSRCM,ODSRCC,ODSRCD,ODSRCT,ODCMNM,ODCMVR,ODOBLV,ODUMOD,ODPPNM,ODPPVR,ODPCNR,ODAPAR,ODSSQN,ODLCEN,ODLDAT,ODLTIM,ODSFIL,ODSFLB,ODASP,ODLBL,ODPTFN,ODOBSY,ODCRTU,ODCRTS,ODUUPD,ODUCEN,ODUDAT,ODUCNT,ODTCEN,ODTDAT,ODODMN,ODCPVR,ODCVRM,ODPVRM,ODCPRS,ODOASP,ODAAPI,ODAPIC,ODUATR,ODACEN,ODADAT,ODATIM,ODAUDT,ODSIZU,ODBPUN,ODPGP,ODSSQL,ODOSIG,ODJRST,ODJRNM,ODJRLB,ODJRIM,ODJREN,ODJRCN,ODJRDT,ODJRTI,ODSSZU,ODSBPU,ODASPL,ODLASN,ODOADN,ODLADN,ODSSIG,ODMSIG,ODASSZ,ODALGN,ODOADG,ODLADG,ODSJRA,ODSJRL,ODSJRD,ODSJRG,ODJRJF
1,072514,164203,EBERHARD  ,BIGLOBOUT ,*PGM    ,CLE       ,0,126976,SQL PROCEDURE BIGBLOBOUT                          ,0,0,1,010314,120641,EBERHARD  , ,      ,      ,          ,0,0,          ,      ,      ,      ,      ,      ,      ,      ,      ,      ,      , , ,      ,      ,999999,          ,          ,          , ,      ,      ,CRTPGM ,999999,        ,1,       ,      ,     ,      ,0,1,010314,120641,          ,          ,1,                 ,       ,Z1014P14,EBERHARD  ,Z1014P14,Y,1,011714,2, ,      ,*U,V7R2M0,V7R2M0,      ,N,0,1,0,          , ,      ,      ,*NONE     ,248,512,*NONE     ,0,0,0,          ,          , , , ,      ,      ,0,0,1,1,*SYSBAS   ,*SYSBAS   ,0,0,4096,1,*SYSBAS   ,*SYSBAS   ,          ,          ,          ,          , 
1,072514,164203,EBERHARD  ,BIGLOBOUTX,*PGM    ,CLE       ,0,126976,SQL PROCEDURE BIGBLOBOUTX                         ,0,0,1,011714,144329,EBERHARD  , ,      ,      ,          ,0,0,          ,      ,      ,      ,      ,      ,      ,      ,      ,      ,      , , ,      ,      ,999999,          ,          ,          , ,      ,      ,CRTPGM ,999999,        ,1,       ,      ,     ,      ,0,1,011714,144329,          ,          ,1,                 ,       ,Z1014P14,EBERHARD  ,Z1014P14,Y,1,021814,2, ,      ,*U,V7R2M0,V7R2M0,      ,N,0,1,0,          , ,      ,      ,*NONE     ,248,512,*NONE     ,0,0,0,          ,          , , , ,      ,      ,0,0,1,1,*SYSBAS   ,*SYSBAS   ,0,0,4096,1,*SYSBAS   ,*SYSBAS   ,          ,          ,          ,          , 
1,072514,164203,EBERHARD  ,BIGLO00001,*PGM    ,CLE       ,0,126976,SQL PROCEDURE BIGBLOBOUT22                        ,0,0,1,011714,143919,EBERHARD  , ,      ,      ,          ,0,0,          ,      ,      ,      ,      ,      ,      ,      ,      ,      ,      , , ,      ,      ,999999,          ,          ,          , ,      ,      ,CRTPGM ,999999,        ,1,       ,      ,     ,      ,0,1,011714,143919,          ,          ,1,                 ,       ,Z1014P14,EBERHARD  ,Z1014P14,Y,1,011714,1, ,      ,*U,V7R2M0,V7R2M0,      ,N,0,1,0,          , ,      ,      ,*NONE     ,248,512,*NONE     ,0,0,0,          ,          , , , ,      ,      ,0,0,1,1,*SYSBAS   ,*SYSBAS   ,0,0,4096,1,*SYSBAS   ,*SYSBAS   ,          ,          ,          ,          , 
1,072514,164203,EBERHARD  ,BIGLO00002,*PGM    ,CLE       ,0,126976,SQL PROCEDURE BIGBLOBOUT10                        ,0,0,1,011714,143948,EBERHARD  , ,      ,      ,          ,0,0,          ,      ,      ,      ,      ,      ,      ,      ,      ,      ,      , , ,      ,      ,999999,          ,          ,          , ,      ,      ,CRTPGM ,999999,        ,1,       ,      ,     ,      ,0,1,011714,143948,          ,          ,1,                 ,       ,Z1014P14,EBERHARD  ,Z1014P14,Y,1,011714,1, ,      ,*U,V7R2M0,V7R2M0,      ,N,0,1,0,          , ,      ,      ,*NONE     ,248,512,*NONE     ,0,0,0,          ,          , , , ,      ,      ,0,0,1,1,*SYSBAS   ,*SYSBAS   ,0,0,4096,1,*SYSBAS   ,*SYSBAS   ,          ,          ,          ,          , 
1,072514,164203,EBERHARD  ,BIGLO00003,*PGM    ,CLE       ,0,118784,SQL PROCEDURE BIGBLOBOUT12                        ,0,0,1,011714,144020,EBERHARD  , ,      ,      ,          ,0,0,          ,      ,      ,      ,      ,      ,      ,      ,      ,      ,      , , ,      ,      ,999999,          ,          ,          , ,      ,      ,CRTPGM ,999999,        ,1,       ,      ,     ,      ,0,1,011714,144020,          ,          ,1,                 ,       ,Z1014P14,EBERHARD  ,Z1014P14,Y,1,011714,1, ,      ,*U,V7R2M0,V7R2M0,      ,N,0,1,0,          , ,      ,      ,*NONE     ,232,512,*NONE     ,0,0,0,          ,          , , , ,      ,      ,0,0,1,1,*SYSBAS   ,*SYSBAS   ,0,0,4096,1,*SYSBAS   ,*SYSBAS   ,          ,          ,          ,          , 
1,072514,164203,EBERHARD  ,BIGLO00004,*PGM    ,CLE       ,0,118784,SQL PROCEDURE BIGBLOBOUT13                        ,0,0,1,011714,144049,EBERHARD  , ,      ,      ,          ,0,0,          ,      ,      ,      ,      ,      ,      ,      ,      ,      ,      , , ,      ,      ,999999,          ,          ,          , ,      ,      ,CRTPGM ,999999,        ,1,       ,      ,     ,      ,0,1,011714,144049,          ,          ,1,                 ,       ,Z1014P14,EBERHARD  ,Z1014P14,Y,1,011714,1, ,      ,*U,V7R2M0,V7R2M0,      ,N,0,1,0,          , ,      ,      ,*NONE     ,232,512,*NONE     ,0,0,0,          ,          , , , ,      ,      ,0,0,1,1,*SYSBAS   ,*SYSBAS   ,0,0,4096,1,*SYSBAS   ,*SYSBAS   ,          ,          ,          ,          , 
1,072514,164203,EBERHARD  ,BIGLO00005,*PGM    ,CLE       ,0,118784,SQL PROCEDURE BIGBLOBOUT16                        ,0,0,1,011714,144103,EBERHARD  , ,      ,      ,          ,0,0,          ,      ,      ,      ,      ,      ,      ,      ,      ,      ,      , , ,      ,      ,999999,          ,          ,          , ,      ,      ,CRTPGM ,999999,        ,1,       ,      ,     ,      ,0,1,011714,144103,          ,          ,1,                 ,       ,Z1014P14,EBERHARD  ,Z1014P14,Y,1,011714,1, ,      ,*U,V7R2M0,V7R2M0,      ,N,0,1,0,          , ,      ,      ,*NONE     ,232,512,*NONE     ,0,0,0,          ,          , , , ,      ,      ,0,0,1,1,*SYSBAS   ,*SYSBAS   ,0,0,4096,1,*SYSBAS   ,*SYSBAS   ,          ,          ,          ,          , 
1,072514,164203,EBERHARD  ,BIGLO00006,*PGM    ,CLE       ,0,118784,SQL PROCEDURE BIGBLOBOUT20                        ,0,0,1,011714,144134,EBERHARD  , ,      ,      ,          ,0,0,          ,      ,      ,      ,      ,      ,      ,      ,      ,      ,      , , ,      ,      ,999999,          ,          ,          , ,      ,      ,CRTPGM ,999999,        ,1,       ,      ,     ,      ,0,1,011714,144134,          ,          ,1,                 ,       ,Z1014P14,EBERHARD  ,Z1014P14,Y,1,011714,1, ,      ,*U,V7R2M0,V7R2M0,      ,N,0,1,0,          , ,      ,      ,*NONE     ,232,512,*NONE     ,0,0,0,          ,          , , , ,      ,      ,0,0,1,1,*SYSBAS   ,*SYSBAS   ,0,0,4096,1,*SYSBAS   ,*SYSBAS   ,          ,          ,          ,          , 

在此示例中,QSYS.QCMDEXC调用的最后一个参数是第一个参数的长度。 QSYS.QCMDEXC只调用DSPBOJD命令,该命令将有关库中对象的信息转储到QTEMP.OBJECT文件。从那里,我们只使用select语句查询文件以获取信息。