• 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

Insert/Select Image from Oracle DB.

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

Please provide some sample code for inserting and selecting image of size 500 kb into/from oracle.

and what should be the data type in oracle for it.

Regards,
Neeraj
 
Ranch Hand
Posts: 293
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

If you search this forum for the words "Oracle" and "Blob", you should find your answers.

Cheers,

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

Thnx dave.. I got some info with the search...

I am able to fetch and insert images into oracle..only if the gif image size is 1 kb.. more than that give null poiter exception..

any inputs will be a great help..

Regards,
Neeraj.
 
Dave Salter
Ranch Hand
Posts: 293
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show us the code you are using. Also, is there a stack trace of any exceptions?

Cheers
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ResultSet rs = st2.executeQuery("Select picture from neeraj_pic_store where description='1'");
while (rs.next()){
blob=((OracleResultSet)rs).getBLOB(1);
is1=blob.getBinaryStream();
}

int pos=0;
int length=0;
byte[] b = new byte[blob.getChunkSize()];

while((length=is.read(b))!= -1){
pos+=length;
os.write(b);
}
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
tried this also

ResultSet rs = st2.executeQuery("Select picture from neeraj_pic_store where description='1'");
BufferedInputStream bis=null;
if ((rs.next()))
{

bis = new BufferedInputStream( rs.getBinaryStream("picture") );
byte bindata[] = new byte[1024];
int bytesread = 0;
while ( (bytesread = bis.read(bindata,0,bindata.length)) != -1 )
{
os.write(bindata);
}



}

getting stream closed exceptionm..
 
reply
    Bookmark Topic Watch Topic
  • New Topic