ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Lamey <cla...@localmatters.com>
Subject Re: Need a custom way for sqlMapConfig.xml to get JDBC properties
Date Wed, 22 Nov 2006 20:48:21 GMT
Just a suggestion:  You could configure iBATIS to use JNDI and then
either use your container's JNDI provider or use a standalone one.

I'd also ask if the cost of writing your own iBATIS properties loading
code is cheaper than copying the right properties file into the right
CLASSPATH.  That doesn't seem like a good use of developer time to me
and not fun to maintain, especially if the iBATIS guys change things out
from under you.  Most environments manage their differences by copying
around the same war/ear/jar and then some kind of external
configuration.

Another idea would be to use Spring, which has all kinds of ways to do
this stuff.

On Wed, 2006-11-22 at 15:09 -0500, Hycel Taylor wrote:
> In our environment, we are currently using iBatis in three separate
> databases.  We deploy to four environments, dev, staging, and two
> production environments.  For security reasons, the database user
> names and passwords are different in each environment.  Deploying jars
> that use iBatis is cumbersome because the sqlMapConfig.xml has to live
> in the jar and the properties file which the sqlMapConfig references
> must also exist within the class path.
> 
> Example:
> 
> <sqlMapConfig>
>   <properties resource="config/feeddb/ibatis/feeddb.properties"/>
> 
>   <transactionManager type="JDBC">
>     <dataSource type="DBCP">
>       <property name="JDBC.Driver" value="${db.connectionDriver}"/>
>       <property name="JDBC.ConnectionURL" value="${db.connectionURL}"/>
>       <property name="JDBC.Username" value="${db.connectionUserName}"/>
>       <property name="JDBC.Password" value="${db.connectionPassword}"/>
>       <property name="JDBC.DefaultAutoCommit" value="false"/>
>       <property name="Pool.MaximumActiveConnection" value="10"/>
>       <property name="Pool.MaximumIdleConnections" value="5"/>
>       <property name="Pool.MaximumCheckoutTime" value="60000"/>
>       <property name="Pool.TimeToWait" value=""/>
>     </dataSource>
>   </transactionManager>
> …
> 
> I've been given the mandate to "Change all configuration files used by
> iBatis to be read from one central place".   In order to meet this
> goal, I need to modify, hopefully, only a few iBatis java classes that
> would use the interface, shown below, to in order to retrieve JDBC
> property parameters.
> 
> public interface CustomResource {
>   public String getConnectionDriver();
>   public String getConnectionURL();
>   public String getConnectionUserName();
>   public String getConnectionPassword();
> }
> 
> I could then write a concrete class that implements CustomResource to
> retrieve JDBC resource information anyway I want.  There are a few
> more things that I need to hammer out in order to implement this.
> 
> 1) What iBatis class or classes would I need to modify to use the
> CustomResource intereface?
> 
> 2) In sqlMapConfig.xml I would also need to define a property to
> specify the use of the custom class.
> 
> Example: <property
> customResource="com.test.app.feeddb.dataAccess.ibatis.CustomResourceImpl"/>
> 
> Now, it seems that I may have to modify some more iBatis classes and
> the DTD to make this possible.
> 
> I would appreciate any advice, suggestions or other possible solutions
> to resolve this issue.
> 
> Thank you,
> 
> Hycel Taylor
> Principal Architect
> 80108 Media

Mime
View raw message