如果要把一個(gè)二制文件存入ORACLE,用標(biāo)準(zhǔn)的JDBC你就要用LONG RAW類型
create table tb_file(name varchar(20),detail long raw);
然后
File file = new File("aaa.gif");
int fileLength =(int) file.length();
InputStream fin = new FileInputStream(file);
PreparedStatement pstmt = con.prepareStatement("insert into tb_file
values('aaa.gif',?)");
pstmt.setBinaryStream (1, fin, fileLength);
pstmt.executeUpdate();
同樣讀取數(shù)據(jù)LONG RAW那樣
InputStream in = rs.getBinaryInputStream("detail");
posted on 2006-09-14 15:43 天涯孤客 閱讀(395) 評(píng)論(0) 編輯 收藏