Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> how to retrieve PK via JDBC?

how to retrieve PK via JDBC?

From: Frank Ratzlow <frank_ratzlow_at_hotmail.com>
Date: 2 Mar 2003 16:42:44 -0800
Message-ID: <5ef29569.0303021642.797a98b7@posting.google.com>


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:



java.lang.NoSuchMethodError: java.sql.Statement: method execute(Ljava/lang/String;I)Z not found

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US