org.springframework.jdbc.UncategorizedSQLException: ### Error querying database.

I encountered a problem during development today. There is a business state that needs to configure a data dictionary. The value of the dictionary is 0, 1, 2, 3, etc., but when I configure it, the code is as follows when I add it.
<form:select path="status">
        <form:option value="" label=""/>
        <form:options items="${fns:getDictList('BUS_STATUS')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                        </form:select>

Using spring's form tag, but after the code is changed, it cannot convert the dictionary to the real value from the database. At first I suspected that it was a code problem, but after careful inspection, I found that there was no problem with the code. So I looked for the problem by breaking the point, and
later found that the value of the key found in the database was '1', please look carefully, '1' occupies two bytes, explain that the database I use is db2, The visualization tool is DbVisualizer Pro 9.1.8. By looking at the database, I found that the field type of business status is char2, so I passed the sql statement:
alter table tablename alter column columnname set data type varchar(2); Change
the type of the field of business status to varchar.
Due to the problem of modifying the field, the database reported the error -668, so I solved the problem with reorg table tablename.
When I thought it was done like this, I reported this error when querying:

RATE_ADJUST_MODEL, RATE_ADJUST_METHOD, REPAYMENT_METHOD, PAY_RATE_METHOD, PAY_RATE_DATE, LOAN_TARGET, AGR_TYPE, LOAN_USEAGE, PAYMENT_METHOD, TURNOVER, FAMILY_INCOME, ACCOUNT_REC, STOCK, PURCHASE_COST, STAFF_EXPENSE, OTHER_EXPENSE, FAMILY_EXPEND, ACCOUNT_PAYABLE, INITIAL_CAPITAL, BANK_LOAN, LONGTERM_LIAB, REMARK, CUST_SIGN, CREATE_DTIME, CUST_MANAGER, EXT_FIELD1,EXT_FIELD2,EXT_FIELD3,GUA_TYPE from ARESV3.WH_MICRO_CREDIT WHERE CREATE_DTIME >= ? and CREATE_DTIME <= ? order by CREATE_DTIME DESC ) as temp_ where rownumber_ <= 10 ### Cause: com.ibm.db2.jcc.am.SqlException: [jcc][t4][2093][11302][4.7.85] Query processing terminated due to an error on the server. ERRORCODE=-4228, SQLSTATE=null ; uncategorized SQLException for SQL []; SQL state [null]; error code [-4228]; [jcc][t4][2093][11302][4.7.85] Query processing has been terminated due to an error. ERRORCODE=-4228, SQLSTATE=null; nested exception is com.ibm.db2.jcc.am. SqlException: [jcc][t4][2093][11302][4.7.85] Query processing terminated due to an error on the server. ERRORCODE=-4228, SQLSTATE=null

After I restarted the service the problem went away.
, I found through the breakpoint that the value passed in from the database is still '1', which still occupies two bytes, so I reassign all the original business status values ​​of the database, and then query it again.
My solution may be different from yours. It is for your reference only. As a novice, I hope you will point out any problems.


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326613003&siteId=291194637