10g XE에서 잘 돌아가던 넘이 운영서버 환경에 올리자 CLOB 등록이 안된다.
iBatis 단독 사용 시 CLOB 넣기
sqlmap-config.xml
<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 넣기
application-context.xml
<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
) 에러 발생 시
application-context.xml
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="username" value="${ID}" />
<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 (최신버전)으로 적용.