How can i read a stored picture in oracle Long Raw datatype? blob or clob?

How can i read a stored picture in oracle Long Raw datatype? Like a blob or clob?....i am using jdk 1.3
This is because...i tried to read it like a blob but i obtain a exception...about Type of column no valid......but the column exist....and it contains the long raw datatype of the pictures.....this is my code:
import java.sql.*;
import java.io.*;
import java.util.*;
import oracle.jdbc.driver.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.InputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.DriverManager;
import oracle.sql.BLOB;
import oracle.sql.BLOB.*;
import oracle.jdbc.driver.*;
import java.sql.*;
class rec_ima1
public static void main(String h[])
Connection con = null;
Blob bl;
final ImageIcon image1;
JPanel photo;
try
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
con= DriverManager.getConnection("jdbc:oracle:thin:@123.3.12.213:1521:db_name","user","password");
String query = "Select * from pictures where ID = '18840'";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery( query );
if (!rs.next())
System.out.println("Empty Result Set");
bl = rs.getBlob(5);
if (bl == null) {
System.out.println("Null Blob");
return;
InputStream is = bl.getBinaryStream();
int imageLength = (int) bl.length();
System.out.println(imageLength);
System.out.println(bl.length());
byte[] imageData = new byte [imageLength];
is.read(imageData, 0, imageLength);
image1 = new ImageIcon(imageData);
photo = new JPanel() {
public void paint(Graphics g){
g.setColor(Color.lightGray);
g.drawImage(image1.getImage(), 0, 0, this);
} catch (Exception e) {
e.printStackTrace();
Now i tried using clob:
import java.sql.*;
import java.io.*;
import java.util.*;
import oracle.jdbc.driver.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.InputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.DriverManager;
import oracle.sql.CLOB;
import oracle.sql.CLOB.*;
import oracle.jdbc.driver.*;
import java.sql.CallableStatement;
class rec_ima4
public static void main(String h[])
Connection con = null;
Clob cl;
JPanel photo;
try
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
con= DriverManager.getConnection("jdbc:oracle:thin:@123.3.12.213:1521:db_name","user","password");
con.setAutoCommit (false);
String query = "Select * from pictures where ID = '18840'";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery( query );
while (rs.next()) {
oracle.sql.CLOB clob = (CLOB) rs.getObject(5); //line 47
} catch (Exception e) {
e.printStackTrace();
This is the runtime exception:
java.lang.ClassCastException: [B
at rec_ima4.main(rec_ima4.java:47)

Thanks by answering to me......
Well....i did that....but what is ImageIO?....
I declared a ImageIcon imageIO, but this give me the following:
rec_ima3.java:49: cannot resolve symbol
symbol : class BufferedImage
location: class rec_ima3
BufferedImage bi = ImageIO.read(bInput);
^
rec_ima3.java:49: cannot resolve symbol
symbol : variable ImageIO
location: class rec_ima3
BufferedImage bi = ImageIO.read(bInput);
^
What classes i have to import?.....what is ImageIO?
Thanks

Similar Messages

  • How can i  read a image from a oracle DB?

    How can i read a image from a oracle DB?
    Because in the DB a have a field that is a picture that i would like to show in a jpanel.....but this field is in oracle DB only has strange caracters ..... so Do i have to read this field like a input stream?....
    Could some body help me please?
    Thanks...
    Mary

    Well I suppose the picture is stored in a blob. If that is so this is some code I have used to load a picture to a panel. Hope you find it usefull.
    PreparedStatement retreive = db.createPreparedStatement("select bl from test where ln = ?");
    Blob bl;
    try{
    retreive.setBigDecimal(1, new BigDecimal(jTFln.getText()));
    ResultSet rs = retreive.executeQuery();
    if (!rs.next())
    System.out.println("Empty Result Set");
    bl = rs.getBlob("bl");
    if (bl == null) {
    System.out.println("Null Blob");
    return;
    InputStream is = bl.getBinaryStream();
    int imageLength = (int) bl.length();
    System.out.println(imageLength);
    System.out.println(bl.length());
    byte[] imageData = new byte [imageLength];
    is.read(imageData, 0, imageLength);
    image1 = new ImageIcon(imageData);
    photo = new JPanel() {
    public void paint(Graphics g){
    g.setColor(Color.lightGray);
    g.drawImage(image1.getImage(), 0, 0, this);
    } catch (BadLocationException ble){
    ble.printStackTrace();
    } catch (SQLException sqle){
    sqle.printStackTrace();
    } catch (IOException ioe){
    ioe.printStackTrace();
    }

  • How can i see created stored procedure from oracle?

    Hi All
    could any one help me?
    i have created procedure Insert_Profilebasicdetail and more in oracle 10g
    now i want 2 see the structure or code for the created procedure
    how can i see?
    Thanks
    Edited by: Ajay Patel on Sep 25, 2008 2:18 AM

    Hi,
    If you want to know the paramters of the procedure or decalaration jist use describe
    14:53:56 SQL>desc dba_verify_db_current_schema
    PROCEDURE dba_verify_db_current_schema
    Argument Name                  Type                    In/Out Default?
    IN_USER_NAME                   VARCHAR2                INIn Order to know the Source Code.. you might have got the reply.. from the Earlier Response... !!
    - Pavan Kumar N

  • How can I retreve old stored pictures after reinstalling Elements7 on a new computer?

    My computer with windowsXL crashed. I now have Windows8 When I reinstalled Elements 7  most of the oictures were missing. I thought they wre all stored. Is there a way to get them back?

    The photos are not stored in PSE. The photos are stored on your old computer's hard disk(s) somewhere. If those disk(s) are available, retrieve the photos and the PSE catalog file (*.pse7db) and move those to the new computer. The photos need to be in the EXACT same folders on the new computer that they were in on the old computer. The Catalog file can go anywhere. Then double-click on the *.pse7db file

  • How can I get the edited pictures from the thumbnails to full size?

    I upgraded to iPhoto 11, the thumbnail photos show my previous edits, but when I click on the photo to make it bigger, it reverts back to the unedited, original picture.  How can I get the edited pictures from the thumbnails to full size?

    Verify you are using iPhoto11 ver 9.5
    if not run the >Software update or check your apps folder and make sure the correct iPhoto is launched,  not an older ver.

  • Can you please help me by saying me how can i join two different picture to make it as one picture.??

    Hi Sir/ Madam,
       My name is Rishav and I am facing some problem with my Photoshop CC. Actually I have a question. If you guys could help me out i will be very obliged. The quest in "Can you please help me by saying me how can i join two different picture to make it as one picture.??"

    Maybe you should post over at
    Photoshop for Beginners
    or start with the "Get Started" section of the Help:
    Photoshop Help | Photoshop Help
    And your question
    Can you please help me by saying me how can i join two different picture to make it as one picture.??
    does not seem particularly specific – do you want to simply combine two images as they are, do you want to clip elements from the one and insert them into the other, …?
    Could you post (lores of) the images and explain what you intend to achieve?

  • How can one  read a Excel File and Upload into Table using Pl/SQL Code.

    How can one read a Excel File and Upload into Table using Pl/SQL Code.
    1. Excel File is on My PC.
    2. And I want to write a Stored Procedure or Package to do that.
    3. DataBase is on Other Server. Client-Server Environment.
    4. I am Using Toad or PlSql developer tool.

    If you would like to create a package/procedure in order to solve this problem consider using the UTL_FILE in built package, here are a few steps to get you going:
    1. Get your DBA to create directory object in oracle using the following command:
    create directory TEST_DIR as ‘directory_path’;
    Note: This directory is on the server.
    2. Grant read,write on directory directory_object_name to username;
    You can find out the directory_object_name value from dba_directories view if you are using the system user account.
    3. Logon as the user as mentioned above.
    Sample code read plain text file code, you can modify this code to suit your need (i.e. read a csv file)
    function getData(p_filename in varchar2,
    p_filepath in varchar2
    ) RETURN VARCHAR2 is
    input_file utl_file.file_type;
    --declare a buffer to read text data
    input_buffer varchar2(4000);
    begin
    --using the UTL_FILE in built package
    input_file := utl_file.fopen(p_filepath, p_filename, 'R');
    utl_file.get_line(input_file, input_buffer);
    --debug
    --dbms_output.put_line(input_buffer);
    utl_file.fclose(input_file);
    --return data
    return input_buffer;
    end;
    Hope this helps.

  • How can I read a file with ASCII Special Character into a SQL table using SSIS 2008?

    I've tried everything to read this file and am getting no where.   Help how can I read this file and load a SQL table?
    RS - AscII - 30  (Record Separator)
    GS - AscII - 29 (Group Separator)
    Thank you for your assistance - Covi
    Mark Covian

    We can use script component as source/transformation to read the text file and assign the contains to a string. Split the string by chr(30)  i.e RS and finally stored into an array or write to the output buffer of the script component.
    For example on how to use script component refer this link
    http://social.technet.microsoft.com/Forums/en-US/6ff2007d-d246-4107-b77c-624781baab38/how-to-use-substring-in-derived-column-in-ssis?forum=sqlintegrationservices
    Regards, RSingh

  • How can I see the stored files in cache?

    How can I see the stored files in cache? I need them!
    Thanks for helping me.

    The History menu lets you revisit the page where you can drag any page element from it.
    How would you sort through thousands (tens of thousands) of files found in a cache?

  • HT1766 I recently replaced my iphone and took 6 weeks of new pictures, I plugged it to my computer and by accident I restored the back from 4 months ago and erased my new pictures. How can I recover the new pictures ?? Help!!

    I recently replaced my iphone and took 6 weeks of new pictures, I plugged it to my computer and by accident I restored the back from 4 months ago and erased my new pictures. How can I recover the new pictures ?? Help!!

    Sorry those pics might be gone, since you restored from your backup.
    Only way possible if by some possibility you were able to backup your current data to itunes, then you can restore from that backup.
    Open itunes - edit - preference - devices - backup - see if there is an up to date backup.
    If you don't have one then sorry those pics are gone.

  • How can I move photos from pictures to my Iomega external hard drive?  I have copied all photos, however it won't allow me to paste them.  The paste button is grayed out.

    How can I move photos from pictures to my external hard drive? I have copied all photos, however it won't allow me to paste the photos.  The paste button is grayed out.

    Do you want to copy some pictures to the external drive, or do you want to move your whole iPhoto library? The latter will free up hard drive space on your start up disk; the procedure is explained here:
    http://support.apple.com/kb/PH2506
    Note this is not the same as a Time Machine backup.
    If on the other hand you want to copy some photos from one drive to another, you can just drag and drop them from one location to another. This is a true copy, the originals will remain intact.

  • HT4528 How can I see if a picture was sent from my phone? I am not sure the number it was sent to, it may have been an i-phone. I just want to know if someone sent themselves a pic from my phone....

    How can I see if a picture was sent from my iPhone? I am not sure the number the picture(s) was sent to..and whether or not it was an iPhone...I just want to know if someone sent themselves pics from my phone. Aside from a court order to obtain data message info, any ideas? Any info is greatly appreciated.

    by email?
    by mms?

  • How can you get your facebook pictures to sync with your contacts?, HOW Can you get your facebook pictures to syncwith your contacts?

    How can you get your facebook pictures to sync with your contacts?

    take a look at the link
    http://www.iphonestuffs4u.com/how-to-sync-facebook-contacts-to-iphone/

  • How can I delete a chosen picture in my address card

    Hi ALL,
    As the title already says ... How can I delete a chosen picture in my address card.
    Every Email I sent it shows a picture on the right upper corner.
    I tried to delete it or chose "Non" but notting works ... how to do that.
    Thanks in advance ...
    Dimaxum

    That picture does not show in actual emails - none of your recipients will see it. The picture is the one you chose when you set up your account; you can change it in System Preferences -> Accounts, but you can't delete it - each account will have a picture assigned to it.

  • HT1296 how can i sync every day pictures from iphone to mac?

    how can i sync every day pictures from iphone to mac?
    i can only sync my app via itunes, and the pictures from my mac to iphone, and not the opposite

    Which Mac OS do you have adn which iPhoto do you have?
    Do you see Photo Stream on the left side of iPhoto?
    Appletini6
    im pretty sure iphoto is for importing. icloud is for photo stream.
    Yes but iPhoto can import directly via Photo Stream.

Maybe you are looking for

  • Color Printing in java

    Can any one guide me to print colored characteres in System console?. I am starting many processes in my application and i want to show green OK for successfully started processes and i want to show red FAILED for failed processes. Please let me know

  • Launch air application from browser like adobe connect pro

    I will like to install and launch my adobe air application from the browser, just like adobe connect pro does. Any help on this?

  • UIX:Tree Control

    Hi, Has anybody used or know to use the UIX:Tree control part of the UIX Simple JSP Components? If so can you please tell me if this helps creating a DHTML Tree component? Thanks mn

  • What is  Double.NaN

    hi i want to know what is Double.NaN ? the SUN doc says, "....... A constant holding a Not-a-Number (NaN) value of type double...." then what is the content of Double.NaN ? suppose i am writing Double a = new Double(Double.NaN); what is the content o

  • Installing AIR SDK on Ubuntu?

    Hi everyone, I am about to pull my hair off. I have tried to spent the complete  morning to install the Adobe AIR SDK on my Ubuntu machine and it just  won't work. The runtime version is already installed and have verified it to be working with vario