• MySQL++:(转)mybatis 常用 jdbcType数据类型


    MyBatis 通过包含的jdbcType类型

    BIT         FLOAT      CHAR           TIMESTAMP       OTHER       UNDEFINED
    
    TINYINT     REAL       VARCHAR        BINARY          BLOB        NVARCHAR
    
    SMALLINT    DOUBLE     LONGVARCHAR    VARBINARY       CLOB        NCHAR
    
    INTEGER     NUMERIC    DATE           LONGVARBINARY   BOOLEAN     NCLOB
    
    BIGINT      DECIMAL    TIME           NULL            CURSOR

    2 Mybatis中javaType和jdbcType对应和CRUD例子

    <resultMap type="java.util.Map" id="resultjcm">
      <result property="FLD_NUMBER" column="FLD_NUMBER"  javaType="double" jdbcType="NUMERIC"/>
      <result property="FLD_VARCHAR" column="FLD_VARCHAR" javaType="string" jdbcType="VARCHAR"/>
      <result property="FLD_DATE" column="FLD_DATE" javaType="java.sql.Date" jdbcType="DATE"/>
      <result property="FLD_INTEGER" column="FLD_INTEGER"  javaType="int" jdbcType="INTEGER"/>
      <result property="FLD_DOUBLE" column="FLD_DOUBLE"  javaType="double" jdbcType="DOUBLE"/>
      <result property="FLD_LONG" column="FLD_LONG"  javaType="long" jdbcType="INTEGER"/>
      <result property="FLD_CHAR" column="FLD_CHAR"  javaType="string" jdbcType="CHAR"/>
      <result property="FLD_BLOB" column="FLD_BLOB"  javaType="[B" jdbcType="BLOB" />
      <result property="FLD_CLOB" column="FLD_CLOB"  javaType="string" jdbcType="CLOB"/>
      <result property="FLD_FLOAT" column="FLD_FLOAT"  javaType="float" jdbcType="FLOAT"/>
      <result property="FLD_TIMESTAMP" column="FLD_TIMESTAMP"  javaType="java.sql.Timestamp" jdbcType="TIMESTAMP"/>
     </resultMap>

    3 MybatisjavaTypejdbcType对应关系

    JDBC Type            Java Type
    CHAR                String
    VARCHAR                String
    LONGVARCHAR            String
    NUMERIC                java.math.BigDecimal
    DECIMAL                java.math.BigDecimal
    BIT                boolean
    BOOLEAN                boolean
    TINYINT                byte
    SMALLINT            short
    INTEGER                int
    BIGINT                long
    REAL                float
    FLOAT                double
    DOUBLE                double
    BINARY                byte[]
    VARBINARY            byte[]
    LONGVARBINARY                byte[]
    DATE                java.sql.Date
    TIME                java.sql.Time
    TIMESTAMP            java.sql.Timestamp
    CLOB                Clob
    BLOB                Blob
    ARRAY                Array
    DISTINCT            mapping of underlying type
    STRUCT                Struct
    REF                            Ref
    DATALINK            java.net.URL[color=red][/color]

    4  oracle数据类型和对应的java类型

    用mybatis generator生成代码后,执行查询语句时,oracle里的Date类型字段只精确到年月日,后面时分秒都为零。

     jdbcType="DATE"时候,存入到数据库中的字段只有年月日!

    后来发现是jdbcType问题,改成 jdbcType="TIMESTAMP" 就可以。(原先默认生成时是jdbcType="DATE")

    地址:

    http://otndnld.oracle.co.jp/document/products/oracle10g/102/doc_cd/java.102/B19275-03/datacc.htm#BHCJBJCC

     

    SQL数据类型JDBC类型代码标准的Java类型Oracle扩展的Java类型
     

    1.0标准的JDBC类型:

       

    CHAR

    java.sql.Types.CHAR

    java.lang.String

    oracle.sql.CHAR

    VARCHAR2

    java.sql.Types.VARCHAR

    java.lang.String

    oracle.sql.CHAR

    LONG

    java.sql.Types.LONGVARCHAR

    java.lang.String

    oracle.sql.CHAR

    NUMBER

    java.sql.Types.NUMERIC

    java.math.BigDecimal

    oracle.sql.NUMBER

    NUMBER

    java.sql.Types.DECIMAL

    java.math.BigDecimal

    oracle.sql.NUMBER

    NUMBER

    java.sql.Types.BIT

    boolean

    oracle.sql.NUMBER

    NUMBER

    java.sql.Types.TINYINT

    byte

    oracle.sql.NUMBER

    NUMBER

    java.sql.Types.SMALLINT

    short

    oracle.sql.NUMBER

    NUMBER

    java.sql.Types.INTEGER

    int

    oracle.sql.NUMBER

    NUMBER

    java.sql.Types.BIGINT

    long

    oracle.sql.NUMBER

    NUMBER

    java.sql.Types.REAL

    float

    oracle.sql.NUMBER

    NUMBER

    java.sql.Types.FLOAT

    double

    oracle.sql.NUMBER

    NUMBER

    java.sql.Types.DOUBLE

    double

    oracle.sql.NUMBER

    RAW

    java.sql.Types.BINARY

    byte[]

    oracle.sql.RAW

    RAW

    java.sql.Types.VARBINARY

    byte[]

    oracle.sql.RAW

    LONGRAW

    java.sql.Types.LONGVARBINARY

    byte[]

    oracle.sql.RAW

    DATE

    java.sql.Types.DATE

    java.sql.Date

    oracle.sql.DATE

    DATE

    java.sql.Types.TIME

    java.sql.Time

    oracle.sql.DATE

    TIMESTAMP

    java.sql.Types.TIMESTAMP

    javal.sql.Timestamp

    oracle.sql.TIMESTAMP

     

    2.0标准的JDBC类型:

       

    BLOB

    java.sql.Types.BLOB

    java.sql.Blob

    oracle.sql.BLOB

    CLOB

    java.sql.Types.CLOB

    java.sql.Clob

    oracle.sql.CLOB

    用户定义的对象

    java.sql.Types.STRUCT

    java.sql.Struct

    oracle.sql.STRUCT

    用户定义的参考

    java.sql.Types.REF

    java.sql.Ref

    oracle.sql.REF

    用户定义的集合

    java.sql.Types.ARRAY

    java.sql.Array

    oracle.sql.ARRAY

     

    Oracle扩展:

       

    BFILE

    oracle.jdbc.OracleTypes.BFILE

    N/A

    oracle.sql.BFILE

    ROWID

    oracle.jdbc.OracleTypes.ROWID

    N/A

    oracle.sql.ROWID

    REF CURSOR

    oracle.jdbc.OracleTypes.CURSOR

    java.sql.ResultSet

    oracle.jdbc.OracleResultSet

    TIMESTAMP

    oracle.jdbc.OracleTypes.TIMESTAMP

    java.sql.Timestamp

    oracle.sql.TIMESTAMP

    TIMESTAMP WITH TIME ZONE

    oracle.jdbc.OracleTypes.TIMESTAMPTZ

    java.sql.Timestamp

    oracle.sql.TIMESTAMPTZ

    TIMESTAMP WITH LOCAL TIME ZONE

    oracle.jdbc.OracleTypes.TIMESTAMPLTZ

    java.sql.Timestamp

    oracle.sql.TIMESTAMPLTZ

  • 相关阅读:
    XLS导出的服务器端配置方式
    SQLSERVER2008 内存占用高的处理方式
    word定义多级列表
    SQL Server替换特殊字符
    php和mysql两种不同方式的分割字符串和类型转换
    tp杂记
    MySql数据库 主从复制/共享 报错
    the server ssl certificate failed to verify
    loaded some nib but the view outlet was not set(转载)
    xcode7 调用相册权限无提示
  • 原文地址:https://www.cnblogs.com/codingmode/p/15193506.html
Copyright © 2020-2023  润新知