ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: Dynamically passing username/password while create JDBC connection in buildDaoManager
Date Mon, 24 Jul 2006 15:23:47 GMT
Are there placeholders for the user/password in the dao.xml?

Larry


On 7/24/06, Christina Xu <christxu@yahoo.com> wrote:
> Hello All,
>
> I have a requirement to Dynamic set username/password
> when create JDBC connection. So what I have is :
>
> <sqlmapConfig>
>    <properties resource="dataSourse.properties" />
>    <transactionManager type="JDBC" >
>       <dataSource type="SIMPLE" >
>       <property name="JDBC.Driver" value="${driver}"
> />
>       <property name="JDBC.ConnectionURL"
> value="${url}" />
>       <property name="JDBC.DefaultAutoCommit"
> value="false" />
>       ...
>       ...
>     </dataSource>
>    </transactionManager>
> ...
> ...
> </sqlMapConfig>
>
> In java,
>
> public void loadDaoManager(String username, String
> password) {
>
> String dbSource="dao.xml"
> Properties daoProp = new Properties();
> daoProp.put("JDBC.username", username);
> daoProp.put("JDBC.password", password);
>
> Reader reader =
> Resources.getResourceAsReader(dbSource);
> daoManager =
> DaoManagerBuilder.buildDaoManager(reader.daoProp);
> ...
> ...
>
> }
>
> When I run this, I got Error
> "com.ibatis.common.exception.NestedRuntimeException:
> SimpleDataSource: Some properties were not set."
>
> My question is is it possible to Dynamic give
> username/password in the properties instead hardcode
> in .xml file? If yes, can someone give me direction on
> how? Thanks a lot.
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>

Mime
View raw message