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());
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());