jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes fetch out of sequence 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 "fetch out of sequence" Watch "fetch out of sequence" New topic

fetch out of sequence

Tia Wai

Joined: Sep 19, 2001
Posts: 1
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())");
String cmd = "SELECT * FROM img WHERE name='test' FOR UPDATE";
ResultSet rset = stmt.executeQuery(cmd);
blob = ((OracleResultSet)rset).getBLOB(2);
What am I doing wrong?? Please help!
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

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.
I agree. Here's the link: http://aspose.com/file-tools
subject: fetch out of sequence
It's not a secret anymore!