Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java Databases
|
Java Databases Discussion specific to working with Java Databases. For other Java topics, please see related Java forums. For database discussions not specific to Java, please see the Database category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 25th, 2005, 03:34 PM
Registered User
 
Join Date: Jul 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cannot upload a whole images

Hi all
I'm coding jsp to upload the images into the blob (mysql database). Everything seems good except one thing that I cannot upload the completed images into database. I can upload images with no error but when I try to retrieve it back out browser, I've just got part of images to be displayed. below is my code. Thanks in advance

DiskFileUpload Upload = new DiskFileUpload();
Upload.setSizeMax(-1);
List items = Upload.parseRequest(request);
Iterator it = items.iterator();
while (it.hasNext()) {
    FileItem fi = (FileItem)it.next();
    if(!(fi.isFormField())) {
        PreparedStatement pstmt = conn.prepareStatement("INSERT INTO fswar0090 (files, filesize) VALUES( ?, ?)" );
        try {
            pstmt.setBinaryStream(1, fi.getInputStream(), (int)fi.getSize());
            pstmt.setInt( 2, (int)fi.getSize() );
            pstmt.executeUpdate();
            pstmt.close();
        }
        catch (Exception e) {
            out.println("error:" + e.getMessage());
        }
    }
}

 
Old July 25th, 2005, 03:46 PM
Registered User
 
Join Date: Jul 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I forgot to let you guys know this. My problem have just happened when I tried to upload a large images (>1Mb) and with a big scale. With small images, this code works perfectly

Regards,

Quote:
quote:Originally posted by vnguyen
 Hi all
I'm coding jsp to upload the images into the blob (mysql database). Everything seems good except one thing that I cannot upload the completed images into database. I can upload images with no error but when I try to retrieve it back out browser, I've just got part of images to be displayed. below is my code. Thanks in advance

DiskFileUpload Upload = new DiskFileUpload();
Upload.setSizeMax(-1);
List items = Upload.parseRequest(request);
Iterator it = items.iterator();
while (it.hasNext()) {
    FileItem fi = (FileItem)it.next();
    if(!(fi.isFormField())) {
        PreparedStatement pstmt = conn.prepareStatement("INSERT INTO fswar0090 (files, filesize) VALUES( ?, ?)" );
        try {
            pstmt.setBinaryStream(1, fi.getInputStream(), (int)fi.getSize());
            pstmt.setInt( 2, (int)fi.getSize() );
            pstmt.executeUpdate();
            pstmt.close();
        }
        catch (Exception e) {
            out.println("error:" + e.getMessage());
        }
    }
}






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to upload images? vipin k varghese Beginning PHP 1 June 3rd, 2008 03:59 AM
Problem with images upload M.Poalim Beginning PHP 1 May 11th, 2007 07:25 PM
Upload Images Help leeyoung Classic ASP Professional 0 April 26th, 2005 08:42 PM
upload images mccoco Classic ASP Professional 2 September 23rd, 2003 04:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.