The standard MySQL Connector J driver does support getting generated keys, yes. Here is some sample code:
final Connection conn ; // setup connection
final String SQL ; // define SQL template string
final PreparedStatement stmt = connection.prepareStatement(
SQL,
Statement.RETURN_GENERATED_KEYS);
int affected = stmt.executeUpdate();
if (affected > 0) {
final ResultSet keySet = stmt.getGeneratedKeys();
while (keySet.next()) {
// these are your autogenerated keys, do something with them
System.out.println(keySet.getInt(1));
}
}