IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
Expand all | Collapse all

read from pipline database BINARY object and convert it to String

  • 1.  read from pipline database BINARY object and convert it to String

    Posted 05/18/16 09:22 AM

    Hi
    I am reading in SQL Adapter service BINARY data from database and need to convert to String. How do I get it from the Pipeline? In my SQL Adapter the database value is defined as follwo:
    Outpu JDBC Type : Binary
    Output Field Type : byte array
    and I ttried in JAVA service followings:

    option1
    Byte bytesData = (Byte) IDataUtil.getObjectArray(mycursor, “MyBinaryData”)

    option2
    String mySTring= IDataUtil.getString(aResult, “MyBinaryData”);
    But no of them return correct data
    ?

    Regarding option1 which I think is the right way, is trying to get it as objectArray the right way?
    I tried following but does not work:

    byte b2 = new byte[bytesData.length];
    String mydataString = new String(b2);
    System.out.println(mydataString );
    Thanks for any help


    #Adapters-and-E-Standards
    #webMethods
    #Integration-Server-and-ESB


  • 2.  RE: read from pipline database BINARY object and convert it to String

    Posted 05/18/16 11:51 PM

    Try using the charset used by database

    String(byte bytes, Charset charset)
    Constructs a new String by decoding the specified array of bytes using the specified charset.


    #webMethods
    #Adapters-and-E-Standards
    #Integration-Server-and-ESB


  • 3.  RE: read from pipline database BINARY object and convert it to String

    Posted 05/19/16 06:39 AM

    I used the cast fuction in select statement to cast this binary value to char and it works:
    CAST(MyElement as char(20) ) as MyElement
    thanks


    #Adapters-and-E-Standards
    #Integration-Server-and-ESB
    #webMethods