Java examples for JDBC:Binary Data
read From Blob
//package com.java2s; import java.io.BufferedInputStream; import java.io.IOException; import java.sql.Blob; import java.sql.SQLException; public class Main { public static String readFromBlob(Blob data) throws SQLException, IOException {//from w ww . jav a 2 s . co m if (data == null) { return ""; } StringBuffer ddlBuffer = new StringBuffer(); BufferedInputStream bi = new BufferedInputStream( data.getBinaryStream()); int count = 0; byte[] buffer = new byte[100]; while ((count = bi.read(buffer, 0, buffer.length)) >= 0) { ddlBuffer.append(new String(buffer, 0, count, "UTF8")); } return ddlBuffer.toString(); } }