returning autogenerated primary key after insertion

HiI am inserting a row into the database using simple jdbc statement. The primary key for that row is autogenerated by the database.Is there any way to get the primary key and return it to the user?
[219 byte] By [ketancmaheshwaria] at [2007-11-27 6:03:46]
# 1
PreparedStatement ps = con.preparedStatement("INSERT INTO Table (title, name) VALUES ("test", "name")", PreparedStatement.RETURN_GENERATED_KEYS);ps.executrUpdate();ResultSet rs = ps.getGeneratedKeys();while (rs.next()) {primaryKey = rs.getInt(1);}
Mike_Calgooa at 2007-7-12 16:46:52 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
By the way, it also depends on the Database and the JDBC driver used. This example doesn't work on Oracle and PostgreSQL for example.
BalusCa at 2007-7-12 16:46:52 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...