oracle大字段BLOB读取,转换异常

在读取oracle数据库中的大字段blob字段时,
oracle.sql.BLOB blob = (oracle.sql.BLOB)rs.getBlob(1);
发生java.lang.ClassCastException: oracle.sql.CLOB 异常

异常信息:
java.lang.ClassCastException: oracle.sql.BLOB
at mdx.DB.updateClob(DB.java:116)
at org.apache.jsp.processEditBidItem_jsp._jspService(org.apache.jsp.processEditBidItem_jsp:174)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:319)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)

刚开始都以为真的是类型转换异常,后面加了一句打印转换前的类型
System.out.println(rs.getBlob(1).getClasss());
打印出来的结果是oracle.sql.BLOB,

后面又怀疑是驱动包的问题,把原来的class12.jar的驱动包换成了oracle10.2.0.1版本的驱动包ojdbc14.jar,
也没有解决问题

问题解决方法:
最后觉得是不是驱动包重复了,
就在tomcat的common/lib目录下面找到相应的驱动包,而应用程序中也有相应的驱动包,只能删除其中一个来试,
因为common/lib/目录下面的驱动包是给tomcat创建jndi数据源时用的,故不能删除,只能删除应用程序中的包,但删除后又会导致程序编译不通过,这时就通过eclilpse的-build path进行外部引用,使用应用程序编译通过,但也不会把ojdbc14.jar的驱动包引入到发布目录,再试,果然解决了问题。

本文转自:http://blog.javauu.com/2009/03/235.html

你可能感兴趣的:(java,apache,oracle,sql,tomcat)