aspose file tools
The moose likes JDBC and Relational Databases and the fly likes How to read the blob column from oracle database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "How to read the blob column from oracle database" Watch "How to read the blob column from oracle database" New topic

How to read the blob column from oracle database

Bharat Agarwal

Joined: Jun 16, 2001
Posts: 21
Hi all,
I am able to insert the blob column in the database. Now, I want to check whether the element is inserted or not and so I am trying to retreive the bolb through JDBC. But it is giving me the error. I tried to check it out in as many ways as possible by me. Can someone look into it and reply back. I will greatly appreciate that. Thanks,Statement sment=conn.createStatement();
ResultSet rs = sment.executeQuery(sql);
String returndata=null;
if ( {
System.out.println("In the if loop");
try {
System.out.println("in the try loop");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedInputStream bis = new BufferedInputStream(rs.getBinaryStream("XYCOORD"));
byte[] bindata=new byte[1024];
int bytesread = 0;
System.out.println("In the try loop");
if ((bytesread =,0,bindata.length)) != -1) {
System.out.println("Before the try loop");
// txtfield.append(rs.getString("DRAW_ID"));
// txtfield.append(rs.getString("I_ID"));
// txtfield.append(returndata);
// txtfield.append(rs.getString("MA_DESC"));
System.out.println("Query executed");
// bis.close();
} catch (IOException ioe) {
System.err.println("Problem retreiving binary data : " + ioe);
} catch (Exception cnfe) {
System.err.println("Problem retreiving binary data : " + cnfe);
this is my code where i want to retreive the blob. XYCOORD is the blob column in the database.
It is very urgent as I need to submit my project as the deadline is appraoching for me(I am a student)
Bharat Agarwal

Joined: Jun 16, 2001
Posts: 21
here is the error that it is giving meIn the if loop
in the try loop
java.lang.NoClassDefFoundError: oracle/sql/BLOB
at oracle.jdbc.driver.OracleStatement.getBinaryStreamValue(
at oracle.jdbc.driver.OracleResultSetImpl.getBinaryStream(
at oracle.jdbc.driver.OracleResultSet.getBinaryStream(
at TestProject.action(
at java.awt.Component.handleEvent(
at java.awt.Component.postEvent(
at java.awt.Button.process(
at java.awt.ActionEvt.dispatch(

I could not understand y it is not going ahead of the BufferedInputStream method....

Thanx in advance.
srikanth bukkapatnam

Joined: Jul 31, 2001
Posts: 7
Do you have in your classpath?. Sometimes the drives also makes difference, are you using thin client or oci?
Chad McGowan
Ranch Hand

Joined: May 10, 2001
Posts: 265
Have you tried
byte[] bytes = null
Blob b = rs.getBlob("XYCOORD");
bytes = b.getBytes(1,b.length);
This works for me. You could also use b.getBinaryStream() to return an InputStream.

[This message has been edited by Chad McGowan (edited August 09, 2001).]
I agree. Here's the link:
subject: How to read the blob column from oracle database