Recently, when inserting data, I encountered the BUG of "ORA-01461: Can only assign values to the LOGN values of the inserted LOGN columns ".
The data type in oracle is varchar2 (4000 byte). The inserted data cannot exceed 4000.
Changes to varchar2 (4000 char), LONG, CLOB, and other types cannot be solved.
Google, most of the solutions on the Internet are to change the driver or change the database type. They have tried and are not valid.
I found that the length of the inserted data is about 1400, while that of oracle is inserting [1000 ~ 2000] between the data will be reported ORA-01461 error, less than 1000, or (2000 ~ 4000. The following operations are performed to solve the problem:
Java code
String content =...; // data to be inserted
Int len = content. getBytes (). length;
If (len> = 1000 & len <= 2000)
Content = StringUtils. rightPad (content, 2002 );
Note: To use StringUtils, You need to import the commons-lang package. rightPad () indicates filling spaces on the right.
Java code
StringUtils. rightPad (null, *) = null
StringUtils. rightPad ("", 3) = ""
StringUtils. rightPad ("bat", 3) = "bat"
StringUtils. rightPad ("bat", 5) = "bat"
StringUtils. rightPad ("bat", 1) = "bat"
StringUtils. rightPad ("bat",-1) = "bat"
Author "three lessons"