ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: Connections
Date Fri, 07 Jan 2005 05:15:06 GMT
When it comes to connection pools, it's the responsibility of each
pool to ensure that their connections are closed.  iBATIS can't do
much in this regard. I suggest you enforce a manual shutdown policy
for your datasources, as simply shutting down a JVM (i.e. service)
won't cut it.

If you're using iBATIS SimpleDataSource, you can call .forceCloseAll()
to release all Connection resources.  For any other DataSource
implementation, you'll need to check the docs (it's non-standard
behavior).

Cheers,
Clinton


On Fri, 07 Jan 2005 10:24:52 +0530, Vamsee Kanakala <vamlists@gmail.com> wrote:
> Carl Brodeur wrote:
> 
> >Would like to know how Ibatis releases or close its connections.  I use
> >a JNDI datasource type (connection pool).  I look at the debug trace,
> >see when connection are requested but not when they are released.
> >
> >
> >
> I have a similar problem. I am using sqlmaps only, and I'm getting the
> datasource connection from the container itself, like this:
> 
> public class BatsSqlConfig {
>     private static final SqlMapClient sqlMap;
> 
>     static {
>         try {
>             String resource = "com/mafoi/bats/sql-map-config.xml";
>             Reader reader = Resources.getResourceAsReader(resource);
>             sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
>         } catch (Exception e){
>             e.printStackTrace();
>             throw new RuntimeException("Init error: BatsSqlConfig class.
> cause: " + e);
>         }
>     }
> 
>     public static SqlMapClient getSqlMapInstance() {
>         return sqlMap;
>     }
> }
> 
> And, I'm using the code like this:
> 
> public class LoginBean {
> 
>     SqlMapClient sqlMap;
> 
>     public LoginBean() {
>         sqlMap = BatsSqlConfig.getSqlMapInstance();
>     }
> 
>     public User getUser(String userName, String password) throws
> SQLException {
> 
>         return (User)sqlMap.queryForObject("getUser",
> userName);
>     }
> }
> 
> But, I'm using Tomcat Ant tasks to stop and start the container. I get
> the feeling that the connections are not closed, because 2 developer
> machines (linux) just hung after doing a few start/stops of the
> application inside Tomcat. It never happened before, while we used to
> shutdown tomcat fully before deploying the application again. How can I
> make sure that the PoolableConnection objects are actually released
> before I restart the application in Tomcat?
> 
> TIA,
> Vamsee.
>

Mime
View raw message