• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

How to set and get images in Oracle databse

Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Friends here is my code it runs succesfully but when i try to see the image
stored in the file it gives me windows error saying bmp is not a valid file .
can i get the code for saving and retriving the image in BLOB column of database .
PLZ help .
package test;
import java.sql.*;
import java.io.*;
public class GetImage
public static void main(String args[])
Blob blob = null;
Connection1DB cdb = new Connection1DB();
Connection conn = (Connection)(cdb.getConnection());
System.out.println("Got the connection");
FileOutputStream fos= new FileOutputStream("E:/javatest/dbimage.bmp");
String sql1= "select IMAGE1 from IMAGE ";
Statement stmts = conn.createStatement();
ResultSet rs = stmts.executeQuery(sql1);
InputStream ims=null;

long len= blob.length();
byte collect[]= blob.getBytes(1l,(int)len);
System.out.println(""+ collect);
catch(Exception e)



With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic