El if tambien se podría poner en la query:
String query = """
INSERT INTO public.users (id, first_name, last_name, email, last_connection, country, website, username, followers, following)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT (id) DO UPDATE SET
first_name = EXCLUDED.first_name,
last_name = EXCLUDED.last_name,
email = EXCLUDED.email,
last_connection = EXCLUDED.last_connection,
country = EXCLUDED.country,
website = EXCLUDED.website,
username = EXCLUDED.username,
followers = EXCLUDED.followers,
following = EXCLUDED.following;
""";