This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes fetch out of sequence Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "fetch out of sequence" Watch "fetch out of sequence" New topic
Author

fetch out of sequence

Tia Wai
Greenhorn

Joined: Sep 19, 2001
Posts: 1
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.
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.
http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#_18_
Jamie
 
wood burning stoves
 
subject: fetch out of sequence
 
Similar Threads
ora-01002 fetch out of sequence
java.sql.SQLException: ORA-01407:
opinion soughted
Data lost when writing object to a file
Reading From a Binary Large Object(BLOB)