Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

BLOB Question

  Asked By: Vivek    Date: Jan 07    Category: Java    Views: 689
  

Ive got a problem inserting files larger than 2k (2048 bytes) into
BLOB objects via JDBC, i use something like this:


if (news.getPicture() != null)
ps.setBinaryStream(9,news.getPicture(),news.getPicture().available
());
else
ps.setBinaryStream(9,null,0);

suppose tht new.getPicture() returns a InputStream, it works fine
when the file size (InputStream) is less than 2k but it doesnt works
when it gets larger than 2k.

As im a newbie in JDBC programming i would appreciate any guides or
tips to solve my problem.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Luigi Fischer     Answered On: Jan 07

If you check the value of news.getPicture().available() when file size is bigger
than 2
K, you will see it is 0.

One solution is to read in byte[] and then call setBinaryStream.

 
Didn't find what you were looking for? Find more on BLOB Question Or get search suggestion and latest updates.




Tagged: