In order to commemorate the 90th anniversary of the founding of the People's Republic of China, this article is dedicated to commemorate our military's prestige!!!
I. Background of the problem
II. Problem Orientation
public static void dbLogError(StringBuffer errorMessage, Exception ex) { if (dbLog != null) { dbLog.error(errorMessage); } if (isPrintStackTrace && ex != null) { ex.printStackTrace(); } }
Revised
public static void dbLogError(StringBuffer errorMessage, Exception ex) { if (dbLog != null) { dbLog.error(errorMessage); } if (isPrintStackTrace && ex != null) { dbLog.error(ex.getMessage(), ex); //Print the error stack to the log file ex.printStackTrace(); } }
III. Problem Analysis
That's 254.qualitystan VARCHAR2(254) default '',
if(trim(document.getElementsByName('bean.qualityStan')[0].value).length > 200){ alert("The quality standard you entered exceeds 200 words, please re-enter!"); document.getElementsByName('bean.qualityStan')[0].focus(); return; }
Why is the actual value 314 prompted in the error stack? Take a look at the description of varchar2 length in Oracle
SELECT parameter, VALUE FROM nls_database_parameters WHERE parameter IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET');
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_CHARACTERSET ZHS16GBK
There are two types of character data in Oracle. VARCHAR2 stores data according to the character set of database. NVARCHAR2 stores data according to the national character set. Similarly, CHAR and NCHAR are the same. One is the database character, the other is the national character set.
NVARCHAR2(N), where N is the number of characters, not bytes. But its maximum length is in bytes, or 4000 bytes.
VARCHAR2(N), where N may refer to the number of characters or bytes. You can specify explicitly when declaring, such as VARCHAR2(10 BYTE) or VARCHAR2(10 CHAR), and when not explicitly specified, it is determined by the parameter NLS_LENGTH_SEMANTICS.
SQL> SELECT parameter, VALUE FROM nls_database_parameters; PARAMETER VALUE ------------------------------ -------------------------------------------------------------------------------- NLS_NCHAR_CHARACTERSET AL16UTF16 NLS_LANGUAGE AMERICAN NLS_TERRITORY AMERICA NLS_CURRENCY $ NLS_ISO_CURRENCY AMERICA NLS_NUMERIC_CHARACTERS ., NLS_CHARACTERSET ZHS16GBK NLS_CALENDAR GREGORIAN NLS_DATE_FORMAT DD-MON-RR NLS_DATE_LANGUAGE AMERICAN NLS_SORT BINARY NLS_TIME_FORMAT HH.MI.SSXFF AM NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR NLS_DUAL_CURRENCY $ NLS_COMP BINARY NLS_LENGTH_SEMANTICS BYTE NLS_NCHAR_CONV_EXCP FALSE NLS_RDBMS_VERSION 11.2.0.4.0
IV. Problem Solution
if(trim(document.getElementsByName('bean.qualityStan')[0].value).length > 120){ alert("The quality standard you entered exceeds 120 words, please re-enter!"); document.getElementsByName('bean.qualityStan')[0].focus(); return; }