본문 바로가기

웹개발

[MyBatis/iBATIS] iBATIS기초 - JNDI설정

sqlMapClient.xml 설정파일에서

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMapConfig      
    PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"      
    "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">

<sqlMapConfig>
 
 <settings
  cacheModelsEnabled="true"
  enhancementEnabled="true"
  lazyLoadingEnabled="true"
  maxRequests="50"
  maxSessions="25"
  maxTransactions="10"
  useStatementNamespaces="false"
 />

 <!--Type aliases allow you to use a shorter name for long fully qualified class names. -->

 <typeAlias alias="order" type="testdomain.Order"/>

  <!-- Configure a built-in transaction manager.  If you're using an 
       app server, you probably want to use its transaction manager 
       and a managed datasource -->
  <transactionManager type="JDBC" commitRequired="false">
     <dataSource type="JNDI">
         <property name="DataSource" value="java:/comp/env/jdbc/DB"/>
     </dataSource> 
  </transactionManager>
  
  <!--sqlMap resource="C:\LuckyData\Project\Java1.5\data\ibatis\Member.xml"/-->
  <sqlMap resource="board/board.xml"/>
  <sqlMap resource="login/login.xml"/>  
  <sqlMap resource="db/dbChange.xml"/>
  <sqlMap resource="statics/static.xml"/>
  
  <!-- List more here...
  <sqlMap resource="com/mydomain/data/Order.xml"/>
  <sqlMap resource="com/mydomain/data/Documents.xml"/>
  -->

</sqlMapConfig>


빨간색 부분처럼 바꿔준다. JNDI 물론 톰캣 SERVER.XML에 설정이 되있어야 겠다.

SERVER.XML
<Context docBase="" path="" reloadable="true">
        <Resource name="jdbc/IMARC" auth="Container" type="javax.sql.DataSource"                
        driverClassName="oracle.jdbc.driver.OracleDriver" 
                             url="jdbc:oracle:thin:@XXX.XXX.XXX.X:XXX:XXXX" 
                  username="XXXX" password="XXXX maxActive="20" maxIdle="10" maxWait="10000" />
</Context>

각자설정에 알맞게 바꿔야겠죠?^^