• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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..
 
The only cure for that is hours of television radiation. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic