Work experience: MyBatis processing Oracle Long type

Source: Internet
Author: User
Tags sql error

Foreword: MyBatis receive a LONG type in Oracle, Error: Invalid column type: Getclob not implemented for class Oracle.jdbc.driver.T4CLongAccessor

Case

There is a long type in the Oracle table, a variable-length string is stored in a Long data type, and the maximum length limit is 2GB. (Detailed explanation can Baidu)

Since this table in the database is provided elsewhere, cannot be modified and can only be queried, the type of this field in the Oracle table cannot be modified.

So you can only handle the current problem. The current problem is as follows: Java entities use String type Iteme,mybatis SQL to use Resultmap form, SQL Resultmap as follows

<extends= "Baseresultmap"  ID= "Resultmapwithblobs"  type  = "Com.yule.demo">        <column= "Item_e"  Property= "Iteme"  jdbctype= "LongVarChar"/>    </ Resultmap >

Then query SQL error:

Solution Solutions

Change the LongVarChar in SQL to LongVarBinary.

<column= "Item_e"  Property= "Iteme"  jdbctype= " LongVarBinary "/>

Supplement (Turn http://blog.csdn.net/loongshawn/article/details/50496460) Mybatis jdbctype with Oracle, MySQL data type corresponding list

Mybatis Jdbctype Oracle MYSQL
Jdbctype ARRAY
Jdbctype BIGINT BIGINT
Jdbctype BINARY
Jdbctype BIT BIT
Jdbctype Blob Blob Blob
Jdbctype BOOLEAN
Jdbctype CHAR CHAR CHAR
Jdbctype Clob Clob TEXT
Jdbctype CURSOR
Jdbctype DATE DATE DATE
Jdbctype DECIMAL DECIMAL DECIMAL
Jdbctype DOUBLE Number DOUBLE
Jdbctype FLOAT FLOAT FLOAT
Jdbctype INTEGER INTEGER INTEGER
Jdbctype LongVarBinary
Jdbctype LongVarChar LONG VARCHAR
Jdbctype NCHAR NCHAR
Jdbctype NCLOB NCLOB
Jdbctype Null
Jdbctype NUMERIC Numeric/number numeric/
Jdbctype NVARCHAR
Jdbctype Other
Jdbctype REAL REAL REAL
Jdbctype SMALLINT SMALLINT SMALLINT
Jdbctype STRUCT
Jdbctype Time Time
Jdbctype TIMESTAMP TIMESTAMP Timestamp/datetime
Jdbctype TINYINT TINYINT
Jdbctype UNDEFINED
Jdbctype VARBINARY
Jdbctype VARCHAR VARCHAR VARCHAR

Note that the jdbctype part of MyBatis does not correspond to the data types of Oracle and MySQL (perhaps due to its own omission), but do not worry, follow-up people come across a detailed analysis, and the above correspondence is not necessarily one by one correspondence, please understand.

People master the basic numbers, time, string is enough to deal with the daily development.

  

Working experience: MyBatis processing Oracle Long type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.