IBatis | Configuring xml file as data source in ibatis
If you are using Tomcat, you can configure the DataSource in the config.xml file and have the following definition in your iBatis xb config, where comp / env / jdbc / db is your jndi definition in Tomcat.
<bean id="JndiDatasource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/db"/>
<property name="resourceRef" value="true" />
</bean>
If it's a standalone app:
<bean id="jdbc.DataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
<property name="initialSize" value="${jdbc.initialSize}"/>
<property name="maxActive" value="${jdbc.maxActive}"/>
<property name="minIdle" value="${jdbc.minIdle}"/>
<property name="password" value="${jdbc.dbpassword}"/>
<property name="url" value="${jdbc.dburl}"/>
<property name="username" value="${jdbc.dbuser}"/>
<property name="accessToUnderlyingConnectionAllowed" value="true"/>
</bean>
source to share
You can use JndiDataSourceFactory .. this is what I got from the IBATIS documentation:
JndiDataSourceFactory - This implementation will retrieve the DataSource implementation from the JNDI context from within the application container. This is typically used when an application server is in use and a managed pool container and associated DataSource implementation. the standard way to access a JDBC DataSource implementation is through the JNDI context. JndiDataSourceFactory provides functionality for accessing DataSource data through JNDI. the configuration options that must be specified in the data source lines are:
I used Spring to configure IBATIS with a specific AppServer datasource, the Spring framework has nice integration with IBATIS. take a look at org.springframework.orm.ibatis.SqlMapClientFactoryBean to do this.
source to share
If you are looking for a complete (working) example, then http://ganeshtiwaridotcomdotnp.blogspot.com/2011/05/tutorial-on-ibatis-using-eclipse-ibator_31.html can help you.
This article contains all the configuration settings for ibatis with the ibator plugin and examples of working examples with downloadable code.
source to share