PDA

View Full Version : Managing EJB Connections...


ElPapa
Aug 16th, 2004, 10:49 AM
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...?

irbouho
Aug 16th, 2004, 11:48 AM
You do not need to worry about closing connections when using Spring Framework JDBC abstraction layer. In your case, JdbcTemplate will transparently call

DataSourceUtils.closeConnectionIfNecessary(con, getDataSource());

after each call to execute method.

ElPapa
Aug 16th, 2004, 12:24 PM
You do not need to worry about closing connections when using Spring Framework JDBC abstraction layer. In your case, JdbcTemplate will transparently call

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