title: PostgreSQL/JDBC - How do I prepare-call a function with parameter CITEXT (TEXT)?
body: <p>I created a table with a <code>CITEXT</code> column, <code>CITEXT</code> (case-insensitive version of <code>TEXT</code>) being an extension I previously loaded using <code>CREATE EXTENSION citext;</code></p>
  
  <pre><code>CREATE TABLE artists (
      artist_id   SERIAL   PRIMARY KEY,
      artist      CITEXT   UNIQUE NOT NULL
  );
  
  CREATE OR REPLACE FUNCTION add_artist(_artist CITEXT) RETURNS INTEGER AS $$
      DECLARE
          _artist_id INT;
      BEGIN
          SELECT artist_id INTO _artist_id FROM artists WHERE artist = _artist;
  
          IF (_artist_id IS NULL) THEN
              INSERT INTO artists (artist) VALUES (
                  _artist
              ) RETURNING artist_id INTO _artist_id;
          END IF;
  
          RETURN _artist_id;
      END;
  $$ LANGUAGE plpgsql;
  </code></pre>
  
  <p>Now I am trying to call the function in java using</p>
  
  <pre><code>public int addArtist(String name) throws SQLException {
      int artist_id;
  
      try (CallableStatement callableStatement = 
              connection.prepareCall("{ ? = CALL add_artist(?) }")) {
          callableStatement.registerOutParameter(1, Types.INTEGER);
          callableStatement.setString(2, name);
          callableStatement.execute();
          artist_id = callableStatement.getInt(1);
      }
  
      return (artist_id != 0) ? artist_id : -1;
  }
  </code></pre>
  
  <p>The same method in calling functions works fine if the argument passed to the sql function is type of <code>INTEGER</code> or <code>VARCHAR(n)</code>.</p>
  
  <p>I assume <code>callableStatement.setString(2, name);</code> is throwing the <code>SQLException</code> because <code>setString()</code> is to be be used for VARCHAR(n) fields?</p>
  
  <pre><code>org.postgresql.util.PSQLException: ERROR: function add_artist(character varying) does not exist
    Hint: No function matches the given name and argument types. You might need to add explicit type casts.
    Position: 15
  at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2182)
  at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1911)
  at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:173)
  at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:615)
  at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:465)
  at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:458)
  at postgresql.PostgreSQL.addArtist(PostgreSQL.java:61)
  at postgresql.PostgreSQLConnector.main(PostgreSQLConnector.java:26)
  </code></pre>
  
  <p><code>CallableStatement</code> has no methods like <code>setText(int i, String text)</code> - What must I use instead?</p>