Loading class file stored in BLOB field

- I am able to store and retrieve Java files and XML files in and from a BLOB field, but when I store a class file and try and load it using Class Loader, it us unable to load the class. The size of the class file increases by 1 byte when I retrieve it from the database. Is this some security feature by the JVM? Is it not possible to store, retrieve and load a class file from a database table?
Thanks
Harini

Hi,
First, I would suggest you use fiddler (http://www.telerik.com/fiddler) to compare these two different client requests, second, please try to use Azure Storage Explorer (http://azurestorageexplorer.codeplex.com/) to do
this instead of the Azure Web Storage Explorer. 
Best Regards,
Jambor
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • Storing a file in a BLOB field in the database through forms

    Hi, I want to have a form that lets the user choose a file he has on his client side and load this file into a BLOB field in the database.
    I know how to use "GET_FILE_NAME" to get the file, the second part is what I'm having problems with. Do I use an OLE object? How do I initailize it? Or what is the best way to go? Thanks.
    --Bassem                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Are you looking for something like this?
    DECLARE
       l_temp  clob;
       l_text  varchar2(2000);
    BEGIN
        l_temp := httpuritype('http://www.oracle.com/PO.xsd').getclob;
        l_text := substr(l_temp, 1, 2000);
        dbms_output.put_line(l_text);
    END;N.B.: Not Tested...
    Regards.
    Satyaki De.

  • RETRIEVE OF ETXT FILE STORED IN BLOB

    Hi,
    I have a question on utl file. I wrote some text in an utl file (text file) and stored it as blob in data base at back end while my team mate has to retrieve the data stored in blob in front end using java. when he retrieves, the file which i stored as blob is retrieved as html file not as text file i stored initially . when we retrieve a file stored as blob, how a blob file will be retrieved..is it depends on front end programmer or is there any format where a file stored as blob will be retrieved only on that format? Kindly give your expertise on this question

    As Billy said, the passing through correct mime type is the only reliable way. If you have already loaded tons of blobs without providing this information, you may try a small workaround to determine the right mime type for your files by emulating the file utility behaviour in the database - you have to load the /etc/mime-magic or something similar for your os into the database and then compare certain bytes of your lobs with those recorded in the mime-magic file. An example how it can be done is here
    http://articles.techrepublic.com.com/5100-9592_11-5219073.html
    You could so complete the missing information in the database without to unload your data , but you should be aware - this can not replace the need to provide right mime type information by loading into database.
    Best regards
    Maxim

  • Loading .class files for reflection

    I'm trying to write a program that lets the user select thier .class files to gather
    information about those classes with reflection.
    I can't figure out how to get ClassLoader to load .class files outside the program
    directory.

    I've tried both these options, and spent some time on it too,
    but failed. If can't find a class that can load clases form a URL
    how can I write my own ClassLoader that does it.
    The ClassLoaders all seem to assume that they already know where
    to look for the class files. Perhaps if I could tell them where to look,
    but I don't see how.

  • Finding loaded Class file from particular Jar

    Hi,
    I have multiple jars containing same class file.
    How can I find out that the loaded Class file belongs to particular jar?
    Thanks
    madan

    In most cases it's possible with ProtectionDomain and CodeSource:ProtectionDomain pd = YourClass.class.getProtectionDomain();
    CodeSource cs = pd.getCodeSource();
    if (cs != null) {
        System.out.println("It came from " + cd.getLocation());
    } else {
        System.out.println("Location unknown.");
    }For further information see
    [url http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#getProtectionDomain()]http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#getProtectionDomain()
    http://java.sun.com/j2se/1.4.2/docs/api/java/security/ProtectionDomain.html
    http://java.sun.com/j2se/1.4.2/docs/api/java/security/CodeSource.html

  • Error displaying a jpg file loaded into a table with blob field

    This may not be the correct forum for this question, but if it isn't could someone direct me to the correct one.
    I have created a table with a blob field in which I have loaded a jpg image. This appeared to work correctly, but when I try to display the image in internet explorer it comes back and tells me that it doesn't recognize the file type. Enclosed is the table create, load, and display pl/sql code. Can anyone tell me what I am doing wrong. Thanks. For the mime/header I used owa_util.mime_header('images/jpg') because my image is a jpg file.
    The database is 10g
    -- Create table
    create table PHOTOS
    IMAGEID NUMBER(10),
    IMAGE BLOB,
    IMAGE_NAME VARCHAR2(50)
    load image
    CREATE OR REPLACE PROCEDURE load_file ( p_id number, p_photo_name in varchar2) IS
    src_file BFILE;
    dst_file BLOB;
    lgh_file BINARY_INTEGER;
    BEGIN
    src_file := bfilename('SNAPUNCH', p_photo_name);
    -- insert a NULL record to lock
    INSERT INTO photos (imageid, image_name, image)
    VALUES (p_id , p_photo_name, EMPTY_BLOB())
    RETURNING image INTO dst_file;
    -- lock record
    SELECT image
    INTO dst_file
    FROM photos
    WHERE imageid = p_id AND image_name = p_photo_name
    FOR UPDATE;
    -- open the file
    dbms_lob.fileopen(src_file, dbms_lob.file_readonly);
    -- determine length
    lgh_file := dbms_lob.getlength(src_file);
    -- read the file
    dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
    -- update the blob field
    UPDATE photos
    SET image = dst_file
    WHERE imageid = p_id
    AND image_name = p_photo_name;
    -- close file
    dbms_lob.fileclose(src_file);
    END load_file;
    display image
    PROCEDURE display_image(p_id NUMBER) IS
    Photo BLOB;
    v_amt NUMBER DEFAULT 4096;
    v_off NUMBER DEFAULT 1;
    v_raw RAW(4096);
    BEGIN
    -- Get the blob image
    SELECT image
    INTO Photo
    FROM PHOTOS
    WHERE IMAGEID = p_id;
    owa_util.mime_header('images/jpg');
    BEGIN
    LOOP
    -- Read the BLOB
    dbms_lob.READ(Photo, v_amt, v_off, v_raw);
    -- Display image
    htp.prn(utl_raw.cast_to_varchar2(v_raw));
    v_off := v_off + v_amt;
    v_amt := 4096;
    END LOOP;
    dbms_lob.CLOSE(Photo);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    END;
    END;
    The url I enter is: http://webdev:7777/tisinfo/tis.tiss0011.Display_Image?p_id=1

    Just a little more information. When I enter owa_util.mime_header('image/jpeg') I can't display the file. It just shows up with a red x for the file.
    When I enter owa_util.mime_header('image/jpg') it displays the file, but in the format
    ¿¿¿¿JFIF¿¿-Intel(R) JPEG Library, version [2.0.16.48]¿¿C
    This is the way I would expect it to look if I opened it with Notepad, or an application that doesn't recognize jpg files. Can anyone tell me what I am doing wrong?? Thanks.

  • Diaplay  Word file stored in blob into a browser using JSP

    Dear All
    I have files stored in oracle table in a blob field.I store the files using forms 10g and webutil. I can upload the files and display them successfully in forms, however when i use JSP to retrieve the files and display them in Internet Explorer, I'm able to display the pdf files, bmp , jpg and video but I'm getting junk characters when I try displaying (word , excel , access or powerpoint files which might contain arabic Characters )
    the code I use to display the files is as follows :
    <%
    try
    Connection conn = null;
    String username=session.getAttribute("username").toString().toUpperCase();
    String password=session.getAttribute("password").toString().toUpperCase();
    String ip = "*****************";
    String sid = "***************";
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conn = DriverManager.getConnection("jdbc:oracle:thin:@"+ip+":1521:"+sid,username,password);
    String par = request.getParameter("LETTER");
    String par1 = request.getParameter("SERIAL");
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select * from TableName where PK1 like '"+par+"'"+" and PK2 like '"+par1+"'" );
    if (rs.next())
    Blob pic = null;
    byte[] blobBytesArray = null;
    OutputStream stream = response.getOutputStream();
    pic = rs.getBlob("BLOBFIELD");
    int len = new Integer( new Long( pic.length()).toString() ).intValue();
    blobBytesArray = pic.getBytes(1,len);
    if (blobBytesArray != null)
    if (blobBytesArray.length > 0 )
    stream.write(blobBytesArray) ;
    catch(Exception e)
    System.out.println("Exception: " + e.getMessage() + "<BR>");
    %>
    can you please guide me of how to display other file types.
    Best Regards.

    Hello,
    Ideally when you store the document put the content-type in a column and set the content type in your JSP. This will indicate to the browser what is the type of file and you should not have any issue with any type.
    Regards
    Tugdual Grall

  • How to store file content in BLOB field MySql database using java

    Hi!
    i want to store the file content in a BLOB field in MySql database using java.
    Please help me out..........
    thanx in advance...
    bye

    i stored images in db, and retrieved them. like that cant i store pdf file in db, and retrieve it back using oracle db?
    Plz help me out how to put a file in db. i need complete code. thanks in advance.

  • Downloading a file from Database [Blob field]

    I am trying to write an application which can upload and download files [Excel, Word etc.] to/from an Oracle 9i database Blob field. I am using Java/JSP for the same.
    The upload part works just fine. However, when I try to download the file that I uploaded, I get an error.
    A dialog box comes up asking me to Open/Save the file. However, when I try to save it, it says
    �Internet Explorer cannot download �..tion=download&planId= testplan from localhost
    Internet Explorer was not able to open this Internet Site. The requested site is either unavailable or cannot be found. Please try again later.�
    I am using IE 6.0. I tested the same with Firefox browser and was able to download the file.
    Can anyone help?
    Code:
    Following is the code I am using for the same.
    /* Code to retrieve from Blob field */
    String sqlString = "SELECT PLAN_DOCUMENT_NAME,PLAN_DOCUMENT FROM BRS_PLAN_DESCRIPTION WHERE PLAN_ID = ?";
    ps = con.prepareStatement(sqlString);
    ps.setString (1,planId);
    rs = ps.executeQuery();
    while (rs.next()) {
         fileBytes = rs.getBytes("PLAN_DOCUMENT");
         fileName = rs.getString("PLAN_DOCUMENT_NAME");
    brsPlanDocument.setPlanId(planId);
    brsPlanDocument.setFileName(fileName);
    brsPlanDocument.setFileBytes(fileBytes);
    /* Code for download */
    String fileName = brsPlanDocument.getFileName();
    String fileType = fileName.substring(fileName.indexOf(".")+1,fileName.length());
    if (fileType.trim().equalsIgnoreCase("txt"))
         response.setContentType( "text/plain" );
    else if (fileType.trim().equalsIgnoreCase("doc"))
         response.setContentType( "application/msword" );
    else if (fileType.trim().equalsIgnoreCase("xls"))
         response.setContentType( "application/vnd.ms-excel" );
    else if (fileType.trim().equalsIgnoreCase("pdf"))
         response.setContentType( "application/pdf" );
    else if (fileType.trim().equalsIgnoreCase("ppt"))
         response.setContentType( "application/ppt" );
    else
         response.setContentType( "application/octet-stream" );
    response.setHeader("Content-Disposition","attachment; filename=\""+fileName+"\"");
    response.setHeader("cache-control", "no-cache");
    byte[] fileBytes=brsPlanDocument.getFileBytes();
    ServletOutputStream outs = response.getOutputStream();
    outs.write(fileBytes);
    outs.flush();
    outs.close();

    Hi,
    is this problem solved for you, I am also writing the java code to store different files in blob fields in database(db2udb) and allow users to open them through jsp pages. Upload seems to be working fine.....My big problem is only excel files are opened properly in both IE and Firefox. Word files, image files are not getting opened. Any suggestion as what I could be doing wrong....my jsp is kind of similar to the above one...
    thanks in advace, please guide me
    long pmsId = new Long(request.getParameter("pmsId")).longValue();
    String fileName = request.getParameter("fileName");
    int fileSeq = new Integer(request.getParameter("fileSeq")).intValue();
    if(fileName.endsWith("txt")) {
    response.setContentType("text/plain");
    log.debug(" this is a text file");
    } else if(fileName.endsWith("xls")) {
    response.setContentType("application/vnd.ms-excel");
    log.debug(" this is a excel file");
    } else if(fileName.endsWith("gif")) {
    response.setContentType("image/gif");
    log.debug(" this is a image file");
    } else if(fileName.endsWith("doc")) {
    response.setContentType("application/msword");
    log.debug(" this is a doc file");
    } else if(fileName.endsWith("pdf")) {
    response.setContentType("application/pdf");
    log.debug(" this is a pdf file");
    } else if(fileName.endsWith("ppt")) {
    response.setContentType("application/ppt");
    log.debug(" this is a ppt file");
    } else {
    response.setContentType("application/everythingelse");     
    log.debug(" this is a unknown ile");
    response.setHeader("Content-Disposition", "attachment;filename="+fileName);
    OutputStream out1 = response.getOutputStream();
    Class.forName("com.ibm.db2.jcc.DB2Driver");
    db2Conn = DriverManager.getConnection("jdbc:db2:TESTDB","db2admin","db2fv1000");
    //log.debug("connection obtained");
    pstmt = db2Conn.prepareStatement(" SELECT * FROM UPLOADDOCS WHERE PMSID = ? AND DOCSEQ = ? ");
    //log.debug("statemenmt prepared");
    pstmt.setLong(1, pmsId);
    pstmt.setInt(2, fileSeq);
    rs = pstmt.executeQuery();
    int count = 0;
    if(rs.next()){
    InputStream is = rs.getBinaryStream("DOCUMENT"); //"is" is
    //now the binary data
    //of the file
    byte[] buf = new byte[4096];
    int len;
    while ((len = is.read(buf)) > 0)
         out1.write(buf, 0, len);
    out1.close();
    out1.flush();

  • How to retrieve the data stored in BLOB field in MySql using java?

    Hi all!
    i stored a file content into the MySql database in BLOB field.
    and i now want retrieve the data......
    Please help me out in doing the task...........
    Thanx...........

    Thrisha..
    When u get a result set u can have rs.getBlob() function that will give u a BLOB object that can be captured using Blob interface of javax.sql package...
    Blob interface has getBinaryStream, getBytes etc as functions...
    i think i cleared u
    regards
    Shanu

  • Tomcat6 does not load class files from WEB-INF/lib/myjarfile.jar  WHY???

    I have placed my jar file in c:\tomcat6\webapps\my-application\WEB-INF\lib\myjarfile.jar
    But, after restarting tomcat6, when i try to import the class file contained in the myjarfile.jar in a servlet, it says
    ProcessFileUpload.java:4: package test.test1 does not exist
    import test.test1.*;
    ^It clearly tomcat's class loading problem.
    As i unzipped my jar and placed the packagefolder structure to
    c:\tomcat6\webapps\my-application\WEB-INF\classes\testand it works perfectly.
    Anyone knows its workaround? please suggest if any configuration changes is required in tomcat or so.
    Thanks.
    ---Sujoy

    Thank you gimbal2 . There was error in creating the jar file myjarfile.jar.
    But, now I have created it again and placed it in place
    c:\tomcat6\webapps\my-application\WEB-INF\lib\myjarfile.jarand tried to use one on the Class file included within the jar to compile my servlet. But, still I am getting error at servlet compilation time. I want to place executable jar files in
    c:\tomcat6\webapps\my-application\WEB-INF\lib\myjarfile.jar and compile my servlet and execute the servlet.
    I DO NOT WANT TO unzip the jar, placing all unzipped files to
    c:\tomcat6\webapps\my-application\WEB-INF\classes\ folder and comiple my servlet and execute the servlet. But, I am failing to user WEB-INF\lib\ folder facility....please help me why i am not getting class files from WEB-INF\lib\ folder.
    If you please see the small code bit and tell me any possible error that would be very helpful.
    Step 1: my library java file MyClass.java
    package test.test1;
    public class MyClass {
         String myName = "Default return string value";
         public void setMyName(String varName) {
              this.myName = varName;
         public String getMyName() {
              return this.myName;
    }Step2 : Creating jar file of my library class files
    C:\jdk1.6\bin>jar cvf myjarfile.jar test
    added manifest
    adding: test/(in = 0) (out= 0)(stored 0%)
    adding: test/test1/(in = 0) (out= 0)(stored 0%)
    adding: test/test1/MyClass.class(in = 452) (out= 296)(deflated 34%)
    adding: test/test1/MyClass.java(in = 230) (out= 140)(deflated 39%)
    C:\jdk1.6\bin>Step3 : Double checking the created jar file content by listing its content
    C:\jdk1.6\bin>jar tf myjarfile.jar
    META-INF/
    META-INF/MANIFEST.MF
    test/
    test/test1/
    test/test1/MyClass.class
    test/test1/MyClass.java
    C:\jdk1.6\bin>Step4 : Placed myjarfile.jar to
    c:\tomcat6\webapps\my-application\WEB-INF\lib\Step5 : Restarted standalone Tomcat6 in my Windows XP SP2.
    Step6 : Created a simple servlet LibFolderTest.java within my-application\WEB-INF\classes\ folder with code
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import test.test1.*;
    public class LibFolderTest extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              MyClass mc = new MyClass();
              out.println(mc.getMyName());
    }Step7 : Tried to compile my servlet LibFolderTest.java and got the following error
    LibFolderTest.java:4: package test.test1 does not exist
    import test.test1.*;
    ^
    LibFolderTest.java:11: cannot find symbol
    symbol  : class MyClass
    location: class LibFolderTest
                    MyClass mc = new MyClass();
                    ^
    LibFolderTest.java:11: cannot find symbol
    symbol  : class MyClass
    location: class LibFolderTest
                    MyClass mc = new MyClass();
                                     ^
    3 errorsThe above servlet compilation error on Step7 is telling me that myjarfile.jar is not loaded by Tomcat6 or not available for use when compiling servlet. I want to use myjarfile.jar from within WEB-INF\lib\ folder but I can not. please help.
    ---Sujoy

  • Plz help load class files

    hai forum,
    Plz help me out regarding this trouble.
    I have extracted class files of a jar file into a local directory D:\myClass.
    Now i need to access these class files.I loaded the path D:\myClass using URL ClassLoader.
                                  File file = new File("D:myClass");               
                          URL url = file.toURL();         
                          URL[] urls = new URL[]{url};
                          ClassLoader cl = new URLClassLoader(urls);
                          Class c = cl.loadClass(classname);The rest of the code is for listing the methods of the class file.But the class file is not getting loaded and thus the methods are not listed.
    Has it got anything to do with the way i have extracted and stored the class files?
    Plz help me identify my mistake.
    Thank you.

    Hi, I will borrow this thread to discuss my problem with loading a class file.
    How do you use the class when you have loaded it?
    I'm using this code:
    File file = new File("C:\\Foo\\Foo.class");
    URL url = file.toURL();
    URL[] urls = new URL[]url;
    ClassLoader cl = new URLClassLoader(urls);
    Class c = cl.loadClass(cl.getClass().getName());
    Object o = c.newInstance(); <-- This can't be done, my applet just stops and starts to wait or something. I don't get any exception or anything.
    The class Foo.class has a constructor that's prints some text and a function that can print some other text. Is it possible to call that function in some way?

  • How to load externl files (PDF) into BLOB column.  Please help.

    Hi All,
    I've currently been working on loading many external binary files (PDF) into BLOB column. After some digging, I learn that the SQL*LOADER can be used to load data from external files into table. I also got help from another forummate mentioning to use PL/SQL procedure to do so. Since I have not done anything like this before. So, my question is what is the simple approach needed to upload PDF files into a table(there is only one table containing BLOB column in my database). In addition, the LOBs can not be query-able, I wanted to list the contents of the LOBs column to make sure that I did successfully upload data into the database. How can I do that?. I do need your help. Please direct me step by step how to do so. Your help is greatly appreciated.
    Regards,
    Trang

    Hi,
    If the following link helps to you then great.
    http://www.exefind.com/oralobeditor-P25468.html
    Regards,
    Sailaja

  • 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

  • SQL-Loader Control file for Tab-delimited fields

    i want to import a text-file with TAB-DELIMITED fields and a line-break + return at the end of each record.
    a want to do this by sql-loader and a control file.
    please, can someone give me the statement:
    e.g.
    load data
    infile 'exaple.txt' .......
    (...field1, field2,....)
    thank you very much

    Case Study 3: Loading a Delimited, Free-Format File
    http://otn.oracle.com/pls/db92/db92.to_URL?urlname=http:%2F%2Fdownload-west.oracle.com%2Fdocs%2Fcd%2FB10501_01%2Fserver.920%2Fa96652%2Fch10.htm%231006907
    Modify the example and use 'terminated by whitespace' instead
    For more information on TERMINATED Fields see
    http://otn.oracle.com/pls/db92/db92.to_URL?remark=drilldown&urlname=http:%2F%2Fdownload-west.oracle.com%2Fdocs%2Fcd%2FB10501_01%2Fserver.920%2Fa96652%2Fch06.htm%231013838

Maybe you are looking for