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.

 View Only
  • 1.  ISQLWorker

    Posted Wed September 15, 2010 11:34 AM

    Hi All,
    I’ve a oracle table which has a BLOB column and an image needs to be stored.
    Can anyone suggest a way to use ISQLWorker to insert the image as BLOB in the database table


    #webMethods
    #webMethods-BPMS
    #MWS-CAF-Task-Engine


  • 2.  RE: ISQLWorker

    Posted Wed September 22, 2010 10:34 PM

    I’d recommend using Integration Server for your Data Access Layer wherever possible, but below is some sample code.

    The code expects that your database table has two columns with one column for the blob and the other column for a unique ID that you specify.

    import java.sql.SQLException;
    
    import com.webmethods.portal.service.meta2.IMetaContext;
    import com.webmethods.portal.service.meta2.IMetaManager;
    import com.webmethods.portal.service.meta2.MetaException;
    import com.webmethods.portal.service.sql.ISqlWorker;
    import com.webmethods.portal.system.PortalSystem;
    
    public class DBTest {
    
    public void storeBLOBData(String tableName, 
    String blobFieldName, 
    byte [] bytes,
    String keyFieldName,
    int keyFieldValue) throws SQLException, MetaException{
    
    ISqlWorker worker = null;
    try {
    IMetaManager mm = (IMetaManager)PortalSystem.getMetaProvider();
    IMetaContext mc = mm.getDefaultContext();
    worker = mc.createWorker();
    worker.executeBlobUpdate(tableName, 
    blobFieldName, 
    bytes,
    keyFieldName, 
    new Integer(keyFieldValue));
    
    worker.commitTran();
    } finally {
    if (worker != null) {
    worker.release();
    }
    }
    }
    }

    [/code]


    #MWS-CAF-Task-Engine
    #webMethods
    #webMethods-BPMS