ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michal Malecki" <misie...@poczta.onet.pl>
Subject Re: loading properties from other source
Date Thu, 07 Jul 2005 14:15:53 GMT
Wow, thanks
I didn't noticed the seconds constructor -
SqlMapClientBuilder.buildSqlMapClient(reader,prop);
ibatis is really great tool :)

Regards
Michal Malecki
PSNC
----- Original Message ----- 
From: "Mitchell, Steven C" <Steven.Mitchell@umb.com>
To: <user-java@ibatis.apache.org>
Sent: Thursday, July 07, 2005 4:01 PM
Subject: RE: loading properties from other source


You can do something like what I've shown below.  Here I am overriding
the location of the SQL MAP to support multiple databases, but you could
supply ID, password, etc too.

private static DaoManager getDaoManager() throws IOException
    {
        Properties properties = ConfigurationManager.getProperties();
        String cmSqlMap =
properties.getProperty("cm.libt.ibatis.mapping.config");

properties.setProperty(ConfigurationManager.PROPERTY_IBATIS_MAPPING_CONF
IG, cmSqlMap);
        String daoConfig =
ConfigurationManager.getResourceBundle().getString(
            ConfigurationManager.PROPERTY_IBATIS_DAO_CONFIG );
        Reader reader = Resources.getResourceAsReader( daoConfig );
        return DaoManagerBuilder.buildDaoManager( reader, properties);
    }

This assumes that you use parameterized values in your sql map.

<transactionManager type="JDBC">
 <dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${connection.driver.class}" />
<property name="JDBC.ConnectionURL" value="${cm.libt.connection.url}" />
<property name="JDBC.Username" value="${cm.libt.connection.user}" />
<property name="JDBC.Password" value="${cm.libt.connection.password}" />
</dataSource>
</transactionManager>

Steve Mitchell

-----Original Message-----
From: Michal Malecki [mailto:misiek_x@poczta.onet.pl]
Sent: Thursday, July 07, 2005 8:48 AM
To: user-java@ibatis.apache.org
Subject: loading properties from other source


Hello,
I'm trying to convinced my friends to port our system to ibatis
DataMapper. Unfortunatelly our config files must remain untouched, and
this means we must load db parameters (url, username, password, driver)
from web.xml. Is it possible to create properties in the runtime, feed
them with parameters from web.xml, and make ibatis use that properties?

Thanks!
Michal Malecki




Mime
View raw message