• 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

fetch out of sequence

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm trying simple loading of an image file into Oracle as a Blob, but keep getting the error:ORA-01002: fetch out of sequence.
The code is as follows:
BLOB blob = null;
stmt.execute("CREATE TABLE img (name varchar(10), data blob)");
stmt.execute("INSERT INTO img VALUES ('test', empty_blob())");
stmt.execute("commit");
String cmd = "SELECT * FROM img WHERE name='test' FOR UPDATE";
ResultSet rset = stmt.executeQuery(cmd);
while(rset.next())
blob = ((OracleResultSet)rset).getBLOB(2);
What am I doing wrong?? Please help!
Thanks.
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
taken from the oracle docs:
Error Message: "ORA-01002: fetch out of sequence"
A JDBC Connection by default has the AutoCommit turned ON. However, to use a SQL that has 'for update' you need to have autoCommit to be turned OFF.
Hence, the solution is to set autocommit to false.
http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#_18_
Jamie
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic