怎么把字节数组插入数据库的blob字段
1个回答
推荐于2016-10-22
展开全部
Java代码实现方法
public byte[] blob2ByteArr(Blob blob) throws Exception {
byte[] b = null;
try {
if (blob != null) {
long in = 0;
b = blob.getBytes(in, (int) (blob.length()));
}
} catch (Exception e) {
e.printStackTrace();
throw new Exception("fault");
}
return b;
}
public byte[] blob2ByteArr(Blob blob) throws Exception {
byte[] b = null;
try {
if (blob != null) {
long in = 0;
b = blob.getBytes(in, (int) (blob.length()));
}
} catch (Exception e) {
e.printStackTrace();
throw new Exception("fault");
}
return b;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询