zoukankan      html  css  js  c++  java
  • java.lang.AbstractMethodError: Method oracle/jdbc/driver/OracleResultSetImpl.getNString(Ljava/lang/String;)Ljava/lang/String; is abstract,

    mapper.xml映射数据库和实体类报错

    报错信息:java.lang.AbstractMethodError: Method oracle/jdbc/driver/OracleResultSetImpl.getNString(Ljava/lang/String;)Ljava/lang/String; is abstract,

    问题:在mapper.xml代码中  jdbcType  定义的跟数据库中的和实体类中的不一致,

    解决方案1:暴力解决,直接去掉mapper.xml中定义的resultMap中的jdbcType ,不指定数据类型

    解决方案2:逐个检查 实体类、数据库、resultMap中的数据类型,这三者要保持一致

    附:MySQL数据类型、JDBC数据类型、Java数据类型的默认映射关系

    MySQL数据类型 JDBC类型(getColumnTypeName)默认返回的Java类型(getColumnClassName)
    BIT(1) (new in MySQL-5.0) BIT java.lang.Boolean
    BIT( > 1) (new in MySQL-5.0) BIT byte[]
    TINYINT TINYINT java.lang.Boolean if the configuration property tinyInt1isBit is set to true (the default) and the storage size is 1, or java.lang.Integer if not.
    BOOLBOOLEAN TINYINT See TINYINT, above as these are aliases for TINYINT(1), currently.
    SMALLINT[(M)] [UNSIGNED] SMALLINT [UNSIGNED] java.lang.Integer (regardless of whether it is UNSIGNED or not)
    MEDIUMINT[(M)] [UNSIGNED] MEDIUMINT [UNSIGNED] java.lang.Integer (regardless of whether it is UNSIGNED or not)
    INT,INTEGER[(M)] [UNSIGNED] INTEGER [UNSIGNED] java.lang.Integer, if UNSIGNED java.lang.Long
    BIGINT[(M)] [UNSIGNED] BIGINT [UNSIGNED] java.lang.Long, if UNSIGNED java.math.BigInteger
    FLOAT[(M,D)] FLOAT java.lang.Float
    DOUBLE[(M,B)] DOUBLE java.lang.Double
    DECIMAL[(M[,D])] DECIMAL java.math.BigDecimal
    DATE DATE java.sql.Date
    DATETIME DATETIME java.sql.Timestamp
    TIMESTAMP[(M)] TIMESTAMP java.sql.Timestamp
    TIME TIME java.sql.Time
    YEAR[(2|4)] YEAR If yearIsDateType configuration property is set to false, then the returned object type is java.sql.Short. If set to true (the default), then the returned object is of type java.sql.Datewith the date set to January 1st, at midnight.
    CHAR(M) CHAR java.lang.String (unless the character set for the column is BINARY, then byte[] is returned.
    VARCHAR(M) [BINARY] VARCHAR java.lang.String (unless the character set for the column is BINARY, then byte[] is returned.
    BINARY(M) BINARY byte[]
    VARBINARY(M) VARBINARY byte[]
    TINYBLOB TINYBLOB byte[]
    TINYTEXT VARCHAR java.lang.String
    BLOB BLOB byte[]
    TEXT VARCHAR java.lang.String
    MEDIUMBLOB MEDIUMBLOB byte[]
    MEDIUMTEXT VARCHAR java.lang.String
    LONGBLOB LONGBLOB byte[]
    LONGTEXT VARCHAR java.lang.String
    ENUM('value1','value2',...) CHAR java.lang.String
    SET('value1','value2',...) CHAR java.lang.String

    MySQL JDBC允许不同数据类型之间相互转换:转换表如下 

    MySQL数据类型可以被转换的Java类型
    CHAR, VARCHAR, BLOB, TEXT, ENUM, and SET java.lang.String, java.io.InputStream, java.io.Reader, java.sql.Blob, java.sql.Clob
    FLOAT, REAL, DOUBLE PRECISION, NUMERIC, DECIMAL, TINYINT, SMALLINT, MEDIUMINT, INTEGER, BIGINT java.lang.String, java.lang.Short, java.lang.Integer, java.lang.Long, java.lang.Double, java.math.BigDecimal
    DATE, TIME, DATETIME, TIMESTAMP java.lang.String, java.sql.Date, java.sql.Timestamp

    参考MySQL :: MySQL Connector/J 8.0 Developer Guide :: 6.5 Java, JDBC, and MySQL Types

     
  • 相关阅读:
    HTTP Header 详解
    nginx负载均衡配置
    Win10安装Oracle11g
    MySQL如何让别人远程连接自己的数据库
    Maven的安装以及配置
    linux上安装jdk,tomcat,mysql
    Centos7上安装docker
    ActiviMQ快速入门
    2018年上海后半年JAVA软件工程师面试真题
    Docker安装MySQL、Redis、Tomcat
  • 原文地址:https://www.cnblogs.com/cdlyy/p/15720593.html
Copyright © 2011-2022 走看看