I need to insert a record into a table having a Blob type column. I am having byte. Need to convert into Blob and then insert it into that table. This is the first time I am doing handling Blob.
http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/blob.html is saying:
8.1.1 Creating a Blob Object
The following code fragment illustrates creating a Blob object, where stmt is a Statement object:
ResultSet rs = stmt.executeQuery("SELECT DATA FROM TABLE1"); rs.first(); Blob data = rs.getBlob("DATA");
The variable blob contains a logical pointer to the BLOB value that is stored in the column DATA in the first row of the result set rs. It does not contain the data in the BLOB value, but as far as JDBC methods are concerned, it is operated on as if it did.
Here if the table "TABLE1" is empty then we will get nothing in ResultSet. Need to have something in the column "DATA". And in my case the table is empty. So, How to insert the Blob. I have the byte with me.
Originally posted by Babar Qadri: Thanks Jeanne. I need a tool to view the Data of a BLOB field. Because SQL* PLUS is not showing me the data and giving me the message
SP2-0678: Column or attribute type can not be displayed by SQL*Plus
Babar, As a BLOB is binary data, it doesn't really make sense to display it on the command line. I think your best bet is to write a small java program to get the blob's data and do whatever with it (or print it if you are debugging.)