我想用java程序为我的物理文件创建日志。
a)我们如何通过传递模式名称来获取现有的日志名称和描述。例如: DSPFD文件(SCHEMA_NAME/TABLE_NAME)命令执行成功,但java控制台中没有输出。
b)如何读取实际的表名并在java控制台中显示。
提前谢谢。
/**
* Test program to test the AS/400 Command from Java.
*/
public static void main(String[] args) {
String server = "SERVER1";
String user = "USER_ID";
String pass = "PWD_ABC";
String getjournalcmd = "DSPFD FILE(SCHEMA_NAME/TABLE_NAME) OUTPUT(*PRINT)";
String createjournalcmd = "STRJRNPF FILE(SCHEMA_NAME/TABLE_NAME) JRN(SCH_JRN_LIB_NAME/JRN_NAME)";
AS400 as400 = null;
try {
// Create an AS400 object
as400 = new AS400(server, user, pass);
// Create a Command object
CommandCall command = new CommandCall(as400);
// Run the command.
System.out.println("Executing: " + getjournalcmd);
boolean success = command.run(getjournalcmd);
if (success) {
System.out.println("Command Executed Successfully.");
} else {
System.out.println("Command Failed!");
}
// Get the command results
AS400Message[] messageList1 = command.getMessageList();
System.out.println(messageList1.length);
for (AS400Message message : messageList1) {
System.out.println(message.getText());
}
// Create journal
System.out.println("Executing: " + createjournalcmd);
boolean success1 = command.run(createjournalcmd);
if (success1) {
System.out.println("Command Executed Successfully.");
} else {
System.out.println("Command Failed!");
}
// Get the command results
AS400Message[] messageList = command.getMessageList();
System.out.println(messageList.length);
for (AS400Message message : messageList) {
System.out.println(message.getText());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
// Make sure to disconnect
as400.disconnectAllServices();
} catch (Exception e) {
}
}
System.exit(0);
}发布于 2017-03-28 19:16:27
IBM Toolbox for Java有一个用于检索该信息的类。Here is the Javadocs。您必须使用有问题的对象的IFS名,如下所示的/QSYS.LIB/libraryname.LIB/filename.FILE
如果我想这样做,我会尝试这样做:
String journal = "";
FileAttributes fa = new FileAttributes(myConnection, ifsPath);
if (fa.isJournalingStatus()) {
journal = fa.getJournal();
}发布于 2017-03-28 19:09:13
DSPFD输出(*print)生成一个报告,但不会向调用者返回任何内容。您可以使用Java将值返回给调用者QDBRTVFD方法。另一种方法是在IBM (AS400)后端创建一个程序,该程序获取所需的信息并具有简化的参数结构。
https://stackoverflow.com/questions/43061626
复制相似问题