烦大侠们帮忙解决一下smartupload的问题
smartupload是不是只能用来上传,不能利用它存入oracle,可不可以不利用java.io.File存入库。俺看到了这段代码,不是很明白,烦请讲解。这个代码可以直接存入库中吗?
既然有插入数据的过程 String strSql = "insert into test(id,name,content) values('" + id + "','" + fileName + "',empty_blob())";
stmt.execute(strSql);
为何又要select,而且zyw_test和test什么区别?
("select content from zyw_test where id='" + id + "' for update ");
if (rs.next()) {
oracle.sql.BLOB blob = ( (oracle.jdbc.OracleResultSet) rs).getBLOB("content");
OutputStream outStream = blob.getBinaryOutputStream();
inStream.read(bytes);
outStream.write(bytes);
outStream.flush();
stmt.execute("commit");
outStream.close();
("select content from zyw_test where id='" + id + "' for update ");
if (rs.next()) {
oracle.sql.BLOB blob = ( (oracle.jdbc.OracleResultSet) rs).getBLOB("content");
OutputStream outStream = blob.getBinaryOutputStream();
inStream.read(bytes);
outStream.write(bytes);
outStream.flush();
stmt.execute("commit");
outStream.close();
问题点数:0、回复次数:6Top
1 楼zj2977(大地)回复于 2003-09-04 20:28:46 得分 0
什么叫什么区别?不同表不同实现功能你说有什么区别!Top
2 楼lynx1111(任我行:一个PLMM看着就兴奋的男人)回复于 2003-09-04 20:51:29 得分 0
http://expert.csdn.net/Expert/topic/1836/1836241.xml?temp=.3541834Top
3 楼javatech(天方夜谈)回复于 2003-09-04 20:56:11 得分 0
呵呵,我个人的理解是BLOB类型的字段是不能够直接用INSERT语句执行插入File之类的东东,应该可以插入已经是BLOB类型的东东。用"select content from zyw_test where id='" + id + "' for update "来实现插入BLOB类型的原理在于,对于还不是BLOB类型的文件如文本文件,需要以流的方式写入,所以需要先得到一个BLOB对象,然后将需要写入的内容以流的方式写入。就像往一个文件写一些别的东东一样,需要先new 一个File对象,然后在写入内容!Top
4 楼wobupa(wobupa)回复于 2003-09-05 11:19:59 得分 0
不好意思,代码是从以前贴子copy过来的。其实问题就是既然有插入数据的过程,那个select有什么用处,从哪里开始真正插入blob字段的数据?以下这一段是不是插入blob数据,俺看不出来阿。烦请讲解!
("select content from zyw_test where id='" + id + "' for update ");
if (rs.next()) {
oracle.sql.BLOB blob = ( (oracle.jdbc.OracleResultSet) rs).getBLOB("content");
OutputStream outStream = blob.getBinaryOutputStream();
inStream.read(bytes);
outStream.write(bytes);
outStream.flush();
stmt.execute("commit");
outStream.close();
("select content from zyw_test where id='" + id + "' for update ");
if (rs.next()) {
oracle.sql.BLOB blob = ( (oracle.jdbc.OracleResultSet) rs).getBLOB("content");
OutputStream outStream = blob.getBinaryOutputStream();
inStream.read(bytes);
outStream.write(bytes);
outStream.flush();
stmt.execute("commit");
outStream.close();
Top
5 楼wobupa(wobupa)回复于 2003-09-05 11:25:52 得分 0
to lynx1111(任我行)
这个我看过了,是用java.io.File file 变成流写入的,smartupload没有类似的方法吗?可不可以,直接用com.jspsmart.upload.File myFile 写入blobTop
6 楼wobupa(wobupa)回复于 2003-10-10 14:14:29 得分 0
过时继续Top



