|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
Handle XML in Java |
« View previous topic :: View next topic » |
Author |
Message
|
mqjeff |
Posted: Fri Aug 19, 2016 4:00 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
fjb_saper wrote: |
He is not talking about it. He transformed the byte[] into a String. My guess is that he is sending a String downstream to the DB and the DB must know how to handle a Java String...  |
I think it would be the JDBC infrastructure or the JDBC provider on the broker side that did that... Not the database...  _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
newbee001 |
Posted: Fri Aug 19, 2016 7:39 am Post subject: |
|
|
Novice
Joined: 04 Aug 2016 Posts: 10
|
Yes, you are right. Sending byte[] to DB2 doesn't works for XML datatype, but string does.
I've a question, if my 'emp' data received from mainframe in EBCDIC format, applying the below hard coded encoding/ccsid is correct? Shouldnt I use the queue manager's encoding and ccsid format, covert to byte stream and then apply UTF-8 to store in DB2? please clarify.
byte[] mybytes=(byte[]) emp.toBitstream(null, null, null, 546, 1208, 0);
String empStr = new String(mybytes,"UTF-8"); |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Aug 19, 2016 7:51 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
If you're working in Broker, then you don't have an data in EBCDIC.
You have a logical message tree that's been converted to 1200 (1202?) _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
newbee001 |
Posted: Fri Aug 19, 2016 9:24 am Post subject: |
|
|
Novice
Joined: 04 Aug 2016 Posts: 10
|
Jeff,
In this case, should I assume safely that we dont need to bother about encoding for inbound message from ANY SYSTEM received in broker, but only when generating outbound messages (say to mainframe - MRM/CWF format), need to apply the relevant encoding and CCSID settings?
Also does the below coding sounds more appropriate than hardcoding CCSID as 1208? Covert to byte stream by applying inbound message ccsid and create string message in UTF-8 format. Please clarify.
byte[] mybytes = (byte[]) emp.toBitstream(null, null,
null, 0, inboundCCSID, 0);
empstring = new String(mybytes, "UTF-8");
Thanks in advance. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Aug 20, 2016 5:32 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
newbee001 wrote: |
Jeff,
In this case, should I assume safely that we dont need to bother about encoding for inbound message from ANY SYSTEM received in broker, but only when generating outbound messages (say to mainframe - MRM/CWF format), need to apply the relevant encoding and CCSID settings?
Also does the below coding sounds more appropriate than hardcoding CCSID as 1208? Covert to byte stream by applying inbound message ccsid and create string message in UTF-8 format. Please clarify.
byte[] mybytes = (byte[]) emp.toBitstream(null, null,
null, 0, inboundCCSID, 0);
empstring = new String(mybytes, "UTF-8");
Thanks in advance. |
Again, you're grasping at straws and don't understand what you're doing.
Assume the inbound CCSID is 500. (EBCDIC international)
So you are building a byte[] in ccsid 500 and expect java to be able to give a String when you pass the byte[] and tell it it is in UTF-8?
I'd like to borrow some of that stuff you've been drinking!!!  _________________ MQ & Broker admin |
|
Back to top |
|
 |
smdavies99 |
Posted: Sat Aug 20, 2016 9:56 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
fjb_saper wrote: |
Again, you're grasping at straws and don't understand what you're doing.
Assume the inbound CCSID is 500. (EBCDIC international)
So you are building a byte[] in ccsid 500 and expect java to be able to give a String when you pass the byte[] and tell it it is in UTF-8?
|
Sadly, this is not that uncommon. Many people have a hard time understanding CCID's and Encoding. For many devs it is not something that they have ever encountered before they do so with Broker.
When I introduce people to IIB I spend at least two hours talking about CCSID's and using examples of what happens when you get it wrong.
Timber (as kimbert) has posted in the past some links to some articles that do help explain it very well.
It takes a while to get your heady) around it but when you do... you wonder why you had problems in the first place.
Getting devs to understand how (or why you would ever want to) change from UTF-8 to UTF-16LE in the middle of a message is another matter entirely. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
|
|
|
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
|
|
|
|