问题:
使用SpringMVC+MyBatis向oracle中更新数据,发生如下错误:
org.springframework.jdbc.UncategorizedSQLException: Error attempting to get column 'params' from result set. Cause: java.sql.SQLException: 无效的列类型: getCLOB not implemented for class oracle.jdbc.driver.T4CVarcharAccessor
; uncategorized SQLException for SQL []; SQL state [99999]; error code [17004]; 无效的列类型: getCLOB not implemented for class oracle.jdbc.driver.T4CVarcharAccessor; nested exception is java.sql.SQLException: 无效的列类型: getCLOB not implemented for class oracle.jdbc.driver.T4CVarcharAccessor
Mapper.xml文件
<update id="updateByExampleWithBLOBs" parameterType="map">
update t_case
set uuid = #{record.uuid,jdbcType=VARCHAR},
run = #{record.run,jdbcType=VARCHAR},
system = #{record.system,jdbcType=VARCHAR},
caseName = #{record.casename,jdbcType=VARCHAR},
url = #{record.url,jdbcType=VARCHAR},
type = #{record.type,jdbcType=VARCHAR},
header = #{record.header,jdbcType=VARCHAR},
checkpoint = #{record.checkpoint,jdbcType=VARCHAR},
correlation = #{record.correlation,jdbcType=VARCHAR},
params = #{record.params,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
解决方案:
查看generator自动生成的Mapper.xml文件中,某个字段的类型为jdbcType="LONGVARCHAR"。
可能是因为项目在公司使用的是mysql数据库该字段是longtext类型,然后回到家里切成了oracle该字段类型为varchar类型。所以将Mapper.xml文件中的所有LONGVARCHAR全部替换成VARCHAR。
重新启动tomcat服务,就Ok了。
网友评论