java.lang.ClassCastException: oracle.sql.CLOB cannot be cast to oracle.sql.CLOB

左心房为你撑大大i 提交于 2019-12-04 09:55:31

I fixed the problem. Posting this answer, hoping it might be useful to someone.

When I was checking the instance type of the CLOB retrieved by the query, it came up as oracle.sql.CLOB. So I assumed it must have been a version mismatch of ojdbc.jar. I checked my project a gazillion times for multiple copies of the ojdb.jar. There were none.

Finally it turned out to be a clash between hibernate and ojdbc. I changed the reference to java.sql.Clob. Hibernate uses java.sql.Clob. This resolved the problem.

In my situation i m not using Hibernate but i use Jboss like container and i had to remove the module of oracle from the jboss-deployment-structure.xml so i could not use anymore the oracle.sql.CLOB and i had the same probelm

 java.lang.ClassCastException: oracle.sql.CLOB cannot be cast to oracle.sql.CLOB

in the end i used

 java.sql.Clob clobValue = (java.sql.Clob)result.getClob("EMIRFILE");

and works correctly. I hope this help someone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!