Upload an .doc attachment into a blob field in Oracle

sir i have to upload a .doc file into a blob field in the oracle database.
help with any code, or code links
The code i am having,pls suggest if any changes...
String QUERY_ENHANCEMENT = "INSERT INTO EKMIS_ENHANCEMENT(USER_ID,ENH_TYPE,MODULE,DESCRIPTION,ATTACHMENT)";
     QUERY_ENHANCEMENT = QUERY_ENHANCEMENT+"VALUES(?,?,?,?,?)";
          PreparedStatement preparedStatement = connection.prepareStatement(QUERY_ENHANCEMENT);
     preparedStatement.setString(1, enhancementTO.getUserid());
     preparedStatement.setString(2, enhancementTO.getType());
     preparedStatement.setString(3, enhancementTO.getModule());
     preparedStatement.setString(4, enhancementTO.getDescription());
     try
          File anyFile = new File(enhancementTO.getPath());
          InputStream is = new FileInputStream(anyFile);
          preparedStatement.setBinaryStream( 5, is, (int)(anyFile.length()));
     catch(FileNotFoundException fnfe)
          System.out.println("Exception while archiving to BLOB/CLOB");
          fnfe.printStackTrace();
     return preparedStatement;

the html form is like this..
<table width="780" cellpadding="2" cellspacing="0" border="0">
               <tr>
                    <td colspan="6" class="SectionHeader">USER COMMENTS/SUGGESTIONS/COMPLAINTS</td>
               </tr>
               <tr>
                                   <td height="18" class="boldLabel_RA">
                                        User Id
                                   </td>
                                   <td height="18" class="value_LA">
                                        <input name="userId" type="text" class="big" readonly="true" value="{sessionAttributes/ekmis.UserID}"/>
                                   </td>
                                   <td height="18" class="boldLabel_RA">
                                        User Name
                                   </td>
                                   <td height="18" class="value_LA">
                                        <input name="userName" type="text" class="big" readonly="true" value="{sessionAttributes/ekmis.UserName}"/>
                                   </td>
                                   <td height="18" class="boldLabel_RA">
                                        Select Type
                                   </td>
                                   <td height="18" class="value_LA">
                                        <select class="big" name="type">
                                             <option value="0"/>
                                             <option value="E">Enhancement</option>
                                             <option value="S">Suggestion</option>
                                             <option value="B">Bug</option>
                                        </select>
                                   </td>
                              </tr>
               <tr>
                    <td height="18" class="boldLabel_RA">Select Module</td>
                    <td colspan="5" height="18" class="value_LA">
                         <select name="mod" class="extralong">
                         <option value="0"/>
                              <xsl:call-template name="getModules" >
                                   <xsl:with-param name="modules" select="requestParameters/param[@name='sat']" />
                              </xsl:call-template>
                         </select>
                    </td>
               </tr>
               <tr>
                    <td colspan="6" class="SectionHeader"/>
               </tr>
               <tr>
                    <td height="18" class="boldLabel_RA">Description</td>
                    <td colspan="5" height="18" class="value_LA">
                         <textarea name="description" class="big"/>
                    </td>
               </tr>
               <tr>
                    <td height="18" class="boldLabel_RA">Add Attachment</td>
                    <td colspan="5" height="18" class="value_LA">
                         <input name="path" type="file" class="big"/>
                    </td>
               </tr>
          </table>

