<%@ page language="java" import="java.sql.*,com.jspsmart.upload.*" contentType="text/html; charset=gb2312"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" /><HTML>
<BODY BGCOLOR="white"><H1>jspSmartUpload : Sample 4</H1>
<HR><% // Variables
int count=0; // Connect to the database
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@popotang:1521:oradb","system","zjt7890"); // SQL Request
Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY ,ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("SELECT * FROM LINKWAY.UPLOADFILE "); // if the resultset is not null
if (rs.next()){ // Initialization
mySmartUpload.initialize(pageContext); // Upload
mySmartUpload.upload(); // upload file in the DB if this file is not missing
if (!mySmartUpload.getFiles().getFile(0).isMissing()){ try { rs.updateString("FILENAME",mySmartUpload.getFiles().getFile(0).getFileName());

// Add the current file in the DB field
mySmartUpload.getFiles().getFile(0).fileToField(rs,"FILE"); // Update
rs.updateRow();
count++;

} catch(Exception e) {
out.println("An error occurs : " + e.toString());
} } } // Display the number of files uploaded
out.println(count + " file(s) uploaded in the database."); rs.close();
stmt.close();
con.close();%></BODY>
</HTML>

解决方案 »

  1.   

    我在oracle里面遇到很多问题
    http://expert.csdn.net/Expert/topic/2402/2402392.xml?temp=.6813928
      

  2.   

    我看了它的例子 里面只有上传到web服务器的某个文件夹下 并没有上传到数据库的例子。
    你们的例子是这样的吗?
      

  3.   

    二楼的兄弟:我用您的方法连接到数据库后进行上传时,产生如下错误:
    java.sql.SQLException: 对只读结果集的无效操作: updateString .也就是到该位置处报错:
    rs.updateString("FILENAME",mySmartUpload.getFiles().getFile(0).getFileName());
    不知是不是stmt的打开的游标类型有错?
    请不吝指点! 谢谢!
      

  4.   


    InputStream is = rs.getBinaryByte("colname");
      

  5.   

    lfhh() 你的问题我清楚!
    Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY ,ResultSet.CONCUR_UPDATABLE);
    是这一句的问题!必须用ResultSet.CONCUR_UPDATABLE,可更新游标!
    而你用的一定是CONCUR_READ_ONLY,只读游标!
      

  6.   

    我下了jspsmartupload后,为什么第6个例子上(下载)无法使用啊?上传的例子都是正常的,就下载不成功,显示错误如下:
    The server encountered an internal error () that prevented it from fulfilling this request
    org.apache.jasper.JasperException: getOutputStream() has already been called for this response
    请问这是怎么回事啊?
      

  7.   

    http://expert.csdn.net/Expert/topic/2433/2433838.xml?temp=.5165674