hibernate - JAVA + Postgres Limit connections , how to close it ! FATAL: sorry, too many clients already -


i need release connection postgres

my java application interact postgres , problem when need call function more 200 time postgres crashes , normal thing ... because postgres have limited connections , script leave connection opened everytime execute.

@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 * "+settings.getdefaultschemaname()+".getextras_infos_for_source(:idsource)");         sqlquery query = this.getsession().createsqlquery(sql.tostring());         query.setinteger("idsource", idsource);         return (object[]) query.setmaxresults(1).uniqueresult();... 

can please tell me how close connection opened in postgres script avoid app crash everytime postgres connections on loaded.

according hibernate's javadocs can call .close() on session.

close()

end session releasing jdbc connection , cleaning up.

before returning query results: this.getsession().close();


Comments

Popular posts from this blog

smartface.io - Proper way to change color scheme for whole application -

javascript - three.js lot of meshes optimization -

Email notification in google apps script -