开发者社区> 问答> 正文

druid处理clob类型时报类型转换错误java.lang.ClassCast?报错

@wenshao 你好,想跟你请教个问题:

业务表其中有一个字段是clob类型,使用jdbcTemplate查询,返回结果集时报错:

java.lang.ClassCastException: com.alibaba.druid.proxy.jdbc.ClobProxyImpl cannot be cast to java.lang.String

PreparedStatementCallback; uncategorized SQLException for SQL [select * from  (select * from xxxwhere project_id = ? and log_time >=to_date(?,'yyyy-mm-dd hh24:mi:ss') and log_time <= to_date(?,'yyyy-mm-dd hh24:mi:ss') order by total_time desc)  where rownum <= ?]; SQL state [null]; error code [0]; Error

entity代码如下

...
	private String executedSql;
...
	@Lob 
	@Basic(fetch = FetchType.EAGER) 
	@Column(name="executedSql", columnDefinition="CLOB", nullable=true) 
	public String getExecutedSql() {
		return executedSql;
	}
...

展开
收起
爱吃鱼的程序员 2020-06-22 18:40:11 1245 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    把完整堆栈贴出来

    真心无堆栈啊

    2013-06-2714:20:17,332DEBUG[org.springframework.jdbc.core.JdbcTemplate]-ExecutingpreparedSQLstatement[selectfrom (selectfromaudit_sql_execute_logwhereproject_id=?andlog_time>=to_date(?,'yyyy-mm-ddhh24:mi:ss')andlog_time<=to_date(?,'yyyy-mm-ddhh24:mi:ss')orderbytotal_timedesc) whererownum<=?]

    2013-06-2714:20:20,324DEBUG[org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator]-UnabletotranslateSQLExceptionwithErrorcode'0',willnowtrythefallbacktranslator

    下面是debug截图

    <imgsrc="http://static.oschina.net/uploads/space/2013/0627/151313_7lyg_130302.png"alt=""/>

    已经找到问题。

    是我们自己写的一个filter的问题,做了个强制类型转换。

    结贴。

    2020-06-22 18:40:27
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载