title: Why this java code doesn't get last updated ID?
body: <p>I was getting last inserted ID from below code but as I changed it for update it always returns me 0 as last updated ID. Is there any different way to get last Updated id in java using prepared statements?</p>
  
  <pre><code>public static String updateRegistrationInfo(Integer COMPANY_ID, String FIRST_NAME, String LAST_NAME, String MOBILE_NO,
                                         String WORK_EMAIL, String PASSWORD) throws Exception {
      Connection dbConnection = null;
      PreparedStatement preparedStatement = null;
      Integer last_inserted_id = 0;
  
      String insertTableSQL = 
          "UPDATE USER_DETAILS SET COMPANY_ID=?,FIRST_NAME=?, LAST_NAME=?, MOBILE_NO=?, WORK_EMAIL=?, PASSWORD=? WHERE WORK_EMAIL=? AND MOBILE_NO=?";
  
      try {
  
          dbConnection = getConnection();
  
          //--USER_ID IS SET TO AUTO INCREMENT PRIMARY KEY
  
          String returnCols[] = { "USER_ID" };
  
          //--INSERTING MEETING DETAILS
  
          preparedStatement = dbConnection.prepareStatement(insertTableSQL, returnCols);
  
          preparedStatement.setInt(1, COMPANY_ID);
          preparedStatement.setString(2, FIRST_NAME);
          preparedStatement.setString(3, LAST_NAME);
          preparedStatement.setString(4, MOBILE_NO);
          preparedStatement.setString(5, WORK_EMAIL);
          preparedStatement.setString(6, PASSWORD);
          preparedStatement.setString(7, WORK_EMAIL);
          preparedStatement.setString(8, MOBILE_NO);
  
          // execute insert SQL stetement
          preparedStatement.executeUpdate();
  
          ResultSet rs = preparedStatement.getGeneratedKeys();
          if (rs.next()) {
              last_inserted_id = rs.getInt(1);
          }
  
          return last_inserted_id.toString();
  
      } catch (SQLException e) {
          return e.getMessage() + " ERROR CODE: " + e.getErrorCode();
      } finally {
          if (preparedStatement != null) {
              preparedStatement.close();
          }
          if (dbConnection != null) {
              dbConnection.close();
              dbConnection = null;
          }
      }
  }
  </code></pre>