Database Using java

Retrieval of image,video from oracle 10g using java

Page 1 of 1

1 Replies - 2270 Views - Last Post: 08 September 2010 - 03:22 AM Rate Topic: -----

#1 dipesh_kumar  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 3
  • Joined: 05-September 10

Database Using java

Posted 08 September 2010 - 03:09 AM

I have written the following code given below to retreive the image from Oracle 10g using java but it shows the following error:"java.lang.UnsupportedOperationException"


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


class ImageRetriev
{
    public static void main(String args[])
    {
        
          ResultSet rs=null;
	  Statement stmt=null;
          Connection con=null;

	  try
          {
	 
	  Blob b3=null;
 
	 
	  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          
	  con=DriverManager.getConnection("jdbc:odbc:5thsem1","System","maa");
          
	  stmt=con.createStatement();
	  
	  File f1=new File("dip.jpg");
          
	  System.out.println("Before Retrieve1");
          
	  rs=stmt.executeQuery("select * from testblob1 where image_no=5");
                   
	  System.out.println("Before Retrieve2");

          if(rs.next())
           {

		try
		{		

		Blob test=rs.getBlob("imag_name");
		
                InputStream x=test.getBinaryStream();
                 
                int size=x.available();

                OutputStream out=new FileOutputStream("dip.jpg");

                byte b[]=new byte[size];

                x.read(B)/>;

                out.write(B)/>;
		}
                catch(Exception e)

		{

			System.out.println("Exception of Blob IS="+e);
		}

		
	   }

	   }
          
           catch(Exception e)
           {
               System.out.println("Exception of Retrieving ="+e);
           }

           finally
           {

                  try
                   {
                           stmt.close();
                           con.close();
                   }
                   catch(Exception e)
                   {  
                   }
           }
    }
}




There I request to u plz kindly help with the code and explaination....


Thankyou

Edited by macosxnerd101: Welcome to DIC! :) Please, :code:.

Is This A Good Question/Topic? -1
  • +

Replies To: Database Using java

#2 masijade  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 196
  • View blog
  • Posts: 580
  • Joined: 03-April 10

Re: Database Using java

Posted 08 September 2010 - 03:22 AM

Don't multi-post. That is extremely rude.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1