• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in uploading big images

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using apache's FileUpload to upload images into the data base. I am using oracle 10g data base and image is stored as a BLOB object. I am connecting to the DB using JDBC thin drive.
I can upload small images of below 4KB but bigger than that.
When I wanted to upload some big images of size 50-100KB, i am getting "Data size is bigger then max size".


Any help please.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Search for setMaxSize in this page from the FileUpload documentation:
http://jakarta.apache.org/commons/fileupload/using.html


Moving to the Other Open Source Projects forum
[ May 26, 2006: Message edited by: Ben Souther ]
 
Shrikant Kulkarni
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have solved this problem by inserting empty_blob() while inserting the BLOB image. Retrieve the row just inserted, and lock it for insertion of the BLOB columns.
prapredStatement = connection.prepareStatement("select image from image_upload where log_id = ? and image_name = ? for update");
prapredStatement.setInt(1,logId);
prapredStatement.setString(2,imageName);
// Execute the SQL statement
resultSet = prapredStatement.executeQuery();
// Retrieve Blob streams for Image column, and load the sample file
if(resultSet.next())
{
// Get the Blob locator and open output stream for the Blob
Blob mapBlob = resultSet.getBlob(1);
OutputStream blobOutputStream = ((oracle.sql.BLOB)mapBlob).getBinaryOutputStream();
// Open the FileInputStream for insertion into the Blob column
// saveTo is File from which where you are getting the image
InputStream sampleFileStream = new FileInputStream(saveTo);
// Buffer to hold chunks of data to being written to the Blob.
byte[] buffer = new byte[10* 1024];
// Read a chunk of data from the sample file input stream, and write the chunk to the Blob column output stream.
//Repeat till file has been fully read.
int nread = 0; // Number of bytes read
while( (nread= sampleFileStream.read(buffer)) != -1 ) // Read
//from file
blobOutputStream.write(buffer, 0, nread); // Write to Blob
// Close both streams
sampleFileStream.close();
blobOutputStream.close();
}
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic