Thread: JDBC: Insert ID
View Single Post
Old 06-21-2004, 03:42 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
Code:
Statement stmt = conn.createStatement();
// Obtain the generated key that results from the query.
stmt.executeUpdate("INSERT INTO authors " +
                   "(first_name, last_name) " +
                   "VALUES ('George', 'Orwell')",
                   Statement.RETURN_GENERATED_KEYS);
ResultSet rs = stmt.getGeneratedKeys();
if ( rs.next() ) {
    // Retrieve the auto generated key(s).
    int key = rs.getInt(1);
}
here is a code example of what i need ..

i can't find the getGeneratedKeys() method off the Statement object for the life of me. =/

is the jdbc version related to the j2sdk version ? i'm on 1.4.2
__________________
Mike
sde is offline   Reply With Quote