@Override
  public void execute() {
    Connection dbConn = null;
    CallableStatement proc = null;
    try {
      dbConn = PostgresConnection.getDataSource().getConnection();
      dbConn.setAutoCommit(true);
      proc = dbConn.prepareCall("{call create_list(?,?,?,?,now()::timestamp)}");
      proc.setPoolable(true);

      proc.setString(1, map.get("name"));
      proc.setString(2, map.get("description"));
      proc.setInt(3, Integer.parseInt(map.get("creator_id")));
      proc.setBoolean(4, Boolean.parseBoolean(map.get("private")));
      proc.execute();

      MyObjectMapper mapper = new MyObjectMapper();
      JsonNodeFactory nf = JsonNodeFactory.instance;
      ObjectNode root = nf.objectNode();
      root.put("app", map.get("app"));
      root.put("method", map.get("method"));
      root.put("status", "ok");
      root.put("code", "200");
      try {
        CommandsHelp.submit(
            map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"), LOGGER);
      } catch (JsonGenerationException e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
      } catch (JsonMappingException e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
      } catch (IOException e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
      }
    } catch (PSQLException e) {
      if (e.getMessage().contains("unique constraint")) {
        if (e.getMessage().contains("(name)")) {
          CommandsHelp.handleError(
              map.get("app"),
              map.get("method"),
              "List name already exists",
              map.get("correlation_id"),
              LOGGER);
        }
      }
      if (e.getMessage().contains("value too long")) {
        CommandsHelp.handleError(
            map.get("app"), map.get("method"), "Too long input", map.get("correlation_id"), LOGGER);
      }
      CommandsHelp.handleError(
          map.get("app"),
          map.get("method"),
          "List name already exists",
          map.get("correlation_id"),
          LOGGER);
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
    } catch (SQLException e) {
      CommandsHelp.handleError(
          map.get("app"),
          map.get("method"),
          "List name already exists",
          map.get("correlation_id"),
          LOGGER);
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
    } finally {
      PostgresConnection.disconnect(null, proc, dbConn);
    }
  }
  @Override
  public void execute() {
    Connection dbConn = null;
    CallableStatement proc = null;
    try {
      dbConn = PostgresConnection.getDataSource().getConnection();
      dbConn.setAutoCommit(true);
      if (map.containsKey("image_url")) {
        proc = dbConn.prepareCall("{? = call create_dm(?,?,?,now()::timestamp,?))}");

      } else {
        proc = dbConn.prepareCall("{? = call create_dm(?,?,?,now()::timestamp)}");
      }

      proc.setPoolable(true);
      proc.registerOutParameter(1, Types.BOOLEAN);
      proc.setInt(2, Integer.parseInt(map.get("sender_id")));
      proc.setInt(3, Integer.parseInt(map.get("reciever_id")));
      proc.setString(4, map.get("dm_text"));
      if (map.containsKey("image_url")) {
        proc.setString(5, map.get("image_url"));
      }
      proc.execute();

      boolean sent = proc.getBoolean(1);

      if (sent) {
        MyObjectMapper mapper = new MyObjectMapper();
        JsonNodeFactory nf = JsonNodeFactory.instance;
        ObjectNode root = nf.objectNode();
        root.put("app", map.get("app"));
        root.put("method", map.get("method"));
        root.put("status", "ok");
        root.put("code", "200");
        try {
          CommandsHelp.submit(
              map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"), LOGGER);
        } catch (JsonGenerationException e) {
          LOGGER.log(Level.SEVERE, e.getMessage(), e);
        } catch (JsonMappingException e) {
          LOGGER.log(Level.SEVERE, e.getMessage(), e);
        } catch (IOException e) {
          LOGGER.log(Level.SEVERE, e.getMessage(), e);
        }
      } else {
        CommandsHelp.handleError(
            map.get("app"),
            map.get("method"),
            "You can not dm a user who is not following you",
            map.get("correlation_id"),
            LOGGER);
      }

    } catch (PSQLException e) {
      if (e.getMessage().contains("value too long")) {
        CommandsHelp.handleError(
            map.get("app"),
            map.get("method"),
            "DM length cannot exceed 140 character",
            map.get("correlation_id"),
            LOGGER);
      } else {
        CommandsHelp.handleError(
            map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"), LOGGER);
      }

      LOGGER.log(Level.SEVERE, e.getMessage(), e);
    } catch (SQLException e) {
      CommandsHelp.handleError(
          map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"), LOGGER);
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
    } finally {
      PostgresConnection.disconnect(null, proc, dbConn);
    }
  }
  @Override
  public void execute() {
    Connection dbConn = null;
    CallableStatement proc = null;
    ResultSet set = null;
    try {
      dbConn = PostgresConnection.getDataSource().getConnection();
      dbConn.setAutoCommit(false);
      proc = dbConn.prepareCall("{? = call get_user_favorites(?)}");
      proc.setPoolable(true);
      proc.registerOutParameter(1, Types.OTHER);
      proc.setInt(2, Integer.parseInt(map.get("user_id")));
      proc.execute();

      set = (ResultSet) proc.getObject(1);

      MyObjectMapper mapper = new MyObjectMapper();
      JsonNodeFactory nf = JsonNodeFactory.instance;
      ObjectNode root = nf.objectNode();
      ArrayNode tweets = nf.arrayNode();
      root.put("app", map.get("app"));
      root.put("method", map.get("method"));
      root.put("status", "ok");
      root.put("code", "200");

      while (set.next()) {
        Integer id = set.getInt(1);
        String tweet = set.getString(2);
        String image_url = set.getString(3);
        Timestamp created_at = set.getTimestamp(4);
        String creator_name = set.getString(5);
        String creator_username = set.getString(6);
        String creator_avatar = set.getString(7);

        Tweet t = new Tweet();
        t.setId(id);
        t.setTweetText(tweet);
        t.setImageUrl(image_url);
        t.setCreatedAt(created_at);
        User creator = new User();
        creator.setName(creator_name);
        creator.setAvatarUrl(creator_avatar);
        creator.setUsername(creator_username);
        t.setCreator(creator);

        tweets.addPOJO(t);
      }

      root.put("favorites", tweets);
      try {
        CommandsHelp.submit(
            map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"), LOGGER);
      } catch (JsonGenerationException e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
      } catch (JsonMappingException e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
      } catch (IOException e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
      }

      dbConn.commit();
    } catch (PSQLException e) {
      CommandsHelp.handleError(
          map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"), LOGGER);
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
    } catch (SQLException e) {
      CommandsHelp.handleError(
          map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"), LOGGER);
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
    } finally {
      PostgresConnection.disconnect(set, proc, dbConn);
    }
  }