在使用ibatis查询数据时,出现如下错误:
org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation;
uncategorized SQLException for SQL []; SQL state [null]; error code [0];
--- The error occurred in maps/read/xxxxx.xml.
--- The error occurred while applying a result map.
--- Check the xxxx.xxxxResult.
--- Check the result mapping for the 'updateTime' property.
--- Cause: com.ibatis.sqlmap.client.SqlMapException: No type handler could be found to
map the property 'updateTime' to the column 'updateTime'. One or both of the types,
or the combination of types is not supported.
1.起初,以为是属性拼写错误,经过检查拼写没有问题,是一致的。
2.然后,怀疑是Bean中定义的updateTime类型与数据库中字段的类型不一致,经过检查都是Timestamp。
3.最后,还是觉得是类型问题,于是再次仔细检查,终于发现问题所在。Bean中定义的updateTime类型确实是时间戳,担不是Timestamp,而是TimeStamp。TimeStamp是org.apache.commons.net.ntp.TimeStamp,而Timestamp是java.sql.Timestamp。显然应该使用Timestamp而不是TimeStamp。
总结:要细心、细心、细心。。。