import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* 此处插入类型说明。
* 创建日期:(2001/11/30 14:55:06)
* @author:zhubin
*/
public class BLOBUtil {
/**
* 功能说明:编码方式
* 取值范围:
* 依赖属性:
* 最后修改时间:(2002-2-27 15:30:40)
*/
private static String codeSet;
/**
* 此处插入方法说明。
* 创建日期:(2001/11/30 14:58:15)
* @return java.lang.String
* @param result java.sql.ResultSet
* @param index int
*/
public static String readBLOB(ResultSet result, int index) throws IOException,
SQLException
{
String strValue = null;
// 对于SQL NULL,方法getBinaryStream将返回null
InputStream in = result.getBinaryStream(index);
if (in == null) {
return "";
}
byte[] ba = new byte[8192];
ByteArrayOutputStream b = new ByteArrayOutputStream();
int i;
while((i = in.read(ba)) != -1){
b.write(ba, 0, i);
}
try{
strValue = b.toString(codeSet);
}catch(Exception e){
strValue = b.toString();
}
return strValue;
}
/**
* 此处插入方法说明。
* 创建日期:(2001/11/30 14:59:52)
* @return java.lang.String
* @param result java.sql.ResultSet
* @param name java.lang.String
*/
public static String readBLOB(ResultSet result, String name) throws IOException,
SQLException
{
String strValue;
// 对于SQL NULL,方法getBinaryStream将返回null
InputStream in = result.getBinaryStream(name);
if (in == null) {
return "";
}
byte[] ba = new byte[8192];
ByteArrayOutputStream b = new ByteArrayOutputStream();
int i;
while((i = in.read(ba)) != -1){
b.write(ba, 0, i);
}
try{
strValue = b.toString(codeSet);
}catch(Exception e){
strValue = b.t