ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mitchell, Steven C" <Steven.Mitch...@umb.com>
Subject RE: loading properties from other source
Date Thu, 07 Jul 2005 14:01:19 GMT
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 =
IG, cmSqlMap);
        String daoConfig =
            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}" />

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

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?

Michal Malecki

View raw message