Announcement Announcement Module
Collapse
No announcement yet.
Managing EJB Connections... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Managing EJB Connections...

    So, normally in SLSB when I get a connection from the Connection Pool I do something like this:

    Context ctx=new InitialContext();
    Datasource ds = (Datasource) ctx.lookup("java:comp/env/jdbc/blah");
    Connection con = ds.getConnection();

    But in Spring, I hand the datasource off to my classes that extend the Spring StoredProcedure. My question is, when processing is done, how do I go about calling Connection.close()? Or is this something that Spring will work about for me automatically...?

  • #2
    You do not need to worry about closing connections when using Spring Framework JDBC abstraction layer. In your case, JdbcTemplate will transparently call
    Code:
      DataSourceUtils.closeConnectionIfNecessary(con, getDataSource());
    after each call to execute method.

    Comment


    • #3
      Originally posted by irbouho
      You do not need to worry about closing connections when using Spring Framework JDBC abstraction layer. In your case, JdbcTemplate will transparently call
      Code:
        DataSourceUtils.closeConnectionIfNecessary(con, getDataSource());
      after each call to execute method.
      Irbouho,

      That's what I thought, it just wasn't jumping out at me in the sourcecode.

      Thanks much...!!

      Comment

      Working...
      X