|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Problem converting MsgId to String |
« View previous topic :: View next topic » |
Author |
Message
|
sserrano |
Posted: Wed Jun 26, 2002 6:36 am Post subject: Problem converting MsgId to String |
|
|
Newbie
Joined: 15 May 2002 Posts: 3 Location: Chile
|
HI,
i'm using a method in a Java class that convert the msgId from MQBYTE24 to a String with 48 characters long. I need this string, because i store it in a DB as a primary key.
I thought that any element of the byte array[24] could take values from
-127 to 127. So in order to have only positive values we added 127 to each value of the byte array. So the maximum posible value is 254, which transformed results in a 2 digit hexadecimal representation (FE). Finally the byte array[24] is transformed to a 48 character String.
The problem is that in some cases we discovered that an element of the byte array could take a value of -128, and with my algorithm as I add 127, I get a value of -1 which transformed results in a 16 digit hexadecimal (FFFFFFFFFFFFFFFF). The string generated in this cases is longer than the length value of the column in the DB.
Do you know exactly the range of values that the MQBYTE24 can take?. Is the range -128 to 127, or -128 to 128?
Cheers! _________________ sergio serrano j. |
|
Back to top |
|
 |
mrlinux |
Posted: Wed Jun 26, 2002 7:33 am Post subject: |
|
|
 Grand Master
Joined: 14 Feb 2002 Posts: 1261 Location: Detroit,MI USA
|
Iam not a java programmer but can you get an unsigned version of the
byte then it its range would be 0-255 _________________ Jeff
IBM Certified Developer MQSeries
IBM Certified Specialist MQSeries
IBM Certified Solutions Expert MQSeries |
|
Back to top |
|
 |
nimconsult |
Posted: Thu Jun 27, 2002 1:22 am Post subject: |
|
|
 Master
Joined: 22 May 2002 Posts: 268 Location: NIMCONSULT - Belgium
|
"byte" data type ranges from -128 to 127.
However there is an easier way to convert the message id into a string. You can use a String constructor to do that:
String s = new String(myMessage.messageId); _________________ Nicolas Maréchal
Senior Architect - Partner
NIMCONSULT Software Architecture Services (Belgium)
http://www.nimconsult.be |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|