Here you can find the source of getCharStream(Object value, int columnType)
public static java.io.InputStream getCharStream(Object value, int columnType) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.charset.*; public class Main { public static java.io.InputStream getCharStream(Object value, int columnType) throws Exception { java.io.InputStream charStream = null; // check for NULL if (value == null) { return null; }/*from w w w. j av a 2 s .c om*/ if (isBinary(columnType)) { charStream = new ByteArrayInputStream((byte[]) value); } else if (isString(columnType)) { charStream = new ByteArrayInputStream(value.toString().getBytes(StandardCharsets.UTF_8)); } else { throw new Exception( "charStream conversion failed. (" + value.toString().trim() + "/" + columnType + ")"); } return charStream; } public static boolean isBinary(int dataType) { switch (dataType) { case java.sql.Types.BLOB: case java.sql.Types.CLOB: case java.sql.Types.NCLOB: case java.sql.Types.BINARY: case java.sql.Types.VARBINARY: case java.sql.Types.LONGVARBINARY: case java.sql.Types.SQLXML: return true; default: return false; } } public static boolean isString(int dataType) { switch (dataType) { case java.sql.Types.CHAR: case java.sql.Types.VARCHAR: case java.sql.Types.LONGVARCHAR: case java.sql.Types.NCHAR: case java.sql.Types.NVARCHAR: case java.sql.Types.LONGNVARCHAR: return true; default: return false; } } public static byte[] getBytes(Object value, int columnType) throws Exception { return (byte[]) (value); } }