Announcement

Collapse
No announcement yet.

How to read Blob data from database transform to OBX.5 message

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to read Blob data from database transform to OBX.5 message

    Hi

    Is there anyway to transform the blob data stored in sybase database to text string in OBX.5 message?

    Outbound channel created with direct select from the table where blob data is residing. HL7 message generated to text file shows only javax.sql.clobimpl in OBX.5

    mapping

    tmp[..][OBX.5]=msg['t_observation'].toString() // t_observation is column of blob datatype

    How this object can be converted to readable text data?

  • #2
    Re: How to read Blob data from database transform to OBX.5 message

    Code:
          StringBuffer strOut = new StringBuffer();
          String aux;
                
    	// We access to stream, as this way we don't have to use the CLOB.length() which is slower...
    	BufferedReader br = new BufferedReader(cl.getCharacterStream());
    
          while ((aux=br.readLine())!=null)
                 strOut.append(aux);
    
          return strOut.toString();
    This is generic Java code to read the data in a clob. You can write JAVA in the transformers, however you have to use the fully qualified package names (use Packages.java.[etc] for example).

    -Chris
    Chris Lang

    Comment


    • #3
      Re: How to read Blob data from database transform to OBX.5 message

      Thanx for the reply.I am able to deploy using stored procedure example.

      what is the datatype of msg['t_observation'] ?
      msg['t_observation'] how can we convert this to blob data??
      in script.

      var clobobject = (java.sql.clob) msg['t_observation'] ; // In script this is not supported.throws javascript validation error.


      Comment


      • #4
        Re: How to read Blob data from database transform to OBX.5 message

        //using stored procedure in javascript

        var dbConn = DatabaseConnectionFactory.createDatabaseConnection (&#039;net.sourceforge.jtds.jdbc.Driver&#039;, &#039;jdbc:jtds:sybase://<IP>:<port>/<database>&#039;, &#039;sa&#039;, &#039;&#039;
        var expression = &#039;select n_patienttestno,t_observation from observation where n_patienttestno=1234&#039; ;//here t_observation is blob column
        var result = dbConn.executeCachedQuery(expression);

        result.next();
        var xray = result.getClob(2);
        var strOut = new java.lang.StringBuffer();
        var aux = new java.lang.String();

        // RTF data conversion

        var kit = new Packages.javax.swing.text.rtf.RTFEditorKit()
        var doc = new Packages.javax.swing.text.DefaultStyledDocument();
        kit.read(xray.getAsciiStream(), doc, 0);

        var text=doc.getText(0,doc.getLength());
        // The data in Text Format
        localMap.put(&#039;xray&#039;,text);




        Comment

        Working...
        X