mybatis处理 oracel LONG类型的数据

问题:

      因为公司orm框架要改为mybatis,原有的数据库字段中存在LONG字段,mybatis原先封装好的一些方法不能够正确查询会带有 流关闭,以及getClob一些错误

解决方法: select 其他字段,long字段 from 表名称

    自己手写sql语句,并将LONG字段 在select 字段 from 的时候 放到字段的最后一位

例如 :
test  表中 的   newsCode 是Long 字段 
sql 这么写
select 其他字段,newsCode  from  test   

控制台抛出的错误

Cause: java.sql.SQLException: 流已被关闭

; uncategorized SQLException for SQL []; SQL state [99999]; error code [17027]; 流已被关闭; nested exception is java.sql.SQLException: 流已被关闭] with root cause
java.sql.SQLException: 流已被关闭
at oracle.jdbc.driver.LongAccessor.getBytesInternal(LongAccessor.java:156)
at oracle.jdbc.driver.LongAccessor.getBytes(LongAccessor.java:126)
at oracle.jdbc.driver.LongAccessor.getString(LongAccessor.java:201)
at oracle.jdbc.driver.T4CLongAccessor.getString(T4CLongAccessor.java:427)
at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:1251)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:494)
at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.ibatis.logging.jdbc.ResultSetLogger.invoke(ResultSetLogger.java:67)
at com.sun.proxy. Proxy75.getString(UnknownSource)atorg.apache.ibatis.type.StringTypeHandler.getNullableResult(StringTypeHandler.java:37)atorg.apache.ibatis.type.StringTypeHandler.getNullableResult(StringTypeHandler.java:26)atorg.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:55)atorg.apache.ibatis.executor.resultset.DefaultResultSetHandler.getPropertyMappingValue(DefaultResultSetHandler.java:390)atorg.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(DefaultResultSetHandler.java:364)atorg.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:338)atorg.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:291)atorg.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:266)atorg.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:236)atorg.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:150)atorg.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:60)atorg.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:73)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)atjava.lang.reflect.Method.invoke(Method.java:606)atorg.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)atcom.moral.frame.dao.PaginationInterceptor.query(PaginationInterceptor.java:137)atcom.moral.frame.dao.PaginationInterceptor.intercept(PaginationInterceptor.java:78)atorg.apache.ibatis.plugin.Plugin.invoke(Plugin.java:60)atcom.sun.proxy. P r o x y 75. g e t S t r i n g ( U n k n o w n S o u r c e ) a t o r g . a p a c h e . i b a t i s . t y p e . S t r i n g T y p e H a n d l e r . g e t N u l l a b l e R e s u l t ( S t r i n g T y p e H a n d l e r . j a v a : 37 ) a t o r g . a p a c h e . i b a t i s . t y p e . S t r i n g T y p e H a n d l e r . g e t N u l l a b l e R e s u l t ( S t r i n g T y p e H a n d l e r . j a v a : 26 ) a t o r g . a p a c h e . i b a t i s . t y p e . B a s e T y p e H a n d l e r . g e t R e s u l t ( B a s e T y p e H a n d l e r . j a v a : 55 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . r e s u l t s e t . D e f a u l t R e s u l t S e t H a n d l e r . g e t P r o p e r t y M a p p i n g V a l u e ( D e f a u l t R e s u l t S e t H a n d l e r . j a v a : 390 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . r e s u l t s e t . D e f a u l t R e s u l t S e t H a n d l e r . a p p l y P r o p e r t y M a p p i n g s ( D e f a u l t R e s u l t S e t H a n d l e r . j a v a : 364 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . r e s u l t s e t . D e f a u l t R e s u l t S e t H a n d l e r . g e t R o w V a l u e ( D e f a u l t R e s u l t S e t H a n d l e r . j a v a : 338 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . r e s u l t s e t . D e f a u l t R e s u l t S e t H a n d l e r . h a n d l e R o w V a l u e s F o r S i m p l e R e s u l t M a p ( D e f a u l t R e s u l t S e t H a n d l e r . j a v a : 291 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . r e s u l t s e t . D e f a u l t R e s u l t S e t H a n d l e r . h a n d l e R o w V a l u e s ( D e f a u l t R e s u l t S e t H a n d l e r . j a v a : 266 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . r e s u l t s e t . D e f a u l t R e s u l t S e t H a n d l e r . h a n d l e R e s u l t S e t ( D e f a u l t R e s u l t S e t H a n d l e r . j a v a : 236 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . r e s u l t s e t . D e f a u l t R e s u l t S e t H a n d l e r . h a n d l e R e s u l t S e t s ( D e f a u l t R e s u l t S e t H a n d l e r . j a v a : 150 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . s t a t e m e n t . P r e p a r e d S t a t e m e n t H a n d l e r . q u e r y ( P r e p a r e d S t a t e m e n t H a n d l e r . j a v a : 60 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . s t a t e m e n t . R o u t i n g S t a t e m e n t H a n d l e r . q u e r y ( R o u t i n g S t a t e m e n t H a n d l e r . j a v a : 73 ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e 0 ( N a t i v e M e t h o d ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e ( N a t i v e M e t h o d A c c e s s o r I m p l . j a v a : 57 ) a t s u n . r e f l e c t . D e l e g a t i n g M e t h o d A c c e s s o r I m p l . i n v o k e ( D e l e g a t i n g M e t h o d A c c e s s o r I m p l . j a v a : 43 ) a t j a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( M e t h o d . j a v a : 606 ) a t o r g . a p a c h e . i b a t i s . p l u g i n . I n v o c a t i o n . p r o c e e d ( I n v o c a t i o n . j a v a : 49 ) a t c o m . m o r a l . f r a m e . d a o . P a g i n a t i o n I n t e r c e p t o r . q u e r y ( P a g i n a t i o n I n t e r c e p t o r . j a v a : 137 ) a t c o m . m o r a l . f r a m e . d a o . P a g i n a t i o n I n t e r c e p t o r . i n t e r c e p t ( P a g i n a t i o n I n t e r c e p t o r . j a v a : 78 ) a t o r g . a p a c h e . i b a t i s . p l u g i n . P l u g i n . i n v o k e ( P l u g i n . j a v a : 60 ) a t c o m . s u n . p r o x y . Proxy140.query(Unknown Source)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:60)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.mybatis.spring.SqlSessionTemplate SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)atcom.sun.proxy. S q l S e s s i o n I n t e r c e p t o r . i n v o k e ( S q l S e s s i o n T e m p l a t e . j a v a : 358 ) a t c o m . s u n . p r o x y . Proxy83.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:205)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:117)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.sun.proxy. Proxy122.getReceiveNoticeList(UnknownSource)atcom.moral.notice.service.impl.NoticeServiceImpl.getReceiveNoticeList(NoticeServiceImpl.java:161)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)atjava.lang.reflect.Method.invoke(Method.java:606)atorg.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)atorg.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)atcom.sun.proxy. P r o x y 122. g e t R e c e i v e N o t i c e L i s t ( U n k n o w n S o u r c e ) a t c o m . m o r a l . n o t i c e . s e r v i c e . i m p l . N o t i c e S e r v i c e I m p l . g e t R e c e i v e N o t i c e L i s t ( N o t i c e S e r v i c e I m p l . j a v a : 161 ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e 0 ( N a t i v e M e t h o d ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e ( N a t i v e M e t h o d A c c e s s o r I m p l . j a v a : 57 ) a t s u n . r e f l e c t . D e l e g a t i n g M e t h o d A c c e s s o r I m p l . i n v o k e ( D e l e g a t i n g M e t h o d A c c e s s o r I m p l . j a v a : 43 ) a t j a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( M e t h o d . j a v a : 606 ) a t o r g . s p r i n g f r a m e w o r k . a o p . s u p p o r t . A o p U t i l s . i n v o k e J o i n p o i n t U s i n g R e f l e c t i o n ( A o p U t i l s . j a v a : 309 ) a t o r g . s p r i n g f r a m e w o r k . a o p . f r a m e w o r k . J d k D y n a m i c A o p P r o x y . i n v o k e ( J d k D y n a m i c A o p P r o x y . j a v a : 196 ) a t c o m . s u n . p r o x y . Proxy126.getReceiveNoticeList(Unknown Source)
at com.moral.notice.view.NoticeController.getNoticeListPage(NoticeController.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.logging.log4j.core.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:66)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol AbstractConnectionHandler.process(AbstractProtocol.java:607)atorg.apache.tomcat.util.net.JIoEndpoint A b s t r a c t C o n n e c t i o n H a n d l e r . p r o c e s s ( A b s t r a c t P r o t o c o l . j a v a : 607 ) a t o r g . a p a c h e . t o m c a t . u t i l . n e t . J I o E n d p o i n t SocketProcessor.run(JIoEndpoint.java:313)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值