title: Enable PostgreSQL extensions in JDBC
body: <p>I am using Spring + Tomcat8 together with PostgreSQL 9.2.
  I installed the <a href="http://www.postgresql.org/docs/9.1/static/pgtrgm.html" rel="noreferrer">Trigram</a> extension on the database for improved searching in tables.</p>
  
  <p>When I connect to my database manually, the following statement works:</p>
  
  <pre><code>SELECT id, name, similarity(name, 'a') FROM dev.customer WHERE name % 'a' ORDER BY similarity ;
  </code></pre>
  
  <p>However, when I try this in Spring using <code>jdbcTemplate.query()</code> I get an error:</p>
  
  <pre><code>PSQLException: ERROR: function similarity(character varying, character varying) does not exist
  </code></pre>
  
  <p>When I remove the <code>similarity()</code> function and only use the <code>%</code> operator, I get the following exception:</p>
  
  <pre><code>ERROR: operator does not exist: character varying % character varying
  </code></pre>
  
  <p>It seems that the postgres jdbc driver needs to be configured in order to support non-standard syntax: <a href="https://jdbc.postgresql.org/documentation/81/ext.html" rel="noreferrer">https://jdbc.postgresql.org/documentation/81/ext.html</a></p>
  
  <p>The <code>server.xml</code> of my tomcat installation contains the following resource:</p>
  
  <pre><code>&lt;Resource name="jdbc/NasPostgresDB" auth="Container" type="javax.sql.DataSource"
            username="usr" password="pwd"
            url="jdbc:postgresql://127.0.0.1/dbname"
            driverClassName="org.postgresql.Driver"
            initialSize="5" maxWait="5000"
            maxActive="120" maxIdle="5"
            validationQuery="select 1"
            poolPreparedStatements="true"/&gt;
  </code></pre>
  
  <p>which should be correct: <a href="https://jdbc.postgresql.org/documentation/81/load.html" rel="noreferrer">https://jdbc.postgresql.org/documentation/81/load.html</a></p>
  
  <p>What exacly do I need to do to make trigram matching working?</p>