Bowner 2009-08-08 14:07
浏览 526
已采纳

Spring框架里面将jdbcTemplate注入Controller里面,JDBC连接会不会自动关闭?

因为业务原因,需要在Controller里面直接用到ResultSet.

在Controller里面是这样用的:


private JdbcTemplate jdbcTemplate = null;
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}

public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
...
this.jdbcTemplate.query(sql, new ResultSetExtractor() {
public Object extractData(ResultSet rs) throws SQLException {
...
}
...
}


不知道这样用完后这个JDBC会不会释放掉?
  • 写回答

1条回答 默认 最新

  • ghost1000 2009-08-08 14:30
    关注

    [url]http://fengpeng.iteye.com/blog/93897[/url]

    这个文章看一下就知道了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?