Similar Messages

  • Error when reading BLOB field from Oracle usin Toplink

    We experience a very annoying problem when trying to read a BLOB
    field from Oracle 8.1.6.2.0 using TOPLink 3.6.3. I have attached the
    exception stack trace that is reported to the console. As far as I can
    judge a fault at oracle.sql.LobPlsqlUtil.plsql_length() happens first and
    then at TOPLink.Private.DatabaseAccess.DatabasePlatform.convertObject().
    The exception is permanently repeating that is very critical for us.
    ServerSession(929808)--Connection(5625701)--SELECT LOBBODY, ID, LABEL, FK_OBJECT_ID, FK_OBJECTTYPE FROM NOTE WHERE (ID = 80020)
    INTERNAL EXCEPTION STACK:
    java.lang.NullPointerException
    at oracle.sql.LobPlsqlUtil.plsql_length(LobPlsqlUtil.java:936)
    at oracle.sql.LobPlsqlUtil.plsql_length(LobPlsqlUtil.java:102)
    at oracle.jdbc.dbaccess.DBAccess.lobLength(DBAccess.java:709)
    at oracle.sql.LobDBAccessImpl.length(LobDBAccessImpl.java:58)
    at oracle.sql.BLOB.length(BLOB.java:71)
    at TOPLink.Private.Helper.ConversionManager.convertObjectToByteArray(ConversionManager.java:309)
    at TOPLink.Private.Helper.ConversionManager.convertObject(ConversionManager.java:166)
    at TOPLink.Private.DatabaseAccess.DatabasePlatform.convertObject(DatabasePlatform.java:594)
    at TOPLink.Public.Mappings.SerializedObjectMapping.getAttributeValue(SerializedObjectMapping.java:43)
    at TOPLink.Public.Mappings.DirectToFieldMapping.valueFromRow(DirectToFieldMapping.java:490)
    at TOPLink.Public.Mappings.DatabaseMapping.readFromRowIntoObject(DatabaseMapping.java:808)
    at TOPLink.Private.Descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:173)
    at TOPLink.Private.Descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:325)
    at TOPLink.Private.Descriptors.ObjectBuilder.buildObjectsInto(ObjectBuilder.java:373)
    at TOPLink.Public.QueryFramework.ReadAllQuery.execute(ReadAllQuery.java:366)
    at TOPLink.Public.QueryFramework.DatabaseQuery.execute(DatabaseQuery.java:406)
    I have started the application with Oracle JDBC logging on and found that the problem may originate in a possible lack of syncronization in the pooled connection implementation:
    DRVR FUNC OracleConnection.isClosed() returned false
    DRVR OPER OracleConnection.close()
    DRVR FUNC OracleConnection.prepareCall(sql)
    DRVR DBG1 SQL: "begin ? := dbms_lob.getLength (?); end;"
    DRVR FUNC DBError.throwSqlException(errNum=73, obj=null)
    DRVR FUNC DBError.findMessage(errNum=73, obj=null)
    DRVR FUNC DBError.throwSqlException(reason="Logical handle no longer valid",
    SQLState=null, vendorCode=17073)
    DRVR OPER OracleConnection.close()
    so the prepareCall() is issued against an already closed connection and the
    call fails.
    I assume we have been using a JDBC 2.0 compliant driver. We tried out
    drivers that Oracle supplies for 8.1.6, 8.1.7 versions. To be true I
    couldn't find any information about the JDBC specification they conform to. Does it
    mean that these drivers may not be 100%-compatible with JDBC 2.0 Spec?
    How can I find out if they are 2.0 compliant?
    Also I have downloaded Oracle 9.2.0.1 JDBC drivers. This seemed to work
    fine until we found another incompatibility which made us return back to
    8.1.7 driver:
    UnitOfWork(7818028)--Connection(4434104)--INSERT INTO STATUSHISTORY (CHANGEDATE, FK_SET_STATUS_ID) VALUES ({ts '2002-10-17 16:46:54.529'}, 2)
    INTERNAL EXCEPTION STACK:
    java.sql.SQLException: ORA-00904: invalid column name
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093
    at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.jav
    a:2047)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java
    :1940)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatemen
    t.java:2709)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePrepare
    dStatement.java:589)
    at TOPLink.Private.DatabaseAccess.DatabaseAccessor.executeDirectNoSelect(
    DatabaseAccessor.java:906)
    at TOPLink.Private.DatabaseAccess.DatabaseAccessor.executeNoSelect(Databa
    seAccessor.java:960)
    at TOPLink.Private.DatabaseAccess.DatabaseAccessor.executeCall(DatabaseAc
    cessor.java:819)
    at TOPLink.Public.PublicInterface.UnitOfWork.executeCall(UnitOfWork.java:

    Hello Yury,
    I believe the problem is that TopLink's ServerSession by default executes read queries concurrently on the same connection. It does this to reduce the number of required connections for the read connection pool. Normally this is a good concurrency optimization, however some JDBC drivers have issues when this is done. I had thought that with Oracle JDBC 8.1.7 this issue no longer occurred, but perhaps it is only after version 9. I believe that the errors were only with the thin JDBC driver, not the OCI, so using the OCI driver should also resolve the problem. Using RAW instead of BLOB would also work.
    You can configure TopLink to resolve this problem through using exclusive read connection pooling.
    Example:
    serverSession.useExclusiveReadConnectionPool(int minNumerOfConnections, int maxNumerOfConnections);
    This will ensure that TopLink does not to try to concurrently execute read queries on the same connection.
    I'm not exactly sure what your second problem with the 9.x JDBC drivers is. From the SQL and stack trace it would seem that the driver does not like the JDBC timestamp syntax. You can have TopLink print timestamp in Oracle's native SQL format to resolve this problem.
    Example:
    serverSessoin.getLogin().useNativeSQL();
    Make sure you configure your server session before you login, or if using the TopLink Session Manager perform the customizations through a SessionEventListener-preLogin event.

  • Show photoes using blob field in Oracle DB

    When create Crystal report using Blob field in Oracle 10g DB, the photoes are tif format stored in blod and there are multipages for every record. However in the Crystal Report,it just show the first page of the photo.
    Are there some ways to display all the pages? Or is it necessary to programming using java or .net to display?

    Not capable. CR will only show the first picture and not an album.

  • Problem inserting a gif into a blob field in a table with sqldev / forms6i

    Problem solved - For those that might be interested, the errors don't make much sense - the problem was with the gif. Seems that these 28 gifs plus the new scans were saved from the scanner with
    GIF - LZW, Transparent color: 255
    Converting them to Black and white allowed them to be loaded.
    If anyone understands why, I'd like to know
    glenn
    I was previously having a problem deleting a row with a blob and it was suggested that I create the table using rowdependencies - which I did as follows.
    CREATE TABLE "MDD"."MDD_FIGURE2"
    (     "FG_FIGURENAME" VARCHAR2(18 BYTE),
         "FG_FIGURE" BLOB,
         CONSTRAINT "FG_FIGURENAME_NN" CHECK ("FG_FIGURENAME" IS NOT NULL) ENABLE
    ) ROWDEPENDENCIES;
    Then I copied my data from my previous table with the following - and everything came across
    INSERT INTO MDD_FIGURE2 (fg_figurename, fg_figure)
    SELECT FIG_FIGNAME, FIG_FIGURE FROM MDD_FIGURE;
    mdd_figure2 was then renamed to mdd_figure
    The table, Mdd_Figure, already contains some 2000+ .gifs that were successfully loaded with Forms 6i (yes, I know it is old, but I am stuck with having to use it). All the .gifs I am loading are from scans and all are less than 64k. However, 28 .gifs would not load. When I insert the .gif into the field and committed the form, the status message tells me a record was written but when I check it, the blob is empty.
    So, when I try to insert one of these problem .gifs in SqlDeveloper, I open the new mdd_figure table, select the blob field, open the edit dialog, set it to figure, select the .gif that I want to load and then save it. The blob field changes from NULL to BLOB, but it is empty. When I try to commit, I get the following error from SqlDev.
    UPDATE "MDD"."MDD_FIGURE" SET WHERE ROWID = 'AAAOeWAAEAAABAlAAz' AND ORA_ROWSCN = '358136842'
    One error saving changes to table "MDD"."MDD_FIGURE":
    Row 14: ORA-01410: invalid ROWID
    I use rollback to restore the record to it's previous state.
    If I load one of the successfully loaded .gifs into the same field, it loads perfectly as follows.
    UPDATE "MDD"."MDD_FIGURE" SET WHERE ROWID = 'AAAOeWAAEAAABAoAAp' AND ORA_ROWSCN = '358136522'
    Commit Successful
    It appears the 28 gifs have a problem. I've re-scanned them, with the same results. They are just small scanned line map images from our earlier publications. They view properly in several different graphics programs and I can't find anything wrong with them.
    I notice that the ROWID's are different while the ORA_ROWSCN's are the same - but what is the significance of that?
    Any suggestions as to what is happening and what I can do about it?
    Thanks for any help you can give me.
    glenn
    (Database is 10R2 and sqldev is the most recent one)
    Edited by: gconley on Sep 25, 2008 9:51 PM

    solved it myself - problem was with the gif

  • Uploading a JPG File into a Blob problem

    Hi everyone
    I'm using Forms10G
    Oracle Databse 11G
    Right now I'm uploading JPGs images into a blob column using webutil which is implemented in the app. But something weird happen. It seems the file is using more space that it would. For example: I just upload an 800Kb image, and when I try to download it the size is like 1.12Mb (I'm using Reports10g to accomplish this, converting the image to a PDF file) and even the size in the DB is bigger too.
    Is this normal?
    Hope you could help me!
    Thank you!

    If you upload a file using webutil_filetransfer, the blob in the database should have the same size as the file on the client. If you generate a pdf including the image, the pdf-filesize will likely be different as pdf stores images in a different way.

  • Access BLOB field in Oracle database

    Dear Sir,
    I am using Pro* C to access oracle blob fields
    I write "12345" to Oracle Blob field, when I read it it is fine.
    I then modify this record to "ABC", when I read it, I get "ABC45",
    How can I set blob field to the initial state to modify BLOB field correctly ?
    Many Thanks
    Liang

    Initially you write 12345 and when you modify you are modiyfing only 3 bytes from offset 1 and hence the results. When you modify oracle will not erase the complete lob you need to use erase before you modify (write)
    Following doc give you an insight into pl/sql lob functions
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_lob.htm#sthref4428
    Following is the Pro*C Lobs Guide
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28427/pc_16lob.htm#i998068

  • Problem with Pro*C reading BLOB field from Oracle 10g

    Hello Experts,
    We have a Pro*c application which is reading the BLOB data fields (a PNG image file) from Oracle data base. It holds the BLOB fields returned from the SQL query into a Unsigned Char structure in Pro*C. The program used work fine on AIX 32 – bit 4.3 and Oracle 8.1 environment.
    Recently, we have upgraded the environment to AIX 64-bit 5.3 and Oracle 10g.Since after the Pro*c program has problem in reading the Blob filed.
    Below is the query we are trying to execute –
    EXEC SQL
    SELECT
    signtre_image, image_file_name_ext
    INTO
    :msipLocalImage INDICATOR :msipLocalImage_i,
    :file_name_ext INDICATOR :file_name_ext_i
    FROM
    dcs_sign
    WHERE
    signtre_nbr = :signtre_nbr;
    Here signtre_image is the BLOB fields and msipLocalImage is a Pro*C structure define as below –
    typedef struct tagSignImage
    long len; /* Image length */
    unsigned char img[1]; /* Pointer to first byte. */
    } MOTS_SIGN_IMAGE;
    The quesry does not give any error or exception message in the Pro*C , program just stops at the point of executing the quesry..When we run the query commenting the BLOB filed it works fine. Also, the query runs good when we run it in the Oracle editor.
    There seems to be problem with the way we are reading the BLOB field in the new Oracle 10g enviromet.
    Does any body have any idea what’s wrong with this query? We really need it to work.
    Any Help will be greatly appreciated.
    Thanks,
    - Rajan Yadav

    Thanks a ton for your response.
    We made the necessary changes as suggested by you.This time we got another flavour of error - SQL Error Code - Inconsistent error while reading BLOB.
    Another thing we noticed is that the data field which we are trying to read is defined as LONG RAW instead of a BLOB in data base.
    Are these two things related in any sense or is there anything else which is causing the error.
    Once again Thanks for your help.
    - Rajan Yadav

  • Problem building a trigger using a BLOB field in Oracle 10

    My case is the following,
    I'm trying to implement an AFTER trigger which uses the :new.blob_field to insert the new value in a table. Because of the documented AFTER restriction and :new use for blob fields, I've though to add other BEFORE trigger that calls a procedure in which I can store the :new value and later insert the temporary value in the table when the AFTER trigger is executed.
    The Idea is the following:
    BEFORE trigger :new -> TEMP
    and then
    AFTER trigger uses TEMP to store in the new table
    So, the final questions are the following:
    -Any other idea to do the same, that is, to use the ":new" value in an AFTER trigger?
    -How can I do this with the temp variable, is this correct?:
    PROCEDURE store_blob ( new_val BLOB ) IS
    BEGIN
    DBMS_LOB.CREATETEMPORARY(new_blob_temp,TRUE, DBMS_LOB.SESSION);
    -- fill with data
    DBMS_LOB.COPY (new_blob_temp,new_val,DBMS_LOB.GETLENGTH(new_val),1,1);
    END store_blob ;
    Because of the design of the application I have to use the AFTER trigger to store the new value so I must find a solution for this type of fields.
    Sorry for the size of the text and also for my english.
    Thanks in advance

    SQL> create or replace trigger trg1 after insert on test_blob for each row
      2  begin
      3  insert into test_blob2 values (:new.a);
      4  end;
      5  /
    Trigger created.
    SQL> insert into test_blob values ('123456789');
    1 row created.
    SQL> desc test_blob;
    Name                                      Null?    Type
    A                                                  BLOB
    SQL> desc test_blob2
    Name                                      Null?    Type
    A                                                  BLOB
    SQL>
    SQL> select dbms_lob.getlength(a) from  test_blob2;
    DBMS_LOB.GETLENGTH(A)
                        5

  • How can i store image into blob field in oracle express ??

    Hi
    am using oracle express *(2.1)* , i am devloping a small system , we have to store an image in blob filed in a table, we have to create a form which allow the user to store the image in the table and to generate a report contains the image
    any note's please
    tahnk's in advance
    sam
    Edited by: user485341 on Dec 22, 2008 1:28 AM

    hi Andy
    this is the code for download
    create or replace PROCEDURE download_my_file(p_file in number) AS
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(2000);
    Lob_loc BLOB;
    BEGIN
    SELECT MIME_TYPE, BLOB_CONTENT, FILE_NAME,DBMS_LOB.GETLENGTH(BLOB_CONTENT)
    INTO v_mime,lob_loc,v_file_name,v_length
    FROM A_IMAGES
    WHERE IMAGE_ID = p_file;
    owa_util.mime_header( nvl(v_mime,'application/octet'),FALSE );
    -- set the size so the browser knows how much to download
    htp.p('Content-length: ' || v_length);
    -- the filename will be used by the browser if the users does a save as
    htp.p('Content-Disposition: attachment;
    filename="'||replace(replace(substr(v_file_name,instr(v_file_name,'/')+1)
    ,chr(10),null),chr(13),null)|| '"');
    -- close the headers
    owa_util.http_header_close;
    -- download the BLOB
    wpg_docload.download_file( Lob_loc );
    end download_my_file;
    thank's

  • Is it possible to upload a xls file into an application and store in table.

    Hello,
    I just want to know whether its possible to upload a xls file into application in Oracle 10g .
    i.e. have a separate xls file stored in computer then in the application just have a browse button to upload that xls file and that data should be inserted into a new table.
    Thanks

    Good morning,
    You can upload the .XLS file into a BLOB field in a table and then download that back to the local PC. Look in the APEX Advanced Tutorial for "Create an Upload Item", Page 9-3 (PDF Page: 109). There it will explain how to upload to a BLOB and then how to download that again.
    Don.
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone! :)

  • Upload Attachements(Doc File) into SAPand Read The same in BADI

    Hi All,
    I am Nagesh, and presently working on a BADI(NOTIF_EVENT_POST) for sending emails when a new Notification is created through QM01 Transaction Code, and its working very very fine. But now an additional requirement has come up, where i need to upload an Standard Format Word Document into SAP and then attach this file to the Mail to which the converted PDF Smartform file has been attached and then send both files in single mail to concerned Vendor. So I tried to upload the .Doc file into SAP by using OAER TCode with following Parameters
    Class name              :            PICTURES
    Class type               :            OT
    Object key               :            CAPA.
    I exactly dont know whether this is the right format or not, please help me, if this is possible or not.
    And also I uploaded the same doc file from application server to Presentation Server using Tcode CG3Z, to a ditectory which exists in SAP (Checked in AL11 Tcode). So the nhow to read that complete file to send the same as attachemnts without making any changes .
    Regards,
    Nagesh Kumar.
    Edited by: Nagesh Kumar on Mar 12, 2010 9:39 AM
    Edited by: Nagesh Kumar on Mar 12, 2010 11:32 AM

    Hi All,
    I am Nagesh, and presently working on a BADI(NOTIF_EVENT_POST) for sending emails when a new Notification is created through QM01 Transaction Code, and its working very very fine. But now an additional requirement has come up, where i need to upload an Standard Format Word Document into SAP and then attach this file to the Mail to which the converted PDF Smartform file has been attached and then send both files in single mail to concerned Vendor. So I tried to upload the .Doc file into SAP by using OAER TCode with following Parameters
    Class name              :            PICTURES
    Class type               :            OT
    Object key               :            CAPA.
    I exactly dont know whether this is the right format or not, please help me, if this is possible or not.
    And also I uploaded the same doc file from application server to Presentation Server using Tcode CG3Z, to a ditectory which exists in SAP (Checked in AL11 Tcode). So the nhow to read that complete file to send the same as attachemnts without making any changes .
    Regards,
    Nagesh Kumar.
    Edited by: Nagesh Kumar on Mar 12, 2010 9:39 AM
    Edited by: Nagesh Kumar on Mar 12, 2010 11:32 AM

  • Inserting Image into BLOB field from URL

    Is it possible to insert an image into a BLOB field from a URL? I don't have access to the filesystem on the server and I have a page that uses PL/PDF to generate dynamic PDF files from data I pull from the database. I would like to include my companies official header with logo on the top of the PDFs I generate and need to somehow get the image which I currently have uploaded to the images section in Application Express and can access from the "Shared Components => Images" section of the Application Builder. I just want to be able to either query whatever table holds those images or copy the image I need to a blob field in one of my tables so I can use it in my PDF document.
    The other alternative (which is what I first mentioned above) would be to try and perform an insert into the BLOB field in my table but the location of the image file would be like "http://www.myportal.com:7777/pls/htmldb/wwv_flow_file_mgr.get_file?p_security_group_id=1234567&p_flow_id=111&p_fname=myimage.jpg".
    Is this possible? If not, what can I do?
    Thanks in advance.

    The reason why I am asking this question in this forum is two-fold:
    1. I am using Application Express (AE).
    2. Since I am using AE all images that I upload to my workspace are stored in a table in a database and not as an actual file in a directory structure like in Windows etc. This being the case, I can't ever reference any of the files that I upload to my workspace in order to insert them into my BLOB field unless I know their physical location on disk (which of course does not exist b/c they are stored in the AE database somewhere). If I knew AE's database and table structure I could do a "select into ..." from whatever table stores my uploaded images and save those images to my own custom table in my BLOB field.

  • How to upload size 4k file to oracle BLOB field

    hi all, i'm using Oracle 9i, Orcale JDBC thin Driver and ibm websphere to develop a java application.i have used java EJB/CMP to insert images into BLOB field in oracle.
    i used byte[] mapping to BLOB.i did it successfully.
    however, i'm facing another problem. it is that
    when i insert files larger than 4k, there is exception error. it said that the inserted value is too large.
    is that the problem of orcale JDBC?
    is that any solution to solve this restriction?
    it is very urgent, pls help!
    thx a lot

    Hi Lee
    Thanks for ur valuable suggestions. Please give me
    more idea i would really thank to u !Which part is giving you troubles?
    Oh - and change my suggestion to use setBinaryStream to a suggestion to use setAsciiStream, as I missed the part where you said "text file".
    >
    Can anybody tell me anyother way how to solv thid
    problem
    Depending on the size of the text file you could just read the file so you have the contents as a String and use setString (also in the PreparedStatement interface).
    hanks
    Message was edited by:
    MerlinRosina

  • How can upload doc file into database !!

    Dear Everyone,
    How can i upload a doc file into Mysql database ....
    can any one please give ur suggestions...
    i will show u my code
    upload.jsp
    <form name="uploader" action="uploaded.jsp"
    enctype="multipart/form-data">
      <div align="center">
      <table id="table1" border="1" bordercolor="#ff0000"
    cellpadding="0" cellspacing="0" width="50%">
        <tbody bgcolor="#c8d8f8">
          <tr>
            <td bgcolor="#ccccff">
            <p align="center">
               Resume Upload! </p>
            </td>
          </tr>
          <tr>
            <td> 
            <p align="center">You can upload your
    resume.. </p>
            <p align="center">
            <table align="center" border="1"
    cellpadding="10" cellspacing="10">
              <tbody>
                <tr>
                  <td>
                  <p><input name="file" type="file">
                  <input name="uploadButton" value="Upload"
    type="submit"></p>
                  </td>
                </tr>
              </tbody>
            </table>
            </p>
            </td>
          </tr>
        </tbody>
      </table>
      </div>
    </form>
    uploaded.jsp
    <BODY>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.util.*" %>
    <%@ page import="java.io.*" %>
    <% 
        String file1=request.getParameter("file");
        int len;
        String query;
        PreparedStatement pstmt;
       int i=0;
        Class.forName("com.mysql.jdbc.Driver");
    DriverManager.getConnection("jdbc:mysql://localhost:3306    Connection conn= /employee","root","");
         try {
                File file = new File(file1);
                   if (file==null)
    %>
    <center>Nothing in It</center>
    <%
                else
                FileInputStream fis = new FileInputStream(file);
                len = (int)file.length();
                query = ("insert into loader(resume) VALUES(?)");
                pstmt = conn.prepareStatement(query);
                pstmt.setString(1,file.getName());
                pstmt.setInt(2, len);
                //method to insert a stream of bytes
                pstmt.setBinaryStream(3, fis, len);
              i=pstmt.executeUpdate();
                   if(pstmt!=null)
                 pstmt.close();
                if(conn!=null)
                 conn.close();
            } catch (Exception e) {
                e.printStackTrace();
                 if(i>0)
                        out.println("uploaded");
                    else
                        out.println("not uploaded")
    %>
    </BODY>

    File file = new File("myDoc.doc");
    FileInputStream fis = new FileInputStream(file);The file name will most likely NOT be hard-coded. I don't think the question surrounding this topic is how to do the insert statement (he/she clearly knows SQL).
    HTTP and the web browser take care of the file transfer, but the server stores the file in a temporary location. The question is, "How do I found out that location?" In PHP (I know that doesn't offer much help to you, but ...), that location is held in a variable called $_FILES. From there you can simply copy the file to a location you specify (probably with a user-specified name under a directory specifically for that user).
    I hope this is of some help:
    http://www.oop-reserch.com/mime_example_4.html
    Good Luck,
    C. R.

  • Problem inserting Stream or ByteArray into Blob field.

    Hello,
    I am attempting to insert a file that has been converted into a byte array and also an input stream. When the file is less than 50kb it does successfully get inserted into the Blob field. When it is larger, it fails with the following stack trace:
    06/12/07 10:20:57 java.sql.SQLException: Invalid argument(s) in call
    06/12/07 10:20:57 at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    06/12/07 10:20:57 at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    06/12/07 10:20:57 at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
    06/12/07 10:20:57 at oracle.jdbc.dbaccess.DBItem.setArrayData(DBItem.java:270)
    06/12/07 10:20:57 at oracle.jdbc.dbaccess.DBItem.setArrayData(DBItem.java:246)
    06/12/07 10:20:57 at oracle.jdbc.dbaccess.DBDataSetImpl.setBytesBindItem(DBDataSetImpl.java:2484)
    06/12/07 10:20:57 at oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:1219)
    06/12/07 10:20:57 at oracle.jdbc.driver.OraclePreparedStatement.setBytes(OraclePreparedStatement.java:2307)
    06/12/07 10:20:57 at com.evermind.sql.PreparedStatementBCELProxy.setBytes(PreparedStatementBCELProxy.java:201)
    06/12/07 10:20:57 at mil.dla.finance.issueTracker.AbstractIssueTrackerAction.insertNewIssueItem(AbstractIssueTrackerAction.java:265)
    06/12/07 10:20:57 at mil.dla.finance.issueTracker.WriteIssueAction.execute(WriteIssueAction.java:181)
    06/12/07 10:20:57 at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    06/12/07 10:20:57 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    06/12/07 10:20:57 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    06/12/07 10:20:57 at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    06/12/07 10:20:57 at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    06/12/07 10:20:57 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    06/12/07 10:20:57 at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
    06/12/07 10:20:57 at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
    06/12/07 10:20:57 at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
    06/12/07 10:20:57 at mil.dla.finance.common.filters.UserAuthFilter.doFilter(UserAuthFilter.java:201)
    06/12/07 10:20:57 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:645)
    06/12/07 10:20:57 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
    06/12/07 10:20:57 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
    06/12/07 10:20:57 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
    06/12/07 10:20:57 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
    06/12/07 10:20:57 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    06/12/07 10:20:57 at java.lang.Thread.run(Thread.java:534)
    Any assistance would be greatly appreciated.

    I thought I had found the answer here: http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/lob/LobToSP.html
    I adapted the Clob code to a Blob:
    private BLOB getBLOB( byte[] array)
    throws Exception {
    BLOB b = null;
    try {
    // create a new temporary BLOB
    b = BLOB.createTemporary( conn, true, BLOB.DURATION_SESSION );
    // Open the temporary BLOBin readwrite mode to enable writing
    b.open( BLOB.MODE_READWRITE );
    b.setBytes(array);
    // Get the output stream to write
    } catch ( Exception exp ) {
         // Free BLOB object
    b.freeTemporary( );
    // do something
    return b;
    however, it appears that the BLOB being returned is null, and when sent to the DB, nothing is actually written. So any help/suggestions would be greatly appreciated.
    Message was edited by:
    SFBell09

Maybe you are looking for

  • Report for PO price

    Hi I am looking for a report or a simulation transaction that will give me the PO price for a material (including freight etc). Is there a report or a simulation for this? Sincerely Anders

  • Posting Video in Dreamweaver MX 2004

    Hey all! I currently host a website for a local football team and I have been loading video highlights of each weeks games. I currently have been using a free converter that I downloaded but have been noticing that the longer and more effects I add t

  • Error in create a new application

    Hello, i want create a new hyperion application (V11.1.1.3), so I Log on to Workspace, and select Navigate > Administer > Application Library >  I have this error message : There was some communication error. Response is : http://ahmedhoumame:19000/a

  • Border radius & flash video player issue

    Border radius & flash issue - PFA screenshot http://72.29.76.194/~designs/firefox-flash-border-radius/border-radius-flash-firefox.png When I overlay a div with a border radius over a flash object, the corners are being cut as much as the size of bord

  • Oracle OA Framwork Personalizations - Filtering values in LOV

    The launch journal wizard screen gives us a pick list to choose an ADI template from. Our list of values have 3 templates for Actuals journals and 3 for Budgets. Our requirement is that the Business Analyst responsibility should only see Budget templ