iBatis 단독 사용 시 CLOB 넣기
<typeHandler javaType="string" jdbcType="CLOB" callback="test.OracleClobStringTypeHandler"/>
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="oracle.jdbc.driver.OracleDriver" />
<property name="JDBC.ConnectionURL" value="jdbc:oracle:thin:@xxxxx:1521:SID" />
<property name="JDBC.Username" value="${ID}" />
<property name="JDBC.Password" value="${PASS}" />
</dataSource>
</transactionManager>
logic-sqlmap.xml
INSERT INTO TABLE_NAME (
SEQ, TITLE, CONTENTS
)
VALUES(
#seq#, #title#, #contents:CLOB#
)
iBatis + Spring단독 사용 시 CLOB 넣기
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/jndiNameDS"/>
</bean>
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="WEB-INF/conf/sqlmap-config.xml" />
<property name="dataSource" ref="dataSource" />
<property name="lobHandler"><ref bean="oracleLobhandler"/></property>
</bean>
<bean id="nativeJdbcExtractor"
class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor"
lazy-init="true" />
<bean id="oracleLobhandler"
class="org.springframework.jdbc.support.lob.OracleLobHandler"
lazy-init="true">
<property name="nativeJdbcExtractor">
<ref local="nativeJdbcExtractor" />
</property>
</bean>
sqlmap-config.xml
<typeHandler
callback="org.springframework.orm.ibatis.support.ClobStringTypeHandler"
jdbcType="CLOB" javaType="java.lang.String" />
logic-sqlmap.xml
INSERT INTO TABLE_NAME (
SEQ, TITLE, CONTENTS
)
VALUES(
#seq#, #title#, #contents:CLOB#
)
java.lang.NullPointerException at org.springframework.jdbc.support.lob.OracleLobHandler.initOracleDriverClasses(OracleLobHandler.java:150
) 에러 발생 시
JNDI -> DBCP로 변경
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@xxxx:1521:SID" />
<property name="password" value="${PASS}" />
<parameter name="maxActive" value="20" />
<parameter name="maxIdle" value="5" />
<parameter name="maxWait" value="5000" />
<property name="validationQuery" value="SELECT 1 FROM DUAL" />
</bean>
Oracle JDBC 드라이버는 ojdbc14.jar (최신버전)으로 적용.
'자바 > iBatis' 카테고리의 다른 글
ibatis에서 서로 다른 sqlmap.xml 파일 간 참조 ID로 접근해야 될 경우 고려사항 (0) | 2011.11.04 |
---|---|
iBatis 사용시 ORA-01013 사용자가 요청을 취소했습니다 - 에러 해결 (0) | 2009.04.23 |
부적합한 열 유형 관련 에러 (0) | 2009.04.18 |
iBATIS BulkBeanException 예외에 대해서 .... (0) | 2008.06.11 |
iBatis 프로시져 호출 시 주의사항 (1) | 2008.03.31 |