String Content = myUpload.getRequest().getParameter("txtContent");
oracle.sql.CLOB contentClob = ((oracle.jdbc.OracleResultSet)rsClob).getCLOB("Content");
Writer os = contentClob.getCharacterOutputStream();
os.write(Content);
os.flush();
os.close();
}

解决方案 »

  1.   

    这个部分代码,而且我用的是Clob类型的,其实用Blob类似的。
      

  2.   

    要注意的是:写Clob或Blob时要先设置为不是自动提交setCommit(false),修改后用commit进行提交
      

  3.   

    txtContent是文件内容,还是路径,我从多个file控件中上传多个文件可以吗?
      

  4.   

    http://expert.csdn.net/Expert/topic/1345/1345013.xml?temp=4.656619E-02
    http://expert.csdn.net/Expert/topic/876/876147.xml?temp=.870022
    http://expert.csdn.net/Expert/topic/1339/1339835.xml?temp=.5663416<%@ page contentType="text/html;charset=gb2312" %>
    <%@ page language="java" import="com.jspsmart.upload.*"%>
    <jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
    <jsp:useBean id="inewBean" scope="page" class="hitachi.news.inewBean" />
    <HTML>
    <BODY BGCOLOR="white">
    <H1>jspSmartUpload : Sample 3</H1>
    <HR>
    <%// Variables
    int count=0;
    // Initialization
    mySmartUpload.initialize(pageContext);
    // Only allow txt or htm files
    //mySmartUpload.setAllowedFilesList("htm,html,txt,,");
    // DeniedFilesList can also be used :
    // mySmartUpload.setDeniedFilesList("exe,bat,jsp");
    // Deny physical path 
    // mySmartUpload.setDenyPhysicalPath(true);
    // Only allow files smaller than 50000 bytes 
    // mySmartUpload.setMaxFileSize(50000);
    // Deny upload if the total fila size is greater than 200000 bytes
    // mySmartUpload.setTotalMaxFileSize(200000); 
    // Upload
    mySmartUpload.upload();
    // Save the files with their original names in a virtual path of the web server
    try {
    count = mySmartUpload.save("/pic/upload/news", mySmartUpload.SAVE_VIRTUAL);
    String title=mySmartUpload.getRequest().getParameter("title");
    String content=mySmartUpload.getRequest().getParameter("content");
    String picture=mySmartUpload.getFiles().getFile(0).getFileName();inewBean.insert_news(title,content,picture);  
    } catch (Exception e){
    out.println("<b>Wrong selection : </b>" + e.toString()); 
    }
    // Display the number of files uploaded
    out.println(count + " file(s) uploaded."); %>
    </BODY>
    </HTML> <html>
    <head>
    </head>
    <body>
    <form METHOD="POST" ACTION="/hitachi/inews.jsp" ENCTYPE="multipart/form-data">
    <table><tr>
    <td>
    标题
    </td>
    <td>
    <input type="input" name="title"></input>
    </td>
    </tr><tr>
    <td>
    内容
    </td>
    <td>
    <textarea name="content"></textarea>
    </td>
    </tr><tr>
    <td>
    图片
    </td>
    <td>
    <input type="file" name="pic"></input>
    </td>
    </tr><tr>
    <td>
    </td>
    <td>
    <input type="submit" value="保存"></input>
    </td>
    </tr>
    <table>
    </form>
    </body>
    </html>
      

  5.   

    不是setCommit(false)
    应该是
    setAutoCommit(false)
      

  6.   

    to kreven(天地无用J2EE):
    inewBean.insert_news是怎么写的?
      

  7.   

    通过mySmartUpload.getRequest().getParameter("NewsTitle");
    其中mySmartUpload是个bean:<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />表单用提交用<form method="post" enctype="multipart/form-data"    action="upload.jsp">
      

  8.   

    我的[email protected]
    发给我一份,我急用!!!!!!!!!!!!!!
      

  9.   

    应该用byte[]处理上传文件File file = mySmartUpload.getFiles().getFile(0);
    int size = file.getSize();
    System.out.println("received file.size:"+size);
    byte[] content = new byte[size];
    for(int i = 0; i < size; i++)
    {
        content[i] = file.getBinaryData(i);
    }另外使用Oracle thin驱动存储Blob类型时最大文件大小好像是4k
    应使用oci驱动,jdbc:oracle:oci8:@xx
      

  10.   

    to knight_qmh(辉) :
    我使用的是oci,有多大限制
      

  11.   

    你到这个网站去看,关于上传的例子那里都有
    www.jspsmart.com
      

  12.   

    to  kmonkey(家里有只老鼠就是我) :
    谢谢你的建议,很不错的网站,请问
    例子中的jsp写成bean的话,mySmartUpload.initialize(pageContext)出错
    请问怎么解决?
      

  13.   

    to kreven(天地无用J2EE):
    帮我解决一下问题(已发邮件给你!)
      

  14.   

    to  kmonkey(家里有只老鼠就是我) :
    有哪些servlet包需要?望指点!