update Blob field in ResultSet with Java2 --URGENT

Hi,

Before install J2EE environnement, I manipulate Blob with jdbc interface:

I made a insert with the Blob field to null and after this insert I executed a "select for update" to get a updatable ResultSet and used updateBinaryStream() methode to set my file in the Blob. It works OK

Now, with J2EE environnement (Java 2 and Oracle 8 with Thin Oracle drivers 'classes12.zip')

I get a SQLException withe the same code source:

'ORA-01002: Extraction en rupture de squence '

(sorry I'm French...)

If I try to use the new Updatable ResultSet with a call:

Statement stat = aConn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_UPDATABLE);

and try after to use the same methode 'setBinaryStream()' for update Blob field I have another Exception:

'ORA-01008: Toutes les variables ne sont pas li es '

if I use a simple 'select' or

'ORA-01002: Extraction en rupture de squence '

if I use a 'select for update'

(Sorry i'm always French...)

Someone could help me!!!!!

exemples:

1)

ls_Query = "select LC_PA_NOM from PA where ID_PA_NUMERO = 449 for update";

Statement stat = aConn.createStatement();

ResultSet rs= stat.executQuery(ls_Query );

if(rs.next())

{

rs.updateBinaryStream(1,theInputStream, theInputStream.available());

rs.updateRow();

}

=> raise SQLException: ORA 1002

2)

ls_Query = "select LC_PA_NOM from PA where ID_PA_NUMERO = 449 for update";

Statement stat = aConn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_UPDATABLE);

ResultSet rs= stat.executQuery(ls_Query );

if(rs.next())

{

rs.updateBinaryStream(1,theInputStream, theInputStream.available());

rs.updateRow();

}

=> raise SQLException: ORA 1002

3)

ls_Query = "select LC_PA_NOM from PA where ID_PA_NUMERO = 449";

Statement stat = aConn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_UPDATABLE);

ResultSet rs= stat.executQuery(ls_Query );

if(rs.next())

{

rs.updateBinaryStream(1,theInputStream, theInputStream.available());

rs.updateRow();

}

=> raise SQLException: ORA 1008

Thanks a lot

Felmerien

[2386 byte] By [felmerien] at [2007-9-26 2:44:03]
# 1
Could you attempt to translate these?> 'ORA-01002: Extraction en rupture de squence '> 'ORA-01008: Toutes les variables ne sont pas li es '
dubwai at 2007-6-29 10:23:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

ORA-01008: not all variables bound

Cause: A SQL statement containing substitution variables was executed without all variables bound. All substitution variables must have a substituted value before the SQL statement is executed.

Action: In OCI, use an OBIND or OBINDN call to substitute the required values.

and

ORA-01002: fetch out of sequence

Cause: In a host language program, a FETCH call was issued out of sequence. A successful parse-and-execute call must be issued before a fetch. This can occur if an attempt was made to FETCH from an active set after all records have been fetched. This may be caused by fetching from a SELECT FOR UPDATE cursor after a commit. A PL/SQL cursor loop implicitly does fetches and may also cause this error.

Action: Parse and execute a SQL statement before attempting to fetch the data.

Jamie

jlrober at 2007-6-29 10:23:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

The solution is to turn autocommit to false when using the FOR UPDATE clause in your query.

So, before your createStatement() method put in this line:

aConn.setAutoCommit(false);

That should eliminate the ORA-01002 error. the ORA-01008 may be related to this too. try the above first.

Jamie

jlrober at 2007-6-29 10:23:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

I found the explanation to my answer above:

"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

jlrober at 2007-6-29 10:23:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...