• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What are the problem ?

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !
 
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic