IMAGEIO IS WORKING BUT BYTEARRAY IS NOT WORKING:

Hi all
I am getting images from gmail contacts and trying to store it in DB
using my http code:InputStream is=urlconnection.getInputStream();
i could able to store the inputstream in file using:
BufferedImage filebuffer=ImageIO.read(is);
FileOutputStream fos=new FileOutputStream("picturerecent.jpg");
ImageIO.write(filebuffer, "jpg", fos);
but i was trying to store it in DB using the following code but it is not working.i am having a question that
how it writing to a file without any problem.why not to database:
try {
       String url = "jdbc:mysql://localhost:3306/";
         String db = "test";
         String driver = "com.mysql.jdbc.Driver";
                Class.forName(driver);
                con = DriverManager.getConnection(url+db,"root","");
                try{
PreparedStatement psmnt;
     psmnt = con.prepareStatement("insert into gmailphoto(id,Photo) "+ "values(?,?)");
     psmnt.setInt(1, 9);
     psmnt.setObject(2, is, java.sql.Types.BLOB);
     int s = psmnt.executeUpdate();
       Statement st = con.createStatement();
    try{
        ResultSet rs=st.executeQuery("select photo from gmailphoto where id=9");
        if(rs.next())
          {     //byte[] bytearray = new byte[4096];
              int size=0;
            File sImage;
//FIRST TRY
            FileWriter wr=new FileWriter(new File("c:\\imageOutput.jpg"));
            IOUtils.copy(rs.getBlob("photo").getBinaryStream(),wr);
            //SECOND TRY
            BufferedImage bf=ImageIO.read(new ByteArrayInputStream(rs.getBytes("photo")));
            FileOutputStream fout=new FileOutputStream(new File("C:\\imageOut"));
            if(bf!=null)ImageIO.write(bf, "jpg", fout);
            if(wr!=null)
            wr.flush();
            wr.close();
          rs.close();
       }}catch(SQLException e){
            System.out.println(e);
       }Thanks a lot for help

but i was trying to store it in DB using the following codeThere is no code here that writes to a database. There are two lots of code that write to a file.

Similar Messages

  • I installed Firefox today but it will not open and the icon on the taskbar will not close and I cannot uninstall it and the helper app does not work either?

    I have tried everything that I know to uninstall the new version of Firefox. I also installed Aurora beta and it had the same behavior and I was able to uninstall that. I cannot open a ff browser to work on it using much of your support information. I click on icon but it does not start on the desktop but task manager shows it as running. I have to end task in task manager to close it. I can't uninstall it and have tried system restore but that also doesn't work because of another issue with my antivirus program.

    If this is on a Windows computer, check this Microsoft link;
    '''''[http://support.microsoft.com/mats/Program_Install_and_Uninstall Fix problems that programs cannot be installed or uninstalled]'''''

  • HT1689 I can reach the iTunes Store from my iPod Touch, but it will not open on my PC running Windows 7.  Message shows that iTunes has stopped working.  This happens every time.  I have updated iTunes Software.  Will not solve the problem.  What is wrong

    I have uninstalled iTunes several times and reinstalled it on my PC running Window 7 with all updated loaded.  When I click on the iTunes Store Box, Nothing happens except for a message that reads:
              iTunes has stopped working.
    The following items give me a choice, but no answer comes up.  The computer will shut down the website.
              "Check online for a solution and close the program"
              "Close the program."
    There is an item below the box that is selectable for View problem details.  When clicked a long list of items show up.  I have listed some of the problems as written, but I do not understand them.  I know the iTunes Store has been available on earlier versions of of iTunes but is not on this version.  How can we go back and download an earlier version of iTunes?
         Here are some of the Problem Details:
         "Problem signature:  APPCRASH
         Application Name:     iTunes.exe
         Application Version:  11.0.1.12
         Application Timestamp:  50c8fc7e"

    I had this exact same problem.  I found this fix and it worked for me. 
    Step 1:
    Browse to C:\Program Files (x86)\Common Files\Apple\Apple Application Support and copy the filen named QTMovieWin.dll. 
    Step 2:
    Browse and past that file into C:\Program Files (x86)\iTunes.
    Hope this helps you.  I wish I could remember where I saw this originally so I could thank them.
    Good Luck.
    Anthony

  • Podcast downloads fine, but Subscribe is not working

    My feed validates, is showing up in the iTunes store and I can download individual episodes without problem. Yet when I click the "Subscribe" button, it does not work. The name of the podcast shows up in the Podcasts section of my iTunes, but it does not download any episodes. And when new episodes are posted, those don't download either. Other people who I've talked to who have tried subscribing to my podcast are having the same problem. I've checked all my iTunes settings, and everything seems to be in good order, as I'm having no difficulty subscribing to other podcasts.
    Feed is located here: http://www.natefernald.com/butttalk/buttfeed.xml
    Any advice would be greatly appreciated - I'm stumped!
    Thanks.

    You have introduced a fatal error into your feed: at the moment the Store will be showing a cached version but iTunes cannot read it and so subscribing does not work.
    Several episodes have this:
    <itunes:summary>Adam & Nate talk with Best Week Ever's Nick Turner....
    The ampersand ('&') wrecks the feed because in XML it signifies the beginning of a code sequence which is never finished - this invalidates the rest of the feed including the closing tags, so that invalidates the opening tags and the entire feed becomes unreadable.
    You need to search for every instance of this and replace it either with the word 'and' or with this code:
    &amp;
    I would suggest using the 'and' as being more gramatically correct and less fuss unless you are particularly keen on the ampersand.

  • My iPhone safair says it cannot open because it is not connected to the internet.  What do I do? I do not believe I changed any settings.  I have turned the phone off but this did not work.

    Safari cannot open because the iPhone is not connected to internet.  I do not believe I have changed any settings.  I have turned off the phone and then on, but this did not work.  Help?

    For Safari to work, you need either Wi-Fi or cellular data.
    Are you connected to a Wi-Fi hotspot?
    If not is Settings > Mobile/Cellular > Mobile/Cellular Data: ON

  • I get this error when I go to imovie, I have instalerat on via appstore, but it does not work. The QuickTime components necessary to view, edit, import and export various types of films are not installed. The components included in the iMovie installer. R

    I get this error when I go to imovie, I have instalerat on via appstore, but it does not work.
    The QuickTime components necessary to view, edit, import and export varioustypes of films are not installed. The components included in the iMovie installer.Reinstalling iMovie.

    I get this error when I go to imovie, I have instalerat on via appstore, but it does not work.
    The QuickTime components necessary to view, edit, import and export varioustypes of films are not installed. The components included in the iMovie installer.Reinstalling iMovie.

  • I bought this iPhone from Apple Retail Store for the full amount, but  it does not work with my SIM card only works with AT&T

    Hello,
    I have an iPhone 4S 32Gb White AT&T, product part No. MC921LL/A, Serial No. C39GMLPWDTDC
    I bought this iPhone from Apple Retail Store (from Fifth Avenue, NY) for the full amount. Now it does not work with my SIM card only works with AT&T. I restored the phone several times, but I have not received "Congratulations your iPhone has been unlocked". Please activate my iPhone to work with different SIM cards
    Thanks,
    Best Wishes

    When did you buy it?
    Apple did not begin selling an unlocked version of the iPhone 4S in the US until 11/11/11. I believe it went on sale only through the online store at that time. I'm not sure if it's available at retail yet.
    What you purchased was a phone without a contract commitment. It is still locked to AT&T. AT&T will NOT unlock iPhones for any reason.  Return it and get your money back, then use that to purchase an unlocked phone.

  • I cannot access the internet, I tried to answer that said to go to settings, safari, tap clear history, cookies and cache, cut off, then on, but it did not work.  When I go to internet the screen is grey??? please help I am a new user!!

    I cannot access the internet the screen is grey, I have tried by using the answer from someone but it does not work...I went to settings, tap safari, then clear the history, cookies, and cache, then turn off ipad.  When I did that twice, it did not work.  How long does it take for the clear history to work?  I am a brand new
    user of the ipad2 and I am disappointed that this is happening already.

    Have you been able to access the internet previously and now it's suddenly not working, or are you still trying to access the internet for the first time on your iPad?  Are you at home trying to connect through your home router?  If you are at home, did you put your home routers encryption code as your password?  The encryption code is what your iPad is looking for and it is usually found on the router and is typically a 13 digit combination of letters and numbers.  Let us know......

  • Is it possible to  downgrade ios 6 to 5.1.1(i upgrade my iphone 4s from 5.1.1 to 6 but map is not working )

    is it possible to  downgrade ios 6 to 5.1.1(i upgrade my iphone 4s from 5.1.1 to 6 but map is not working )

    best answer to your question I've ever seen is;
    Kappy Tampa, FL and Vancouver, BC
    Re: Downgrading     Oct 16, 2012 2:57 PM    (in response to nbabbit2013) 
    I'm sorry, but Apple does not provide a downgrade path for iOS. Because downgrading is unsupported by Apple we cannot discuss it on these forums, but you can use Google to find information on how to install an older version of iOS on any iDevice.

  • HT4108 I'm trying to connect my iPad to my tv so that I can mirror whatever is on my iPad. I want to stream movies online and watch on the tv. I have the digital av adapter and an hdmi cable but it's not working. Any tips ?

    I'm trying to connect my iPad to my tv so that I can mirror whatever is on my iPad. I want to stream movies online and watch on the tv. I have the digital av adapter and an hdmi cable but it's not working. Any tips ?

    If this is an iPad 1, it won't mirror, but it will still output video from the 30 Pin dock connector.
    If your new TV has a conventional VGA in and stereo inputs you can try this connector.
    http://store.apple.com/us/product/MC748ZM/A/apple-composite-av-cable?fnode=3a
    I used to stream video from both Netflix and YouTube and from my Mac using iTunes sharing through my iPad then with this connector plug into my iPad and TV.
    It won't be high resolution, but it will get you picture from iPad to TV.
    Good Luck.

  • I have a macbook 13"screen purchased in 2007; I want to hook it up to my HDTV; I purchased a mini display port to hdmi adaptor but it does not fit.   what kind of adaptor will work for this model?

    I have a Macbook, 13" screen, purchased in 2007.    I want to hook it up to my HDTV; I purchased a mini display port to hdmi adapter but it does not fit.   Any suggestions?

    If you connect yourMacBook using a MiniDVI/HDMI adapter you will need to use external speakers for audio since the pre-2010 MacBooks will only send video through the MiniDVI or MiniDisplay Port . The MiniDVI/HDMI doesn't carry audio and there's no audio plugs on the TV to work with HDMI since it's expecting audio with the HDMI.
    If your TV has a DVI input plug you can use a MiniDisplayPort/DVI adapter. Then a DVI cable to the DVI input plug on the TV. The TV will have RCA audio plugs for use with the DVI. Plus DVI gives a sharper image than HDMI.

  • Greetings, I am working in Final Cut Pro 7. In the timeline some clips show as offline. I tried going to sequence and reconnecting to media but it does not work. I can still see the video in the timeline and work with it. It just has the red box.

    Greetings, I am working in Final Cut Pro 7. In the timeline some clips show as offline. I tried going to sequence and reconnecting to media but it does not work. I can still see the video in the timeline and work with it. It just has the red box. Thanks! Olga

    If the clips are not actually missing, you could try to refresh the timeline by using cmd-0 and then going to the timeline options tab. Then select name only where it says "thumbnail display". Press ok to accept the change, then repeat the process to add thumbnails back to your timeline.

  • " help me please"  I have Windows 7 installed on my mac pro and Bought Mini DisplayPort to VGA Adapter to connect to lcd tv But it does not work? why? please help me

    " help me please"  I have Windows 7  32 bit installed on my mac pro and Bought Mini DisplayPort to VGA Adapter to connect to lcd tv But it does not work? why? please help me
    I have to boot with a Windows
    When I use the Mac operating system not have a problem  and DisplayPort to VGA Adapter Working properly
    why does not work with windows ?
    What should I do؟
    I'm grateful to give advice
    tanks
    [email protected]

    Someone in another section answered this. Thanks.

  • My ipad mini is not syncing music onto in, my ipad has been replaced to see whether the issue is to do with the ipad but its still not working. i have a a windows PC please help thanks

    my ipad mini is not syncing music onto in, my ipad has been replaced to see whether the issue is to do with the ipad but its still not working.
    ive tried everything and ive been to the store which was when i was given a new ipad mini. i have a a windows PC please help thanks

    Are you attempting to sync music from your iTunes Music Library on your PC?
    What options do you have set on the Music Tab for your iPad in iTunes?
    What happens when you sync?
    Any error messages?

  • Macbook pro to HDTV, video is working but audio is not working, how to make audio work as well

    Macbook pro to HDTV, video is working but audio is not working, how to make audio work as well

    If you use an HDMI cable, the audiostream will be integrated, so there will be sound when using an HDMI cable!
    Not necessarily.  That only works as stated if you have one of the most recent MBP's that has a built-in HDMI port.
    If the MBP only has a Thunderbolt or miniDisplayPort, you need an appropriate adapter cable and even if you use an HDMI adapter or cable to connect to your HDTV there is no guarantee it will carry audio.  You have to determine if your specific MBP model supports audio out through its miniDisplayPort or Thunderbolt output, and whether the adapter does likewise.

Maybe you are looking for

  • Unable to release OPM Batch in R12

    Hi gurus, We are implementing R12 OPM and using the shared version of unconstrained ASCP planning. We are not able to release OPM batch planned orders to OPM execution. The profile Auto Implement planning suggestion to APS is set as No and ran the "A

  • Anyconnect secure mobility and windows 8.1 problem

    I installed the anyconnect secure mobility client 3.1.05152 version on a couple o windows 8.1 workstations on my home network. There are no restrictions from my firewall towards the outside world. When i try to connect for the first time i get the ce

  • BT Sport on Sky

    Forgive me if this has been asked before, but is it still possible to get BT Sport for free if the BT Infinity package is in my name but the Sky viewing card/subscription is in my partners name at the same address? Any help with this would be appreci

  • Deleted files from USB Disk attached to Airport Extreme

    I deleted files from a USB disk attached to my airport extreme.  I then needed to recover them  but they are not in the trash can...how can I find and restore these files?  I have not emptied the trash.  I am just looking in the trash in my bar at th

  • Data Retrieval Speed in Oracle Spatial vs. ESRI ArcSDE

    I would appreciate any opinions regarding data retrieval performance between Oracle Spatial and ESRI ArcSDE. Would an end- user (using ESRI software) experience significant differences in data retrieval speed depending on how the data were stored in