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");
}
}
}

Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

SILAN Technology, BBSR
Call to: 0674-2361252

Comment