ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahx_5.4.0.1/rzahxcolluserdefexquery.htm

208 lines
8.1 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Example: Program to query the collection object" />
<meta name="abstract" content="This sample program illustrates how to query the data stored in the collection object using the Java classes shipped in the ColSrv.jar file in QIBM/ProdData/OS400/CollectionServices/lib." />
<meta name="description" content="This sample program illustrates how to query the data stored in the collection object using the Java classes shipped in the ColSrv.jar file in QIBM/ProdData/OS400/CollectionServices/lib." />
<meta name="DC.Relation" scheme="URI" content="rzahxcollservuserdefexample.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzahxcolluserdefexquery" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Example: Program to query the collection object</title>
</head>
<body id="rzahxcolluserdefexquery"><a name="rzahxcolluserdefexquery"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example: Program to query the collection object</h1>
<div><p>This sample program illustrates how to query the data stored in
the collection object using the Java™ classes shipped in the ColSrv.jar file
in QIBM/ProdData/OS400/CollectionServices/lib.</p>
<div class="section"><div class="note"><span class="notetitle">Note:</span> By using the code examples, you agree to the terms of the <a href="codedisclaimer.htm">Code license and disclaimer information</a>.</div>
</div>
<div class="section"><h4 class="sectiontitle">Java sample code</h4><pre>import com.ibm.iseries.collectionservices.*;
class testmco2
{
public static void main( String argv[] )
{
String objectName = null;
String libraryName = null;
String repoName = null;
MgtcolObj mco = null;
int repoHandle = 0;
int argc = argv.length;
MgtcolObjAttributes
attr = null;
MgtcolObjRepositoryEntry
repoE = null;
MgtcolObjCollectionEntry
collE = null;
int i,j;
if ( argc &lt; 3 )
{
System.out.println("testmco2 objectName libraryName repoName");
System.exit(1);
}
objectName = argv[0];
libraryName = argv[1];
repoName = argv[2];
if ( ! objectName.equals( "*ACTIVE" ) )
mco = new MgtcolObj( objectName, libraryName );
else
try
{
mco = MgtcolObj.rtvActive();
} catch ( Exception e)
{
System.out.println("rtvActive(): Exception " + e );
System.exit(1);
}
System.out.println("Object name = " + mco.getName() );
System.out.println("Library name = " + mco.getLibrary() );
try
{
attr = mco.rtvAttributes( "MCOA0100" );
} catch ( Exception e)
{
System.out.println("rtvAttributes(): MCOA0100: Exception " +
e );
System.exit(1);
}
System.out.println("MCOA0100: Object " + mco.getLibrary() + "/" + mco.getName() );
System.out.println(" size = " + attr.size + " retention = " + attr.retentionPeriod +
" interval = " + attr.dftInterval + " time created = " + attr.timeCreated +
" time updated = " + attr.timeUpdated );
System.out.println(" serial = " + attr.logicalPSN + " active = " + attr.isActive +
" repaired = " + attr.isRepaired + " summary = " + attr.sumStatus +
" repo count = " + attr.repositoryCount );
if ( attr.repositoryInfo != null )
for(i = 0; i &lt; attr.repositoryCount; i++ )
{
repoE = attr.repositoryInfo[ i ];
System.out.println(" name = " + repoE.name + " category = " + repoE.categoryName +
" size = " + repoE.size );
for( j = 0; j &lt; repoE.collectionInfo.length; j++ )
{
collE = repoE.collectionInfo[ j ];
System.out.println(" startTime = " + collE.startTime + " endTime = " + collE.endTime +
" interval = " + collE.interval );
}
}
try
{
attr = mco.rtvAttributes( "MCOA0200" );
} catch ( Exception e)
{
System.out.println("rtvAttributes(): MCOA0200: Exception " + e );
System.exit(1);
}
System.out.println("MCOA0200: Object " + mco.getLibrary() + "/" + mco.getName() );
System.out.println(" size = " + attr.size + " retention = " + attr.retentionPeriod +
" interval = " + attr.dftInterval + " time created = " + attr.timeCreated +
" time updated = " + attr.timeUpdated );
System.out.println(" serial = " + attr.logicalPSN + " active = " + attr.isActive +
" repaired = " + attr.isRepaired + " summary = " + attr.sumStatus +
" repo count = " + attr.repositoryCount );
if ( attr.repositoryInfo != null )
for(i = 0; i &lt; attr.repositoryCount; i++ )
{
repoE = attr.repositoryInfo[ i ];
System.out.println(" name = " + repoE.name + " category = " + repoE.categoryName +
" size = " + repoE.size );
for( j = 0; j &lt; repoE.collectionInfo.length; j++ )
{
collE = repoE.collectionInfo[ j ];
System.out.println(" startTime = " + collE.startTime + " endTime = " + collE.endTime +
" interval = " + collE.interval );
}
}
if ( repoName.equals("NONE") )
return;
try
{
mco.open();
} catch ( Exception e)
{
System.out.println("open(): Exception " + e );
System.exit(1);
}
try
{
repoHandle = mco.openRepository( repoName, "MCOD0100" );
} catch ( Exception e)
{
System.out.println("openRepository(): Exception " + e );
mco.close();
System.exit(1);
}
System.out.println("repoHandle = " + repoHandle );
MgtcolObjReadOptions readOptions = new MgtcolObjReadOptions();
MgtcolObjRecInfo recInfo = new MgtcolObjRecInfo();
readOptions.option = MgtcolObjReadOptions.READ_NEXT;
readOptions.recKey = null;
readOptions.offset = 0;
readOptions.length = 0;
while ( recInfo.recStatus == MgtcolObjRecInfo.RECORD_OK )
{
try
{
mco.readData( repoHandle, readOptions, recInfo, null );
} catch ( Exception e)
{
System.out.println("readData(): Exception " + e );
mco.close();
System.exit(1);
}
if( recInfo.recStatus == MgtcolObjRecInfo.RECORD_OK )
{
System.out.print("Type = " + recInfo.recType );
System.out.print(" Key = " + recInfo.recKey );
System.out.println(" Length = " + recInfo.recLength );
}
}/* while ... */
mco.closeRepository( repoHandle );
mco.close();
}/* main() */
}/* class testmco2 */
</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzahxcollservuserdefexample.htm" title="Look here for sample programs that illustrate how you can use the provided APIs to integrate customized data collections into Collection Services.">Example: Implementing user-defined categories</a></div>
</div>
</div>
</body>
</html>