Results 1 to 3 of 3

Thread: Managing EJB Connections...

  1. #1
    Join Date
    Aug 2004
    Location
    Tacoma, WA USA
    Posts
    49

    Default 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...?
    ElPapa

    The delusion that people care about what I think:
    http://www.codethought.com/blog

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    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.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Aug 2004
    Location
    Tacoma, WA USA
    Posts
    49

    Default

    Quote 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...!!
    ElPapa

    The delusion that people care about what I think:
    http://www.codethought.com/blog

Similar Threads

  1. Replies: 4
    Last Post: Nov 12th, 2008, 09:14 AM
  2. Replies: 5
    Last Post: Oct 13th, 2005, 06:17 AM
  3. MBeanExporter and DataSource Opening Connections?
    By sethladd in forum Management
    Replies: 2
    Last Post: Aug 28th, 2005, 03:23 PM
  4. Replies: 1
    Last Post: Nov 17th, 2004, 08:21 AM
  5. Replies: 2
    Last Post: Sep 10th, 2004, 09:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •