시소당
[데이터베이스에 파일저장 blob형]
ByteArrayOutputStream baos = new BtyeArrayOutputStream();
FileInputStream fis = new FileInputStream(args[0]);
byte[] buffer = new byte[512];
Int icount =0;
while((icount = fis.read(buffer))>0){
baos.write(buffer, 0, icount);
}
byte[] ibytes = baos.toByteArray();
fis.close();
baos.close();
PreparedStatement ps con.prepareStatement(sql);
ps.setString(1, aa);
ps.setByte(2, ibytes);
[데이터베이스에 파일읽기 blob형]
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1, aa);
ResultSet rs = ps.executeQuery();
rs.next();
Blob bfile = rs.getBlob(1);
InputStream is = rs.getBinaryStream(1);
FileOuputStream fos = new FileOutputStream(args[0]);
byte[] buffer = new byte[512];
Int icount =0;
while((icount = is.read(buffer))>0){
fos.write(buffer, 0, icount);
}
fos.close();
rs.close();
ps.close();
출처 : http://blog.empas.com/zeroscience/19942882