Inserting values into an Informix TEXT column - rbeckman-nextgen/test-mc GitHub Wiki

  1. Mirth Connect
  2. Home
  3. Examples and Tutorials

Mirth Connect : Inserting values into an Informix TEXT column

Created by Lorenzo García, last modified on Jun 14, 2010

It is not possible to directly insert a String into an INFORMIX TEXT column.

It is necessary to get the data from InputStream source and to inset the stream using the PreparedStatement.setAsciiStream() method.

If the data is contained into a String, it is necessary to get an InputStream representation first.

Please, note that the setAsciiStream() implemented by IfxPreparedStatement uses an extra parameter to set the type conversion to perform. The extended method signature is as follows:

   public void setAsciiStream(int i, InputStream x, int length, int IfxType) throws SQLException

The costant value for the TEXT type should be stated as: IfxTypes.IFX_TYPE_TEXT.

Example:

   importPackage(java.lang);
   importPackage(java.io);
   importPackage(com.informix.lang);
   
   var txt = new StringBuffer('hi\! world');
   var bais = new ByteArrayInputStream(txt.toString().getBytes("UTF-8"));
   var len = txt.length();
   
   conn = java.sql.DriverManager.getConnection(dB_address, dB_username, dB_Password);
   
   var expression = "INSERT INTO table (txtCol) VALUES (?)";
   
   stmt = conn.prepareStatement(expression);
   stmt.setAsciiStream(1, bais, len, IfxTypes.IFX_TYPE_TEXT);
   stmt.executeUpdate();
   stmt.close();
   
   conn.close();

Document generated by Confluence on Nov 11, 2019 08:40

Atlassian

⚠️ **GitHub.com Fallback** ⚠️