iBatis 3 - JNDI configuration example

17,703

Solution 1

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>

Solution 2

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

Share:
17,703
Stephane Grenier
Author by

Stephane Grenier

Author of the book Blog Blazers. Blog author of FollowSteph.com Founder of LandlordMax Property Management Software

Updated on June 04, 2022

Comments

  • Stephane Grenier
    Stephane Grenier almost 2 years

    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!!

  • Stephane Grenier
    Stephane Grenier about 14 years
    that's exactly what I did too but with no success. What I eventually found out is there there's some specific "weblogic'ness" that needs to be done above this to make it work.
  • Stephane Grenier
    Stephane Grenier about 14 years
    It appears to have to do with the classpath. Basically you have to set weblogic to load your webapps librairies (jars) before weblogic's own.