IBatis 3 Configuration Example - JNDI

The iBatis frame has been significantly changed between versions 2 and 3, so even the configuration file (now often called MapperConfig.xml) is different.

There are many online examples of how to create a JDBC connection pool with iBatis, but I could not find one example of how to do this 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 relates to JNDI settings on page 19, but I still couldn’t get it correctly communicating with the database.

A working example of JDNI (container-connected pool) in iBatis 3 will be useful.

+3
source share
2 answers

Assuming you already have a JNDI database resource installed, the XML environment of the iBatis 3 configuration file (works on Tomcat) works for me:

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

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

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

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

+2
source

Source: https://habr.com/ru/post/1731893/


All Articles