❮ Previous Next ❯

JDBC-Retrive image from Oracle Database

import java.sql.*;
import java.io.*;

public class JdbcPhotoRetrive
{
public static void main(String args[]) throws Exception
{
//load the register driver
Class.forName("oracle.jdbc.driver.OracleDriver");

//establish the connection
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","myoracle");

//create the statement object
PreparedStatement ps=con.prepareStatement("select * from imgtable");

ResultSet rs=ps.executeQuery();
if(rs.next())
{
Blob b=rs.getBlob(2);
byte brr[]=b.getBytes(1,(int)b.length());
FileOutputStream fout=new FileOutputStream("d:\\p.jpg");
fout.write(brr);
fout.close();
System.out.println("Success");
}
}
}

❮ Previous Next ❯


Follow Us




  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved