/**
   * Add product to database -Admin code change-Aparna 08/23
   *
   * @throws SQLException
   */
  @Override
  public void addProduct(ProductModel product) throws SQLException {

    PreparedStatement statement = null;
    Connection connection = databaseFactory.getConnection();

    try {
      statement =
          connection.prepareStatement(
              "insert into product(ProductID,ProductName,Category,Price) values(?,?,?,?) ");
      statement.setLong(1, product.getProductId());
      statement.setString(2, product.getProductName());
      statement.setString(3, product.getCategory().toString());
      statement.setDouble(4, product.getProductPrice());

      int rs = statement.executeUpdate();

    } catch (SQLException e) {
      e.printStackTrace();
      throw e;
    } finally {
      DBUtils.closeStatement(statement);
      databaseFactory.closeConnection();
    }
  }
  @Override
  public void updateProduct(ProductModel productModel, long productId) throws SQLException {
    PreparedStatement statement = null;
    Connection connection = databaseFactory.getConnection();

    try {
      statement =
          connection.prepareStatement(
              "update product set ProductName = ?,Category = ?,Price = ? where ProductID = ?");

      statement.setString(1, productModel.getProductName());
      statement.setString(2, productModel.getCategory().toString());
      statement.setDouble(3, productModel.getProductPrice());
      statement.setLong(4, productId);

      int rs = statement.executeUpdate();

    } catch (SQLException e) {
      e.printStackTrace();
      throw e;
    } finally {
      DBUtils.closeStatement(statement);
      databaseFactory.closeConnection();
    }
  }