出错背景:
页面进行刷新,把数据库中的数据以表格形式展示出来的过程,即显示
错误详情:
[DEBUG] [2018-12-18 11:43:49] com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:85) - Attempted to convert SQLException to SQLException. Leaving it alone. [SQLState: 99999; errorCode: 17004]
java.sql.SQLException: 无效的列类型: 1111
错误原因:
在**Mapper.xml中的sql代码写错,没有对传入参数进行判断,项目中传入的参数id可能为空
错误代码:
<select id="queryStatistic" resultType="java.util.Map"
parameterType="java.util.HashMap">
SELECT SUM(DATA_SIZE) collectionNum,
COUNT(BATCH_ID) collectionDispatch,
SUM(COLLECT_TIME) collectionDuration,
COUNT(COLLECT_CYC) collectionAlarm
FROM tableName1 t1, tableName2 t2
where t1.collect_id = t2.collect_id and t2.source_id = #{id}
</select>
解决方法:
对传入参数是否为空进行判断
<select id="queryStatistic" resultType="java.util.Map"
parameterType="java.util.HashMap">
SELECT SUM(DATA_SIZE) collectionNum,
COUNT(BATCH_ID) collectionDispatch,
SUM(COLLECT_TIME) collectionDuration,
COUNT(COLLECT_CYC) collectionAlarm
FROM tableName1 t1, tableName2 t2
where t1.collect_id = t2.collect_id
<if test="id !=null and id != ''">and t2.source_id = #{id}</if> //加上if条件
</select>