code: public int lastInsertedId (Connection conn, Statement istmt, String table, String column)
          throws SQLException
      {
          // if this JDBC driver supports getGeneratedKeys, use it!
          if (istmt != null && conn.getMetaData().supportsGetGeneratedKeys()) {
              ResultSet rs = istmt.getGeneratedKeys();
              if (rs.next()) {
                  return rs.getInt(column);
              }
          }
          return fetchLastInsertedId(conn, table, column);
      }
docs: from DatabaseLiaison