JdbcTemplate connection close
Bonjour,
J'utilise dans mes web services Spring, avec jdbcTemplate et BoneCP.
Petite question simple : après chaque requête (comme ci dessous), dois-je effectuer une fermeture de connexion du jdbcTemplate comme ceci :
Code:
this.jdbcTemplate.getDataSource().getConnection().close();
Exemple de requête :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| public int getProposalByAnnounce(long announceId) {
int result = 0;
try {
int exists = this.jdbcTemplate
.queryForInt("SELECT COUNT(*) FROM notification WHERE (action LIKE '2%' "
+ "OR action LIKE '3%') AND complement LIKE '"
+ String.valueOf(announceId) + "%'");
if (exists > 0) {
result = exists;
}
this.jdbcTemplate.getDataSource().getConnection().close();
} catch (SQLException e) {
// TODO Auto-generated catch block
return 0;
}
return result;
} |
D'avance merci
Vincent