ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kyohyoh Choh <C...@jp.ibm.com>
Subject How to set datasource thread save?
Date Sat, 21 Apr 2007 00:10:42 GMT




Hello all

Our application use Spring+iBATIS, need to switch among multiple
datasources based on user's request datasourceid parameter. We are testing
setDataSource() method of SqlMapClientDAOSupport class. We found if we set
our DAO class which extends SqlMapClientDAOSupport to be singleton
class(Spring's default value), the datasource can't set correctly when
users access concurrently. If we set singleton=false, everything goes will.
The user's datasourceid parameter is hold as thread local. Does this mean
SqlMapClientDAOSupport is not thread save? This is my first time to use
Spring+iBATIS, if I miss something, please forgive me and point out.

Sippete of our DAO class

            DataSource datasource = null;

            //get datasource from ApplicationContext
            datasource = (DataSource) ctx.getBean(datasourceID);

            //set datasource
            SqlMapClientTemplate sqlMapClientTem = null;
            sqlMapClientTem = getSqlMapClientTemplate();
            sqlMapClientTem.setDataSource(datasource);
            domain = sqlMapClientTem.queryForObject(selectID , inobj);

Thank you


Mime
View raw message