• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Problem with Blob's Length while retrieving an image

 
Ranch Hand
Posts: 67
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Helo, I've copied my image to img table in mysql. Now i m trying to retrieve my image and save it into some other location but for me i got only an exception "java.sql.SQLException: "pos" + "length" arguments can not be larger than the BLOB's length" this what happens when i execute my program. But yesterday i got output but today it doesn't work.



Please anyone help me.......
error.png
[Thumbnail for error.png]
 
Ranch Hand
Posts: 417
Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I never put images in the database, I find it inefficient. I put a file path in the db and put the image on the file system.

If you insist on putting them in the db, beware that BLOB max length is only 64K. You might consider declaring your column as MEDIUMBLOB or LONGBLOB:

BLOB: 65535
MEDIUMBLOB: 16777215
LONGBLOB: 4294967295

Beware of the memory requirements to support long blobs although ;-)

https://dev.mysql.com/doc/refman/5.5/en/storage-requirements.html#id899830





 
Sheriff
Posts: 28399
100
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You've asked it to read a number of bytes which is the length of the blob, starting at position 2. But starting at position 2 there can't be that many bytes to read, in fact there can only be 1 less than the total length of the blob. Is there a reason you wanted to skip the first byte, or was that just a mis-typing?
 
vinoth vino
Ranch Hand
Posts: 67
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"2 means second image only know ? or not? because i saw in one site in that they commented as "1 means first image" so already I've inserted one image then again today also one image... So now i m trying to retrieve the second image... For that only now i'm using 2 in that line " IS THIS CORRECT ???
if wrong please make me to understand of that line........ Thank you so much for your efforts
 
Paul Clapham
Sheriff
Posts: 28399
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't quite make sense of that, but if you're asking me to explain the parameters of the getBytes() method of Blob, it would make more sense for you to just go and look at the documentation for that method. Much faster and you don't have to worry about making a clear explanation of your question to a third party. Of course if you have questions about what the documentation says, then this forum is a good place to ask those questions.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic