java中byte和blob互转

1. btye[]转blob

  

byte[] bs = ...
Blob blob = conn.createBlob();
blob.setBytes(1, bs);

ps.setBlob(2, blob);

 

2. blob转byte[]

Blob b = resultSet.getBlob(metaData.getColumnLabel(2));
byte[] bytes = b.getBytes(1, (int)b.length());

 

posted @ 2015-11-13 10:31  火光闪耀  阅读(10948)  评论(0编辑  收藏  举报