• Mybatis集成dbcp-java.lang.AbstractMethodError: Method org/apache/commons/dbcp/DelegatingResultSet.isClosed()Z is abstract


    Mybatis集成dbcp做数据库链接池,进行查询时,触发一个异常:

    java.lang.AbstractMethodError: Method org/apache/commons/dbcp/DelegatingResultSet.isClosed()Z is abstract
    	at org.apache.commons.dbcp.DelegatingResultSet.isClosed(DelegatingResultSet.java)
    	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:352)
    	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:328)
    	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:301)
    	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:194)
    	at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:65)
    	at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
    	at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
    	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
    	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
    	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
    	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
    	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
    	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
    	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
    	at com.sun.proxy.$Proxy59.selectOne(Unknown Source)
    	at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:159)
    	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:87)
    	at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:144)
    	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85)
    	at com.sun.proxy.$Proxy60.findByName(Unknown Source)
            at xxxService.findByName(UruleXmlService.java:43)
    

    原因:


    从集成图中可以看到,ResultSet接口是java.sql下的,从1.6版本增加了isClosed接口,而1.3版本没有实现这个方法。

        /**
         * Retrieves whether this <code>ResultSet</code> object has been closed. A <code>ResultSet</code> is closed if the
         * method close has been called on it, or if it is automatically closed.
         *
         * @return true if this <code>ResultSet</code> object is closed; false if it is still open
         * @throws SQLException if a database access error occurs
         * @since 1.6
         */
        boolean isClosed() throws SQLException;
    

    解决办法-升级dbcp接口或更换数据库链接池

    原依赖

    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.3</version>
    </dependency>
    <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>2.1.2</version>
    </dependency>
    

    新依赖

    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>2.1.2</version>
    </dependency>
    

    思考:

    时间上来看,dbcp-1.3版本是Feb 07, 2010发布的,而jdk-1.6是2006-04年发布的。为啥10年发布的版本没有实现这个方法?
    而且1.4版本 也是10年发布的,为啥10年会同时发布两个版本?难道是maven记录的问题?

  • 相关阅读:
    问题解决(2)
    问题解决(1)
    ubuntu16.04spyder闪退
    ubuntu16.04安装caffe
    python做批量剪切、旋转等小程序
    html中如何使得改变背景的透明度时,背景上的文字透明度不被改变
    css下拉菜单制作
    float浮动
    css盒子模型
    css选择器,背景样式,文本属性
  • 原文地址:https://www.cnblogs.com/jason0529/p/13552898.html
Copyright © 2020-2023  润新知