Question

The iBatis framework has been significantly tweaked between versions 2 & 3, so much that even the config file (now often referred to as MapperConfig.xml) is different.

That being said, there are lots of examples online on how to create a JDBC connection pool with iBatis, but I couldn't find one example on how to do it with JNDI. There is an updated user guide at: http://svn.apache.org/repos/asf/ibatis/java/ibatis-3/trunk/doc/en/iBATIS-3-User-Guide.pdf which does refer to the JNDI settings on page 19, but I still couldn't it get it correctly communicate with the database.

A working example of a JDNI (container managed connection pool) in iBatis 3 would be greatly appreciated!!

Was it helpful?

Solution

Assuming you've already got a JNDI database resource set up, the following environment for iBatis 3's configuration XML file works for me (running on Tomcat):

<environment id="development">
    <transactionManager type="JDBC"/>
    <dataSource type="JNDI">
        <property name="data_source" value="java:comp/env/jdbc/webDb"/>
    </dataSource>
</environment>

OTHER TIPS

This is what I have in my config file, works well in Glassfish and WebSphere:

<dataSource type="JNDI">
     <property name ="data_source" value="jdbc/cpswebmon"/>
</dataSource>

"jdbc/cpswebmon" is the JNDI resource name on my application server

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top