ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Problem converting MsgId to String

Post new topic  Reply to topic
 Problem converting MsgId to String « View previous topic :: View next topic » 
Author Message
sserrano
PostPosted: Wed Jun 26, 2002 6:36 am    Post subject: Problem converting MsgId to String Reply with quote

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
View user's profile Send private message
mrlinux
PostPosted: Wed Jun 26, 2002 7:33 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
nimconsult
PostPosted: Thu Jun 27, 2002 1:22 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Problem converting MsgId to String
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.