Results 1 to 3 of 3
  1. #1
    jegadeeshsp is offline Member
    Join Date
    Aug 2008
    Posts
    2
    Rep Power
    0

    Post File upload error

    Dear all,

    I'm trying to upload a file to database, i uploaded a image size is lessthan 4 kb using blb,
    when I try with a image or file morethan 4kb, i'm getting an error:
    ORA-01460: unimplemented or unreasonable conversion requested

    i added my java code below,
    package Action;

    import java.io.FileInputStream;
    import java.io.InputStream;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.Blob;

    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.upload.FormFile;
    import org.apache.struts.upload.MultipartRequestHandler;

    import Form.StrutsUploadForm;

    /**
    * @author jegadeeswaran
    *
    */
    public class StrutsUploadAction extends Action {

    Connection conn = null;
    ResultSet rset = null;
    int s=0;

    public ActionForward execute
    (ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception{

    StrutsUploadForm myForm = (StrutsUploadForm)form;
    FormFile myFile = myForm.getTheFile();
    String contentType = myFile.getContentType();
    System.out.println(">> contentType: >> " +contentType);
    String fileName = myFile.getFileName();
    System.out.println(">> File Name: >> " +fileName);
    int fileSize = myFile.getFileSize();
    System.out.println(">> File Size: >> " +fileSize);
    byte[] fileData = myFile.getFileData();
    System.out.println(">> file data: >> " +fileData);
    InputStream inFile = myFile.getInputStream();
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conn =DriverManager.getConnection("jdbc:oracle:thin:@de vdbserver.edkaladc.com:1521:EDKADCDB","jegadeeswar an","jeg");
    System.out.println("connection >> "+conn);
    PreparedStatement pstmt = conn.prepareStatement("insert into ABSFILEUPLOAD (filename,upfile) values(?,?)");
    // conn.prepareCall("{call package.functionname(?,?)}");
    System.out.println("prepared statement >> "+pstmt);
    pstmt.setString(1,fileName);
    pstmt.setBinaryStream(2,inFile,fileSize);
    s = pstmt.executeUpdate();
    System.out.println("quert execute resultset >> "+s);
    pstmt.close();
    System.out.println("Insertion successfull");
    return mapping.findForward("success");
    }
    }

    note:
    1.i have given the buffer size in the controller
    2.i added ojdbc jar also
    Last edited by jegadeeshsp; 08-19-2008 at 06:34 AM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,457
    Rep Power
    25

    Default

    Is that a Database error message? It doesn't look like a java error message.

  3. #3
    jegadeeshsp is offline Member
    Join Date
    Aug 2008
    Posts
    2
    Rep Power
    0

    Default File upload in struts

    Quote Originally Posted by Norm View Post
    Is that a Database error message? It doesn't look like a java error message.
    you may be right, but i am able upload a file or image <4kb to database.
    but when the size is exceeding 4kb this ORA error coming.....

    To upload more size i have given the buffer size also in struts-config.xml
    <controller maxFileSize="99999k" bufferSize="99999"/>.

Similar Threads

  1. how to upload a file?
    By tommy in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 06-30-2008, 02:50 PM
  2. file upload
    By sundarjothi in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-27-2008, 11:52 AM
  3. file upload in java
    By muralikrishna in forum New To Java
    Replies: 6
    Last Post: 06-25-2008, 08:24 AM
  4. File Upload
    By ShoeNinja in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 11-09-2007, 10:09 PM
  5. how to upload a file using servlet
    By simon in forum Java Servlet
    Replies: 1
    Last Post: 08-05-2007, 03:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •