exception in getting the blob into byte]

HY guys,.
I have a problem with my java application.
I use hibernate to interact with a derby database.
I've stored an image into the blob field (and not a problem).
When I try to get the blob into byte array that I have this exception:
java.sql.SQLException: You cannot invoke other java.sql.Clob/java.sql.Blob methods after calling the free() method or after the Blob/Clob's transaction has been committed or rolled back.
To get the BLOB I made
Blob cThumnb = ((Allegato) cAllegati.get(i)).getThumb();
byte[] cPrev = toByteArray(cThumnb);
where
private byte[] toByteArray(Blob fromBlob) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            return toByteArrayImpl(fromBlob, baos);
        }
        catch (SQLException e)
        {
            throw new RuntimeException(e);
        }
        catch (IOException e)
        {
            throw new RuntimeException(e);
        }
        finally
        {
            if (baos != null)
            {
                try
                {
                    baos.close();
                }
                catch (IOException ex)
                {
                }
            }
        }
    }

    private byte[] toByteArrayImpl(Blob fromBlob, ByteArrayOutputStream baos)  throws SQLException, IOException
    {
        byte[] buf = new byte[4000];
        
        InputStream is = fromBlob.getBinaryStream();
        try
        {
            for (;;)
            {
                int dataSize = is.read(buf);
                if (dataSize == -1)     break;
                baos.write(buf, 0, dataSize);
            }
        }
        catch(IOException ex)
        {
                throw ex;
        }
        
       finally
        {
            if (is != null)
            {
                try
                {
                    is.close();
                }
                catch (IOException ex)
                {
                }
            }
        }
                return  buf;// baos.toByteArray();
    }
Could you help me?
I define also autocommit to false.
Thank you
Concerning

java.sql.SQLException: you can't call other methods of java.sql.Clob/java.sql.Blob after the free() method is called or after the transaction of the Blob/Clob object has been committed or rolled back.

So invoke it before calling the free() method or until the transaction has been committed or canceled?

And why the blob in an array of bytes to all? The idea of blobs is you don't know what size they are and how you treat the content as a stream.

Tags: Java

Similar Questions

  • script to get the flow of bytes of the PDF file

    Hello

    Y at - it a script that can get the stream of bytes to the current PDF document?

    I use a PDF form in offline mode in the application. At the click of a button, a process of LC is invoked via webservice allows you to store the PDF file to the server. Y at - it a script by which the doc PDF itself could be converted into a bytestream and then sent to the Web service so that the PDF file can be rebuilt it?

    Thank you

    Muniyaraj

    You call a LiveCycle orchestration? If Yes, then you would define a string as an input parameter (make sure you so there is no time limit). Then when you call the function, the string contains the content encoded in base64 in your PDF. You must enter this in a document variable so in a setValue operation you can assign it to a VAR of document using this function:

    getDocFromBase64

    (java.lang.String)

    Paul

  • How can I get the dll into the GAC on web servers (Win2008 R2/IIS 7) that don't have GACUTIL on them?

    I followed the steps described in KB911816, but I can't make it work.

    Two questions:

    How can I get the dll into the GAC on web servers (Win2008 R2/IIS 7) that don't have GACUTIL on them?

    Where should I put the reference to the dll in Web.config?

    OT:

    KB911816

    Hi Mike,.

    Refer to:

    https://TechNet.Microsoft.com/en-us/library/gg607836 (v = ws.10) .aspx

    https://msdn.Microsoft.com/en-us/library/ee265628%28V=BTS.10%29.aspx?f=255&MSPPError=-2147217396

    Please post your question here for improving assistance:

    https://social.technet.Microsoft.com/forums/WindowsServer/en-us/home?category=WindowsServer

  • Interrupted exception in getting the location?

    Hello..

    My application is running in the background that gets the location by gps and cellsite... It shows me interrupted exception when I run the application... How can I start the two wires together? is there a way... How to handle this exception?

    I added a while loop on it in the thread who sleep for 3 minutes and it works even if the condition is true for cellsite and it works when I run both when I run one of them...

    but know not at the moment... I don't know the exception management as well... I just called wire cellsite except thread so gps location when gps does not provide the place or has expired at this time, it executes the cellsite thread... I do not know may be it can cause any problem after...

  • Get the Blob of DB object

    I'm going to Blob object in the database in a particular table

    I want to get this BLOB in my c:/NewFolder

    For Ex: I'm going to test.pdf in a xx table I want to reach c:/NewFolder using some sql or stored procedure or function

    How do I achieve this functionality

    So, you don't have permission to UTL_FILE. Ask your DBA (OR if you have the privilege) of GRANT EXECUTE ON UTL_FILE TO your_user.

  • How to get the byte Array of image cascading?

    Hello

    I need help to get the array of bytes to the image.

    In fact, I have developed image processing application so I need.

    Thank you.

    Please ask a feature against Blackberry 10 (BBTEN) in the Issue Tracker: http://supportforums.blackberry.com/t5/Java-Development/Developer-Issue-Tracker/td-p/271768

    Stuart

  • Trying to get ending entry into force for the groups of lines

    Hello world

    I searched the forums, but I can't find a post that is a problem quite like that.

    I have some data that looks like this:
            ID_NUM     EFFECTIVE ALLOC_PERCENT   ACCT
    ---------- --------- -------------   ----
           101 01-JUL-11            21   A1
           101 01-JUL-11            72   A2
           101 01-JUL-11             7   A3
    
           101 01-JUL-12            20   B1
           101 01-JUL-12            80   B2
    
           101 01-JAN-13            20   A1
           101 01-JAN-13            20   A2
           101 01-JAN-13            50   A3
           101 01-JAN-13            10   B1
    
           101 01-JUN-13            50   A1
           101 01-JUN-13            50   A2
    (note: I inserted manually empty lines for clarity)

    Here's the logic: the lines represent an assignment of percentage on the account for the identification number specified for this entry into force. A new date to cancel the previous, and if any line in the conceptual group is replaced, so they are all.

    I'll try to find the date when the effective period of each group ended and which includes in the game so that I can calculate then the number of days in a given line has been effective; something like that;
      ID_NUM     EFFECTIVE END_DATE   ALLOC_PERCENT ACCT
    ---------- --------- ---------- ------------- ----
           101 01-JUL-11 01-JUL-12             21 A1
           101 01-JUL-11 01-JUL-12             72 A2
           101 01-JUL-11 01-JUL-12              7 A3
    
           101 01-JUL-12 01-JAN-13             20 B1
           101 01-JUL-12 01-JAN-13             80 B2
    
           101 01-JAN-13 01-JUN-13             20 A1
           101 01-JAN-13 01-JUN-13             20 A2
           101 01-JAN-13 01-JUN-13             50 A3
           101 01-JAN-13 01-JUN-13             10 B1
    
           101 01-JUN-13 <null>                50 A1
           101 01-JUN-13 <null>                50 A2
    The end_date of the group is the EFFECTIVE_DATE of the next group (ordered by ID_NUM, EFFECTIVE_DATE).

    End_date of two rows is zero because there is no group of lines with an effective date the later - in my process, I'll NVL which sysdate so that my calculations of days will be valid.

    I tried some analytical queries with LEAD, but I couldn't figure out how to get the next date of the efficient group. I could get the entry into force of the next row, but not the next group. I couldn't specify how many lead lines to look forward, because there is not a number of rows in each group.

    How to fill the end_date column?

    Here's the code to create the above.
    create table t
    (id_num number,
     effective_date date,
     alloc_percent number,
     acct_code varchar2(4)
     );
    
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jul-2011',21.0,'A1');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jul-2011',72.0,'A2'); 
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jul-2011',7.0,'A3');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jul-2012',20.0,'B1');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jul-2012',80.0,'B2');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jan-2013',20.0,'A1');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jan-2013',20.0,'A2');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jan-2013',50.0,'A3');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jan-2013',10.0,'B1');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jun-2013',50.0,'A1');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jun-2013',50.0,'A2');
    
    commit;
    
    select * from t;
    Oracle version information:
    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    "CORE 11.2.0.3.0 Production."
    AMT for Solaris: 11.2.0.3.0 - Production Version
    NLSRTL Version 11.2.0.3.0 - Production


    Thank you very much

    Hello

    Here is one more way to do using lead work.

    WITH ds as (id_num, effective_Date, lead (effective_date) select on end_date (id_num order, effective_Date))

    t

    Id_num group, effective_date)

    Select t.*, ds.end_date

    DS, t

    where t.effective_Date = ds.effective_Date;

  • Get the network traffic in bytes

    I try to get the number of bytes to pass by the network interface.

    The code I use is:

    String [] interfaceList = this.proxy.getNetInterfaceList ();
    a long time in = 0L;
    long out = 0L;

    for (String inteface: interfaceList) {}
    log. Debug (inteface);
    NetInterfaceStat netsstat = this.proxy.getNetInterfaceStat (inteface);
    in += netsstat.getRxBytes ();
    on += netsstat.getTxBytes ();
    }

    I'm not sure that I do it well, because the figures are not updated often. For example, I download a movie from youTube and the number does not change. I have to wait 30 seconds before it changes. Is the resolution of a minimum amount of time (on Windows 2000 Pro) is 30 seconds?

    Hi James,

    I saw this.proxy in your code, guess that is an instance of SigarProxyCache?  This class is a wrapper for caching the values returned by the underlying class of Sigar, 30 seconds by default.  You can change this value by default, but it seems you'd be better of just using the new Sigar() straight-up instead of the ProxyCache.

  • Another problem in the BLOB view

    Hi all

    I have a problem in the image display on the screen. Here's my situation: I have an Oracle table, consists of string, CLOB and BLOB. I also have a web application using JSP and Servlet. My Blackberry application will access the servlet to get the data in my table. Returns an XML file, not a file JSP, servlet, then my Blackberry application will read this file, it displays on the screen. I use not BrowserField.

    My problem is... How can I display the image?

    I have tried to convert byteArray BLOB, and then again to convert to a string, inserting it into my XML. In my Blackberry app, get the string and convert it to byteArray and then use

    Bitmap.createBitmapFromBytes to get the Bitmap image. But it gives me nothing.

    Can someone help me?

    Thank you much in advance.

    Kind regards

    Novan Ananda

    I offer two General options:

    1 generate and send an image url to the XML format. Request per second to get the bytes of the images to the server. Server can presave the image in a temp folder or get the blob of the DB directly.

    2 send the image data as xml encoded in base64. Decode the device and view EncodedImage.

    I prefer the method if you send pictures not only in response. Can see the context for your asynchronous image download information.

    Thank you

    Eugen

  • Write the blob value in a file

    Hi all


    I'm looking on the correct method of writing a blob value to a file. I know the best way to use an external language. For example, Java or C. But also, I met a number of solutions to do within pl/SQL block. All of them look like this:


    CREATE OR REPLACE PROCEDURE Write_Binary_file
    (
    PC$ Directory IN VARCHAR2
    , PC$ file_name IN VARCHAR2
    , PC$ SQL_Order IN VARCHAR2
    , PB$ Raise IN DEFAULT BOOLEAN FALSE
    )
    -- -------------------------------------------
    -Procedure to empty a BLOB column in a file
    -- -------------------------------------------
    -settings:
    -PC$ Directory: name of an existing directory of Oracle
    -PC$ file_name: name of the file output expected
    -PC$ SQL_Order: SQL command to select the BLOB column
    -PB$ Raise: boolean to indicate if the process
    -would be stopped after an error
    --
    IS
    src_lob BLOB;
    RAW buffer (16384).
    AMT directory: = 16384;
    INTEGER POS: = 1;
    LF$ FicOUT UTL_FILE. TYPE_DE_FICHIER;
    LC$ Msg VARCHAR2 (2000);
    BEGIN

    -get the BLOB column-
    BEGIN
    EXECUTE IMMEDIATE PC$ SQL_Order IN src_lob;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    LC$ Msg: = ' Write_Binary_File(): NO_DATA_FOUND';
    If PB$ increase THEN
    RAISE_APPLICATION_ERROR (-20100, LC$ Msg);
    END IF;
    Dbms_Output.put_line(LC$MSG);
    RETURN;
    END;

    -Open the output file-
    LF$ FicOUT: = UTL_FILE. FOPEN (Directory$ PC, PC$ filename, 'W', 32764);

    -write the file-
    LOOP
    -play songs-
    Dbms_Lob.read (src_lob, amt, pos, buffer);
    -write the songs-
    Utl_File.Put_Raw (LF$ FicOut, buffer);
    POS: = pos + amt;
    END LOOP;
    -Close the file-
    Utl_File.fclose(LF$FicOut);

    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    UTL_FILE.fclose(LF$FicOut);
    WHILE OTHERS THEN
    LC$ Msg: = ' error Write_Binary_File(): ' | TO_CHAR (SQLCODE) | "everything by managing the file (')"
    || PC$ Directory | ') ' || PC$ file_name;
    If PB$ increase THEN
    RAISE_APPLICATION_ERROR (-20100, LC$ Msg);
    END IF;
    Dbms_Output.put_line(LC$MSG);
    END Write_Binary_file;
    /


    But this code doesn't seem to work. The problem is that it always creates a slightly bigger than an initial file. So copy jpg will never be opened with any viewer.

    Can someone explain this problem and give no work around?

    Thank you

    Hello

    If I look at this procedure, I think that you forget to check if the last part, it takes to read is less than 32000. Now you put the always full buffer to the desired quantity. The last part, you only need to read from the BLOB what remains, nothing more. By reading more, get your blob of larger than expected.

    I use the package lie on this page for several years and no complains: http://www.adp-gmbh.ch/blog/2005/november/20.html

    Herald tiomela
    http://htendam.WordPress.com

  • I try to restore my ipod, but it wants me to enter the password on the ipod but my ipod is disabled, ive even put the ipod into recovery mode

    Im trying to restore my i Pod but 5th generation. I put my ipod into recovery mode, but when I try to restore it, it asks me to enter the password on my ipod but I can't because the id ipod disabled.

    People with disabilities
    Place the device into Recovery Mode iOS
    https://support.Apple.com/en-us/HT201263
    and then connect you to your computer and restore via iTunes. The iPod will be erased.
    If you have forgotten the password for your iPhone, iPad or iPod touch, or your device is disabled
    https://support.Apple.com/en-us/HT204306
    If the recovery mode does not work, try the DFU mode.
    How to put iPod touch / iPhone in DFU "Karthik doodles."
    https://geekindisguise.WordPress.com/2009/07/16/how-to-put-iPod-touch-iPhone-int o - dfu mode.

    To learn how to restore:
    Use iTunes to restore your iPhone, iPad or iPod to factory settings
    https://support.Apple.com/en-us/HT201252
    To restore backup see:
    Restore your device from an iCloud or iTunes backup - Apple Support
    https://support.Apple.com/en-us/HT204184
    If you restore from a backup of iCloud apps will be automatically downloaded. If you restore from backup iTunes, applications and music must be in iTunes since synchronized as music media library and apps are not included in the backup of the iOS device what iTunes does.
    You can re-download most of iTunes purchases by:
    Download after purchase from the App Store and iTunes Store iBookstore
    https://support.Apple.com/en-us/HT201272

    If no problem what happens or doesn't happen, and when in the instructions? When you get the iPod into recovery successfully mode and connect to iTunes on the computer should say that it found an iPod in recovery mode.

  • Can someone show me how to get the data of this vi in four columns in a spreadsheet file.

    I'm trying to get the data into four columns on a worksheet. The data consists of two channels and two measures, a maximum voltage and a voltage after x seconds. I enclose the code. Any help would be great. Thank you.


  • How to show the BLOB (file pdf, image) as pop up when you click on a link

    Hi all

    I have a requirement that, when, clicks on a commandlink in a page, I need to show the BLOB (pdf, image in my case) in the pop-up window.

    I am therefore able to get the BLOB when link clicks on command.

    Please help me on this aspect, how can I show this BLOB in pdf or image format in the pop-up window

    Thank you very much

    Krishna

    Hello

    Have you seen this? https://technology.AMIS.nl/2011/07/28/ADF-11g-show-PDF-in-a-popup/

    Concerning

  • Get the multi path-

    I found this code. Is there a way I can get the results into an Excel instead of just the screen?

    Get-VMHost | %{$_.Name; $_ | Get-ScsiLun | Select CanonicalName, MultiPathPolicy}

    And even better, since I will connect to an instance of vCenter4, I really need information of two of our clusters.  Cluster names are ProductionCluster8 and ProductionCluster9

    Thank you!

    I fixed that in the script in my first post. Now he has to work and only to retrieve information about the two groups.

  • I get the following message when I login: "Processing Message c0000013 parameters 75b6bf7c 75b6bf7c Exception".___Also, cannot install Adobe Falsh Player.

    I get the following message when I login: "treatment of Message of Exception c0000013 parameters 75b6bf7c 75b6bf7c".  I hit Cancel and it appears 2-3 times more, I hit cancel each time.

    I have Windows XP Media Center Edition Version 2002.  I just loaded Service pack 3 as well as a few other updates.

    Not sure if it's related, but thought I would mention it since others have mentioned the USB port.  Since I got this computer, I always had two cords into the USB port on the back of my PC.  When I want to synchronize my PDA photos or uplaod to my camera, I'll use these two cords pluggeed in my USBs.  What is the problem?  Too bad, it was working before SP3.

    Also (probably unrelated), I had problems with Adobe Falsh Player.  I'm trying to install an update and get always frozen.  The system is configured to add not Add-Ins/Active-Xs without authorization by me, but it crashes whenever I try to give him permission.  Is this related to the updates?  After the problems started, I uninstalled Adobe Flash and it worked, but the relocation has not yet.  (Many applications use this and it's VERY frustrating!)

    Any suggestions would be helpful!  Thank you...

    Hi Mearth,

    Thanks for posting. These issues occurred right after that you have loaded the SP3? Also when you say that you sign on, do you mean log in your computer?

    I hope this helps! Let us know some information so that we can your problems solved! Shawn - Support Engineer - MCP, MCDST
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

Maybe you are looking for

  • Time Capsule loses connectivity

    I read several threads about people having problems with their wifi and their Time Capsule.  Son as: Problem WiFi fall on Time Capsule However, my problem seems to be just a little different and I was wondering if anyone had any ideas on what is the

  • Even after the installation of the fingerprint scanner Scan fingerprint driver does not work

    I have hp pavilion dv6 7012tx and she was pre installed with windows 7, but now I have installed in windows 8 and my fingerprint reader does not work. I have installed finger print driver but its still does not, please help me. Thank you!!!

  • 6510 all-in-one does not print in black

    Hello So my off-warranty 6510 has started to not print in black. I bought this in August 2012, and it has been pretty reliable. Now it just won't print black. I searched through these forums and I feel like a big community now - I'm not alone with th

  • Printer F4580 all-in-one: 10 Windows

    After you have installed windows 10, printer will not print.  All the printer software and drivers installed successfully.   Everything goes well until I hit print and then I get the error message "unable to print".

  • G2 250 HP (F0Z00EA) laptop 32 bit Windows 7

    Please I need help with my G2 to 250 HP for laptop (F0Z00EA) 32-bit, there is no USB controllers. I tried to download from other sites, but I'm afraid because I don't trust them! Help, please