Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> how to retrieve PK via JDBC?
Hi folks,
I use the oracle driver that ships with classes12.zip. When I execute the following code fragment:
conn = DriverManager.getConnection( SqlUniversal.getOracleConnection(), SqlUniversal.getDbUser(), SqlUniversal.getDbPassword());
stmt = conn.createStatement();
// seems not to find a method with this signature stmt.execute("insert into item (shortdescription, price, fulldescription)
values ('Monitor', 333.22, 'fancy thing')", Statement.RETURN_GENERATED_KEYS);
// always null even if I use execute() without a flag -> why? ResultSet rset = stmt.getResultSet();
if (rset != null)
rset.getLong("itemid"));
I always get the error message:
The same is true for all executeXyz(String sql, int FLAG) methods from
the Statement interface that use a signature that specifies a symbolic
constants to indicate the driver should return something.
Where have I missed something? Does the oracle driver not implement
all methods of the Statement interface? Is there any other way to
return the generated PKs?
I use a trigger/sequence to set the PKs.
Environment:
DBMS: Oracle 8.17
IDE: WAS 5.0
JDK: SUN 1.4
TIA
Frank
Received on Sun Mar 02 2003 - 18:42:44 CST
![]() |
![]() |