• 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

using setBlob()

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i have a question.
I have got a table with Data Type BLOB in mysql database

i have a jsp page with <html:file > input and that gives me the
FormFile object in my ActionForm using which i can get the InputStream Object , but i can't figure out how to save it to the the table using setBlob on my prepared Statement.
i was thinking about calling setBinary() on my prepared statement but it needs a third argument the length of the data and thats where i am getting stuck

-thanks.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Prakash,
I recommend not using the setBlob function due to the difficulty you described with creating a Blob. Instead, I would use setBinaryStream(). There is a version of the method that only takes two parameters, so you don't need the length.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That method has only been introduced in Java 1.6, so many drivers don't support it yet. You'd also have to upgrade to Java EE 5 to be compatible.
 
prakash chauhan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help.
well i am using 1.5
but some how i was able to use setBinaryStream().
What i did was like this. I got FormFile object from my Action Form
from FormFile i got InputStream and a lenght property
Then i used


the problem i am facing now is using the above mentioned code i am able to save a .jpeg file to my database (which is of type Blob) however when i try to save an audio file (.mp3, or .wmv) i get the error message that
the "query exceeded the max_allowed_packets " i am using MySQL as my Database server.

is it something(some variable) i need to set somewhere in my MySQL server?
-Thanks.
[ November 20, 2007: Message edited by: prakash chauhan ]
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Rob. I hadn't noticed that I was looking at the latest version of the API. I had used the version of the API that does take a length and was just trying to verify the parameters.
 
reply
    Bookmark Topic Watch Topic
  • New Topic