You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Giorgio Vespucci <gi...@gmail.com> on 2010/05/21 12:43:23 UTC

Dynamic DataSource

Hi everybody
We have the need to decide the referring datasource for some iBatis
DAO at login.
We are using Spring 3.0.2 with iBatis 2.x

We have some properties for the pool _luckily_ fixed, but the DBNAME.
Now the situation is as follow:
<from applicationContext.xml>

<bean id="dao" class="....SqlMapFlussoNauiDao"
   		scope="prototype"
   	>
        <property name="sqlMapClient" ref="sqlMap" />
        <property name="dataSource" ref="NOW_FIXED-datasource" />
    </bean>

<bean id="NOW_FIXED-datasource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
        <property name="driverClassName"
value="net.sourceforge.jtds.jdbc.Driver"/>
        <property name="url" value="jdbc:jtds:sqlserver://HOST:PORT/DBNAME"/>
        <property name="username" value="USERNAME"/>
        <property name="password" value="PASSWORD"/>
        <property name="maxActive" value="30"/>
        <property name="maxIdle" value="10"/>
        <property name="maxWait" value="1000"/>
        <property name="defaultAutoCommit" value="true"/>
</bean>

The varying part is the DBNAME, because each user of the webapp
belongs to a group that see the same database

Each logged user must use the DAO pointing to its particular DBNAME on
the same SQLServer HOST:PORT

I googled the Spring UserCredentialsDataSourceAdapter.

Someone faced with same problem and fixed it?
Thanks to all

P.S. Maybe is a question for Spring user list, but I started from here
because we're using iBatis ;)
-- 
Giorgio Vespucci
giorgio [dot] vespucci [at] gmail [dot] com
Skype, Twitter, Slideshare: gvespucci
Linux User #471792
http://xpermanwalking.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org