ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahh_5.4.0.1/tutorl2.htm

112 lines
4.5 KiB
HTML

<?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: Using message queues (part 2 of 3)" />
<meta name="abstract" content="" />
<meta name="description" content="" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="tutorl2" />
<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: Using message queues (part 2 of 3)</title>
</head>
<body id="tutorl2"><a name="tutorl2"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example: Using message queues (part 2 of 3)</h1>
<div><p></p>
<div class="section"><p>[ <a href="tutorl1.htm#tutorl1">Previous part</a> | <a href="tutorl3.htm#tutorl3">Next part</a> ]</p>
<p>Use the following as
an example for your program.</p>
<div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
example disclaimer</a> for important legal information.</div>
<pre>//////////////////////////////////////////////////////////////////////////////////
//
// Example using the Message Queue function of the IBM Toolbox for Java
//
// This source is an example of IBM Toolbox for Java "Message Queue".
//
//////////////////////////////////////////////////////////////////////////////////
package examples;
import java.io.*;
import java.util.*;
import com.ibm.as400.access.*;
public class displayMessages extends Object
{
public static void main(String[] parameters)
{
displayMessages me = new displayMessages();
me.Main(parameters);
System.exit(0);
}
void displayMessage()
{
}
void Main(String[] parms)
{
try
{
AS400 system = new AS400(); <a href="#tutorl2__dup0007">Note 1 </a>
if (parms.length &gt; 0)
system.setSystemName(parms[0]); <a href="#tutorl2__dup0008">Note 2 </a>
}
catch (Exception e)
{
e.printStackTrace();
}
}
}</pre>
</div>
<div class="section"><ol><li id="tutorl2__dup0007"><a name="tutorl2__dup0007"><!-- --></a>A program uses the <strong>AS400</strong> object to designate which
server to connect to. With one exception, all programs that need resources
from a server must have an AS400 object. The exception is JDBC. If your program
uses JDBC, then the IBM<sup>®</sup> Toolbox for Java™ JDBC driver creates the AS400 object
for the program.</li>
<li id="tutorl2__dup0008"><a name="tutorl2__dup0008"><!-- --></a>This program assumes the first command line parameter is
the name of the server. If a parameter is passed to the program, the <strong>setSystemName</strong> method
of the AS400 object is used to set the system name. The AS400 object also
needs server sign-on information: <ul><li>If the program is running on a workstation, the IBM Toolbox for Java program prompts the user for a user
ID and password. <strong>Note:</strong> If a system name is not specified as a command
line parameter, the AS400 object also prompts for the system name.</li>
<li>If the program is running on the iSeries™ JVM, then the user ID and password
of the user running the Java program is used. In this case, the
user does not specify a system name, but lets the system name default to the
name of the system that the program is running on.</li>
</ul>
</li>
</ol>
<p>[ <a href="tutorl1.htm#tutorl1">Previous part</a> | <a href="tutorl3.htm#tutorl3">Next
part</a> ]</p>
</div>
</div>
</body>
</html>