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 » WebSphere Message Broker (ACE) Support » Need help on ESQL-to-Java mapping

Post new topic  Reply to topic
 Need help on ESQL-to-Java mapping « View previous topic :: View next topic » 
Author Message
dan2WMB
PostPosted: Mon Dec 13, 2010 10:02 pm    Post subject: Need help on ESQL-to-Java mapping Reply with quote

Novice

Joined: 06 Aug 2010
Posts: 12

My requirement is to print a String(with LineFeed) in java method. I am trying to call a java function from ESQL as follows

DECLARE newLineFeed CHARACTER CAST(X'0A' AS CHARACTER CCSID 1208);
DECLARE msg CHARACTER 'test msg';

SET msg = msg || newLineFeed || 'msg in the new line';

CALL logInfo(msg);
.
.
.
CREATE Function logInfo (IN msg CHAR)
LANGUAGE JAVA
EXTERNAL NAME "com.Logger.info";

When i try to print this "msg" in the Logger class, i am getting the output as "test msg(some junk character)msg in the new line".

I expected the output should be like following.

test msg
msg in the new line

I also tried to use '\r\n' for the line feed, it is also not working.

Please help me to print a String with new line feed.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Dec 14, 2010 12:33 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Shouldn't CCSID 1208 have 0x0d0a as new line?
Also you are not passing a String to Java. You are passing a mixed CCSID value to Java where the text is in unicode (String) and the line feeds are in UTF-8 ? That you are printing some strange char and then the line feed is expected.
Try and just add LF to your string like this:
Code:
SET msg = msg || LF || 'msg in the new line';


Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Tue Dec 14, 2010 1:29 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
Shouldn't CCSID 1208 have 0x0d0a as new line?
I don't think the character encoding implies very much about the newline convention. CCSID 1208 ( UTF-8 ) can encode a carriage return, newline or a pair equally well.
Back to top
View user's profile Send private message
mgk
PostPosted: Tue Dec 14, 2010 1:48 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Quote:
I don't think the character encoding implies very much about the newline convention. CCSID 1208 ( UTF-8 ) can encode a carriage return, newline or a pair equally well


Agreed, UTF-8 can encode a newline in different ways.

Quote:
When i try to print this "msg" in the Logger class, i am getting the output as "test msg(some junk character)msg in the new line".


However, the application used to display the output may not understand a single X'0A' on Windows.

Quote:
Also you are not passing a String to Java. You are passing a mixed CCSID value to Java where the text is in unicode (String) and the line feeds are in UTF-8 ?


However, this is not the case, as the ESQL is clever enough to convert the 1208 X'0A' into unicode before the concatenation taken place.

As fjb_saper says you will need to use X'D' as well, so your code should look like this:

Code:
DECLARE newLineFeed CHARACTER CAST(X'0D0A' AS CHARACTER CCSID 1208);


Kind Regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
dan2WMB
PostPosted: Tue Dec 14, 2010 5:56 am    Post subject: Reply with quote

Novice

Joined: 06 Aug 2010
Posts: 12

cool....it worked as you told mgk. Thnaks you very much.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Tue Dec 14, 2010 6:26 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Just a note:

Here is a related thread:

http://www.mqseries.net/phpBB/viewtopic.php?p=281091&sid=a66e7fd80e8d83f3319eadc15b24080a

Also, if using MbService.logInformation, there is a patch that enables linefeeds to be sent to Syslog. Without the patch, the AIX Syslog will not show linefeeds because Broker 7.0.0.0 strips out the linefeed.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Need help on ESQL-to-Java mapping
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.