HikariCP too many Connections with jooq
<p>When using jooq and HikariCP DataSource (Autowired) in a Spring Restful API i get the problem, that jooq is somehow not releasing the DataSource.</p>

<p>Some Code:</p>

<pre><code>@Autowired
private DataSource dataSource;
//Further down 
DSLContext create = DSL.using(dataSource, SQLDialect.MYSQL);
</code></pre>

<p>After using this repository/call two or three times i have too many connections open.</p>

<p>My dispatcher-servlet.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:security="http://www.springframework.org/schema/security"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security.xsd"&gt;

    &lt;context:component-scan base-package="com.rh" /&gt;

     &lt;bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
        &lt;property name="maxUploadSize" value="20971520"/&gt; &lt;!-- 20 MB --&gt;
    &lt;/bean&gt;

    &lt;context:property-placeholder location="classpath:database/database.properties"/&gt;

    &lt;bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"&gt;
        &lt;property name="dataSource" ref="dataSource"&gt;&lt;/property&gt;
    &lt;/bean&gt;

    &lt;bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig"&gt;
        &lt;property name="poolName" value="springHikariCP" /&gt;
        &lt;property name="connectionTestQuery" value="SELECT 1" /&gt;
        &lt;property name="dataSourceClassName" value="${jdbc.driver}" /&gt;
        &lt;property name="maximumPoolSize" value="20" /&gt;
        &lt;property name="idleTimeout" value="20" /&gt;

        &lt;property name="dataSourceProperties"&gt;
            &lt;props&gt;
                &lt;prop key="url"&gt;${jdbc.url}&lt;/prop&gt;
                &lt;prop key="user"&gt;${jdbc.username}&lt;/prop&gt;
                &lt;prop key="password"&gt;${jdbc.password}&lt;/prop&gt;
                &lt;prop key="prepStmtCacheSize"&gt;50&lt;/prop&gt;
                &lt;prop key="prepStmtCacheSqlLimit"&gt;50&lt;/prop&gt;
                &lt;prop key="cachePrepStmts"&gt;true&lt;/prop&gt;
                &lt;prop key="useServerPrepStmts"&gt;true&lt;/prop&gt;                
            &lt;/props&gt;
        &lt;/property&gt;
    &lt;/bean&gt;

    &lt;!-- HikariCP configuration --&gt;
    &lt;bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close"&gt;
        &lt;constructor-arg ref="hikariConfig" /&gt;
    &lt;/bean&gt; 

    &lt;bean id="passwordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"&gt;
        &lt;!--&lt;beans:constructor-arg value="256" /&gt;--&gt;
        &lt;!--&lt;beans:property name="iterations" value="1000" /&gt;--&gt;
    &lt;/bean&gt;  

    &lt;!--Different providers--&gt;
    &lt;bean id="cloudinaryProvider" class="com.rh.bean.CloudinaryProvider"&gt;&lt;/bean&gt;
    &lt;bean id="s3Provider" class="com.rh.bean.S3Provider"&gt;&lt;/bean&gt;    

    &lt;bean id="objectMapper" class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean" autowire="no"&gt;
        &lt;property name="propertyNamingStrategy" value="CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES" /&gt;
    &lt;/bean&gt;
    &lt;mvc:annotation-driven&gt;
        &lt;mvc:path-matching suffix-pattern="false" trailing-slash="false" /&gt;
        &lt;mvc:argument-resolvers&gt;
            &lt;bean class="com.rh.util.CurrentUserHandlerMethodArgumentResolver"/&gt;         
        &lt;/mvc:argument-resolvers&gt;        
        &lt;mvc:message-converters register-defaults="true"&gt;
            &lt;bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"&gt;
                &lt;property name="objectMapper"&gt;
                    &lt;ref bean="objectMapper" /&gt;
                &lt;/property&gt;
            &lt;/bean&gt;
        &lt;/mvc:message-converters&gt;
    &lt;/mvc:annotation-driven&gt; 

    &lt;security:global-method-security pre-post-annotations="enabled" secured-annotations="enabled"&gt;&lt;/security:global-method-security&gt; 
&lt;/beans&gt;
</code></pre>