Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
WEBINAR June 25, 2025: Build on Apache Iceberg with Qlik Open Lakehouse - REGISTER TODAY

Qlik Talend Data Integraion: How to Ingest CLOB Column from DB2 in tDBInput component

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
wei_guo
Support
Support

Qlik Talend Data Integraion: How to Ingest CLOB Column from DB2 in tDBInput component

Last Update:

Jun 10, 2025 10:54:32 PM

Updated By:

Xiaodi_Shi

Created date:

Jun 10, 2025 10:54:54 PM

In Talend tDBInput component,  CLOB data types can not be handled properly when you are attempting to ingest data from source DB2 to Target one.

This article briefly introduces how to properly handle CLOB data types when ingesting from DB2 to Target using Talend.

 

How To

  1. Write a Utils class ClobUtils with the method getClobAsString under Code-> Global Routines
    You can create your own routines according to your particular factorization needs.
    For more information, please check qlik Help Documentation about: Creating user routines
  2. Use this Utils in tMap/tJavaRow component : ClobUtils.getClobAsString(row1.C1)
    You can call any function in any of the system and user routines from your Job components in order to run them at the same time as your Job. Please check Help Documentation about: Calling-routine-function-from-job

 

The code below is a scratch version that needs testing and rewriting.

Use this as an example to study:

==Example code: ===
package routines;
import java.sql.Clob;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.io.IOUtils; package routines; import java.sql.Clob;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.io.IOUtils; import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.lang.String; public class ClobUtils {     public static String getClobAsString(Object obj) {
        String out = null;
        if (obj != null && obj instanceof Clob) {
            out=getClobAsString((Clob) obj);
        } else {
            Logger.getLogger("ClobUtils").log(Level.FINE, "null value");
        }
        return out;
    }     public static String getClobAsString(Clob clobObject) {
        String clobAsString = null;
        if (clobObject != null) {
            long clobLength;
            try {
                clobLength = clobObject.length();                 if (clobLength <= Integer.MAX_VALUE) {
                    clobAsString = clobObject.getSubString(1, (int) clobLength);
                } else {
                    InputStream in = clobObject.getAsciiStream();
                    StringWriter w = new StringWriter();
                    IOUtils.copy(in, w, "UTF-8");
                    clobAsString = w.toString();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return clobAsString;
    }
}

 

Related Content

 

Environment

Labels (1)
Contributors
Version history
Last update:
Tuesday
Updated by: