This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What are the problem ?

 
Alex Marks
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
}

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 = 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.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 381
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic