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 Ja...@nexweb.org on 2008/01/16 22:24:23 UTC

How to pass Database connection dynamically

Hi,

I am using iBATIS 2.3.0. My SqlMapConfig.xml file looks like this

<transactionManager type="JDBC" commitRequired="false">
    <dataSource type="SIMPLE">
      <property name="JDBC.Driver" 
value="oracle.jdbc.driver.OracleDriver"/>
      <property name="JDBC.Class" 
value="oracle.jdbc.pool.OracleDataSource"/>
      <property name="JDBC.Location" value="jdbc/pool/OracleDS"/>
      <property name="JDBC.ConnectionURL" 
value="jdbc:oracle:thin:@dbHost:dbPort:dbSid"/>
      <property name="JDBC.Username" value="user"/>
      <property name="JDBC.Password" value="test"/>
    </dataSource>
  </transactionManager>


Now, I have a requirement to pass the database connection information at 
runtime. My project is Java Application and not a webproject, which runs 
from command line. I want to provide database connection information from 
command line, via some property file instead of hard coding in 
SqlMapConfig.xml file.

At this point I do not have any DAO coded. Its plain iBATIS.

How can I do that?

Thanks
Jasmin
******************************************************************************
ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION 
Our domain name is changing.  Please take note of the sender's
e-Mail address and make changes to your personal address list,
if needed.  Both domains will continue to work, only for a limited
time.
******************************************************************************
This email and any files transmitted with it are intended solely for 
the use of the individual or agency to whom they are addressed. 
If you have received this email in error please notify the Navy 
Exchange Service Command e-mail administrator. This footnote 
also confirms that this email message has been scanned for the
presence of computer viruses.

Thank You!            
******************************************************************************


Re: How to pass Database connection dynamically

Posted by Christopher Lamey <cl...@localmatters.com>.
Check out page 8 of the iBATIS PDF, specifically the properties element.

Cheers,
Chris

On 1/16/08 2:24 PM, "Jasmin_Mehta@nexweb.org" <Ja...@nexweb.org>
wrote:

> Hi,
> 
> I am using iBATIS 2.3.0. My SqlMapConfig.xml file looks like this
> 
> <transactionManager type="JDBC" commitRequired="false">
>     <dataSource type="SIMPLE">
>       <property name="JDBC.Driver"
> value="oracle.jdbc.driver.OracleDriver"/>
>       <property name="JDBC.Class"
> value="oracle.jdbc.pool.OracleDataSource"/>
>       <property name="JDBC.Location" value="jdbc/pool/OracleDS"/>
>       <property name="JDBC.ConnectionURL"
> value="jdbc:oracle:thin:@dbHost:dbPort:dbSid"/>
>       <property name="JDBC.Username" value="user"/>
>       <property name="JDBC.Password" value="test"/>
>     </dataSource>
>   </transactionManager>
> 
> 
> Now, I have a requirement to pass the database connection information at
> runtime. My project is Java Application and not a webproject, which runs
> from command line. I want to provide database connection information from
> command line, via some property file instead of hard coding in
> SqlMapConfig.xml file.
> 
> At this point I do not have any DAO coded. Its plain iBATIS.
> 
> How can I do that?
> 
> Thanks
> Jasmin
> ******************************************************************************
> ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
> Our domain name is changing.  Please take note of the sender's
> e-Mail address and make changes to your personal address list,
> if needed.  Both domains will continue to work, only for a limited
> time.
> ******************************************************************************
> This email and any files transmitted with it are intended solely for
> the use of the individual or agency to whom they are addressed.
> If you have received this email in error please notify the Navy
> Exchange Service Command e-mail administrator. This footnote
> also confirms that this email message has been scanned for the
> presence of computer viruses.
> 
> Thank You!       
> ******************************************************************************
>