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); statement.setString(1,values[0]); ResultSet resultSet = statement.executeQuery(); while(resultSet.next()) { picture = ((OracleResultSet)resultSet).getBlob(1); }
int size = picture.getBufferSize(); byte[] buffer = new byte[size]; int length = -1;
while ((length = instream.read(buffer)) != -1) outstream.write(buffer, 0, length); instream.close(); outstream.close(); --------------------------------------------------------------------------- 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.
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
posted
0
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 !
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: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.