日期:2014-05-20  浏览次数:20874 次

高分求助:Struts+Sping整合框架中,大文件上传至Oracle的BLOB类型的问题。
背景:使用了自己整合的Struts(1.1)+Spring(1.2.6)的框架,还有一些自己的东西。
  数据库:Oracle
  表字段类型:BLOB

问题:在上传小文件的时候是没问题的,但大于256kb的时候就会报错:Oracle Lob can not created,java.io.Exception:...
  小于256的文件的是没问题的。但是在本项目中,文件上传到CLOB类型的就没有此问题。
  注意:两个上传的逻辑和使用方法基本是一样的。

初步解决:调查后发现,好像Struts对文件上次有默认的设置,250kb,于是在struts-config.xml中加了控制:
<controller 
  processorClass="org.apache.struts.action.RequestProcessor"
  memFileSize="4M"
  />
问题解决。不过导致新的问题。

新问题:文件上传到CLOB类型的时候,出现新的错误:java.lang.OutOfMemoryError

付部分代码:
public SqlLobValue getDenbnData(GamenData gamenData,
  HttpServletResponse response) throws IOException {
  SqlLobValue blob;
  InputStream stream = null;
  try {
  response.setContentType("text/html; charset=UTF-8");
  stream = gamenData.getFileNm().getInputStream();
  int len = gamenData.getFileNm().getFileSize();
  blob = new SqlLobValue(stream, len, Constant.BLOB_TYPE);
  } catch (IOException e) {
  // 処理失敗
  throw e;
  } finally {
  stream.close();
  }
  return blob;
  }
其中 SqlLobValue 是经过封装的Spring的LOB类
GamenData 是Form的接口

请大家帮忙看下啊,为这个问题已经头疼几天了!

------解决方案--------------------
在线等。。。
------解决方案--------------------
小弟接触过,懂得不多,卤莽说两句哈``````请多指正
用JSP上传组件应该可以解决,我们SSH用组件可以直接上传几十M到数据库的BLOB字段
例如JSPSMARTUPLOAD:
String path=smartupload.getFiles().getFile(0).getFilePathName();
File file=new File(path);
InputStream stream=file.getInputStream();
............
.....
后面把流放到PreparedStatment的参数里面,执行插入Insert语句就可以了
------解决方案--------------------
你等等 我把代码发给你看看 什么格式都有!!!