File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes What are the problem ? 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 "What are the problem ?" Watch "What are the problem ?" New topic

What are the problem ?

Alex Marks
Ranch Hand

Joined: Sep 12, 2005
Posts: 31
I have the following code. Just a code to fill up the BLOB column in database.
String template = "select picture from picture where id = ?";
Blob picture = null;
PreparedStatement statement = connection.prepareStatement(template);
ResultSet resultSet = statement.executeQuery();
picture = ((OracleResultSet)resultSet).getBlob(1);

File binaryFile = new File("fileName");
FileInputStream instream = new FileInputStream(binaryFile);
OutputStream outstream = picture.getBinaryOutputStream();

int size = picture.getBufferSize();
byte[] buffer = new byte[size];
int length = -1;

while ((length = != -1)
outstream.write(buffer, 0, length);
When I compile it, the compiler cannot find the method getBinaryOutputStream(); and getBufferSize(); What problem do I have ?
Thank you for you help and looking for your replies.

Before I come here, I am confused about Servlet/JSP. Ater I come here, I am more confused about it, but in systematically.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Neither of these methods are in the API for java.sql.Blob
It is possible you may be referring to an OracleBlob but your object type is Blob.

Personally I'm against casting to the specific Oracle types, but I hope it works for you
Alex Marks
Ranch Hand

Joined: Sep 12, 2005
Posts: 31
David O'Meara, Thank you for your help, I have solved wuch a problem. But I encounter another problem related to the above code.
java.sql.SQLException: ORA-01002: fetch out of sequence
what does this error mean ?
Thank you for your help !
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
There is something wrong in your first example where you want a Blob and cast to a specific ResultSet. You want to cast to an OracleBlob no?

Out of sequence errors... well it means you did something in a sequence (order) that the DB (or driver) didn't like. Often times I have seen it because you are trying to get the columns in a different order but I am not sure that is the problem here. Which line is causing the actual error?
I agree. Here's the link:
subject: What are the problem ?
It's not a secret anymore!