title: JAVA + Postgres Limit connections , how to close it ! FATAL: sorry, too many clients already
body: <p>I need to release connection to postgres</p>
  
  <p>My java application interact with postgres and my problem is when i need to call this function more than 200 time postgres crashes , normal thing ... because postgres have limited connections and this script leave a connection opened everytime it execute.</p>
  
  <pre><code>@Override
      public Object[] getExtrasInfosSource(int idSource) {
      StringBuffer sql = new StringBuffer();
          final SessionFactoryImplementor sfi = (SessionFactoryImplementor) getSessionFactory();
          final Settings settings = sfi.getSettings();
          // Appel du procedure stocké "getExtrasInfosForSource(idSource integer)" au niveau de bd
          sql.append("SELECT * from "+settings.getDefaultSchemaName()+".getExtras_Infos_For_Source(:idSource)");
          SQLQuery query = this.getSession().createSQLQuery(sql.toString());
          query.setInteger("idSource", idSource);
          return (Object[]) query.setMaxResults(1).uniqueResult();...
  </code></pre>
  
  <p>Can you please tell me how to close the connection opened in postgres from this script to avoid the app crash everytime postgres connections is over loaded.</p>