I believe you should use java.sql.PreparedStatement#setNull(int, int,
java.lang.String)
As far as I understand, current implementation ignores typename argument:
https://github.com/pgjdbc/pgjdbc/blob/REL42.2.2/pgjdbc/src/main/java/org/postgresql/jdbc/PgPreparedStatement.java#L1240-L1242
however one can file an issue and/or PR to fix that.
Vladimir