Here you can find the source of getBinary(Object value, int columnType)
public static String getBinary(Object value, int columnType) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.*; import java.sql.*; public class Main { public static String getBinary(Object value, int columnType) throws Exception { String result = null;/*ww w. jav a2s. co m*/ InputStream stream = null; char[] buffer = new char[1024]; try { if ((columnType == java.sql.Types.BINARY) || (columnType == java.sql.Types.VARBINARY) || (columnType == java.sql.Types.LONGVARBINARY) || (columnType == java.sql.Types.BLOB)) { byte[] blobData = ((Blob) value).getBytes(1, (int) ((Blob) value).length()); result = new String(blobData, "US-ASCII"); } else if (columnType == java.sql.Types.CLOB) { result = ((Clob) value).getSubString(1, (int) ((Clob) value).length()); } else if ((columnType == java.sql.Types.VARCHAR) || (columnType == java.sql.Types.LONGVARCHAR)) { byte[] blobData = ((Blob) value).getBytes(1, (int) ((Blob) value).length()); result = new String(blobData, "UTF-8"); } } catch (Exception ex) { throw new Exception("clob conversion failed. (" + value.toString().trim() + ")"); } finally { if (stream != null) { try { stream.close(); } catch (Exception exi) { } } } return result; } public static byte[] getBytes(Object value, int columnType) throws Exception { return (byte[]) (value); } }