去这里看看吧
http://www.csdn.net/expert/topic/757/757317.xml?temp=.4518854
http://www.csdn.net/expert/topic/441/441708.xml?temp=.1830866
http://www.csdn.net/expert/topic/83/83096.xml?temp=.8129236

解决方案 »

  1.   

    用smartupload上传数据到数据库只有在mySQL下能成功,SQLServer或Oracle不能成功,不能用它提供的方法向数据库写,要自己完成流写入数据库的操作。
    <H1>上传图片到数据库(Sql Server200 image)</H1>
    <HR>
    <%
    Connection con; 
    Statement stmt; 
    PreparedStatement prestmt;
    ResultSet rs; 
    String strSql; // Variables
    int count=0; //加载驱动程序,下面的代码为加载JDBD-ODBC驱动程序 
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
    //用适当的驱动程序连接到数据库,sqltest"是系统dsn名 
    String url="jdbc:odbc:sqltest";//for SQL Server200 
    //建立连接,类似于ASP中的创建数据库联接 
    con=DriverManager.getConnection(url, "sa", "shf007"); 
    // SQL Request // Initialization
    mySmartUpload.initialize(pageContext);
    // Upload
    mySmartUpload.upload();
    if (!mySmartUpload.getFiles().getFile(0).isMissing())
    { try {
    byte[] data_tmp=new byte[mySmartUpload.getFiles().getFile(0).getSize()];
    for (int i=0;i<mySmartUpload.getFiles().getFile(0).getSize();i++) 
    {
         data_tmp[i]=mySmartUpload.getFiles().getFile(0).getBinaryData(i);
    } strSql="update img_table set file_name=?,file_data=? where id=? ";
    prestmt=con.prepareStatement(strSql);
    prestmt.setString(1,mySmartUpload.getFiles().getFile(0).getFileName());
    prestmt.setBytes(2,data_tmp);
    prestmt.setInt(3,1);
    count=prestmt.executeUpdate();
    }
     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.");
    prestmt.close();

    con.close();
    ......
    %>