开发者

iBatis 3 - JNDI configuration example

开发者 https://www.devze.com 2022-12-19 18:38 出处:网络
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.

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, bu开发者_如何转开发t 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!!


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>


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

0

精彩评论

暂无评论...
验证码 换一张
取 消