This page looks plain and unstyled because you're using a non-standard compliant browser. To see it in its best form, please upgrade to a browser that supports web standards. It's free and painless.

Robert Marcano's blog
Get Firefox Use OpenOffice.org hacker emblem

Java = APIs, Oracle = Wrong APIs implementations

robert | 23 November, 2005 15:50

Since JDBC 3.0 it has been posible to retrieve the keys that are generated on a database when an SQL insert is executed, using the getGeneratedKeys() method on the statement object. For some reason the latest Oracle JDBC driver that claims that implement this method, has a non standard behaviour (that is not strange on Oracle):

It does not returns the generated keys values, it only returns a value for a propietary object implementation named ROWID. One of the solutions was to use that ROWID in a query to retrieve the other generated columns:

SELECT KEY_1, KEY_2, KEY_3 FROM MYTABLE WHERE ROWID = ?

where KEY_1, KEY_2, KEY_3 are the generated columns I want to know its value. The other solution is not to use the int parameter (with the value Statement.RETURN_GENERATED_KEYS) in the PreparedStatement, instead use the one that needs the generated column names or indexes.

Another reason why I prefer IBM DB2 and PostgreSQL over Oracle.

Comments

Add comment

 authimage
 
Valid XHTML 1.0 Strict and CSS.
Copyright 2003-2007 Robert Marcano. All Rights Reserved
Powered by LifeType
Original Design by Book of Styles