首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Java 备份BLOB门类的数据生成INSERT语句可识别的字符

2012-11-05 
Java 备份BLOB类型的数据生成INSERT语句可识别的字符做数据库备份得时候,备份二进制的数据类型如BLOB类型

Java 备份BLOB类型的数据生成INSERT语句可识别的字符

做数据库备份得时候,备份二进制的数据类型如BLOB类型的数据

public static String hexToString() throws Exception {

try {

? ? ? ? ? ? ? ? ? ? ? ?InputStream in = rs.getBinaryStream(1);

int b;

StringBuffer result =new StringBuffer();

while ((b = in.read()) != -1) {

String hex = Integer.toHexString(b & 0xFF);

if (hex.length() == 1) {

hex = 0 + hex;

}

result.append(hex.toUpperCase());

}

return "0x"+result.toString();

} catch (Exception e) {

throw e;

}

}

?

热点排行