Hi I have this simple
java program (code shown below) to connect and get message from an mq series queue.When I run it I get the exception shown below .The message , however disappears from the queue which means the getting is working.I debugged and realize the code is failing on the line "System.out.println("Received message : "+ testRes.readLine()); "
java.io.UnsupportedEncodingException: Cp437
at sun.io.Converters.getConverterClass(Converters.java:121)
at sun.io.Converters.newConverter(Converters.java:152)
at sun.io.ByteToCharConverter.getConverter(ByteToCharConverter.java:81)
at java.io.InputStreamReader.<init>(InputStreamReader.java:93)
at com.ibm.mq.MQMessage.readConvertedLine(MQMessage.java:626)
at com.ibm.mq.MQMessage.readLine(MQMessage.java:475)
at SCVDirect.<init>(SCVDirect.java:52)
at Receiver.main(Receiver.java:18)
Here is the code :
import com.ibm.mq.*;
import java.io.*;
/**
* @author mutuj
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class Receiver {
private
String qManager = "COFQM1";
private MQQueueManager qMgr;
public static void main(String[] args) {
new Receiver();
}
public Receiver() {
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
MQQueue qsres = null;
try {
//create connection to queue manager
qMgr = new MQQueueManager(qManager);
qsres = qMgr.accessQueue("QSRES", openOptions);
MQMessage testRes = new MQMessage();
while (true) {
qsres.get(testRes);
System.out.println("Received message : "+ testRes.readLine());
}
} catch (MQException mqex) {
System.out.println(
"A websphere error occured : Completion code "
+ mqex.completionCode
+ "Reason code "
+ mqex.reasonCode);
mqex.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
qsres.close();
qMgr.disconnect();
} catch (MQException mqex) {
System.out.println(
"A websphere error occured : Completion code "
+ mqex.completionCode
+ "Reason code "
+ mqex.reasonCode);
mqex.printStackTrace();
} catch (Exception ex) {
}
}
}
}
jeff