• 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

storing images in the database

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i dont know wheteher to post this query here or not.as i dont know about any oracle forum i am posting my query here.
Actually i want to store images/music or video in the oracle database. I hav read that u can acheive this with blobs.
But i hav also read that u require an appropriate convertor before storing it into the databse.
How do i go about it . can somebody please guide.
i also want to know about an oracle forum where i can post my queries. it would be helpful if somebody culd redirect me to any.

 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two suggestions:
1) Do a search for "blob" in this forum
2) check http://technet.oracle.com
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
u can do something like this ..hope u will get it ..
import these ...
import java.io.*;
import java.util.*;
import java.sql.*;
import oracle.sql.*;
import oracle.jdbc.driver.*;
then
insert an empty row in the table like this
stmt.executeUpdate("insert into blobdata (blob_nr,data) values ("+ +blobnr + " ,empty_blob())");
now u do just like this ..
ResultSet rs2;
BLOB blob=null ;
Stringcmd = "SELECT inhalt FROM blobdata WHERE blob_nr=" +blobnr + " for update";
rs2 = stmt.executeQuery(cmd);
if(rs2.next())
{
blob= ((OracleResultSet)rs2).getBLOB(1);
}
//filling blob
File binaryFile = new File("fileName);
FileInputStream instream = new FileInputStream(binaryFile);
OutputStream outstream = blob.getBinaryOutputStream();

int size = blob.getBufferSize();
byte[] buffer = new byte[size];
int length = -1;
while ((length = instream.read(buffer)) != -1)
outstream.write(buffer, 0, length);
instream.close();
outstream.close();

hope u can figure it out ..
if not then ask i will be happy to clarify it ..
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Need help!!!
i have a string, i have to store this in the database as type text....which means i have to save it as a type BLOB
how do i go about cvonverting the string to BLOB???
PLEASE HELP
i am using informix as my database
and java as my application program
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually i am able to store gif files into the oracle BLOB.
but i dont know how to retrieve the gif file from BLOB and display the gif in the browser
 
reply
    Bookmark Topic Watch Topic
  • New Topic