How to quickly locate problems in error reporting of db2-407 sqlcode: – 407, sqlstate: 23502

Why can’t you grab tickets when you travel on holiday?Reveal the key technology of 12306 how to ensure the ticket is not oversold>>>

Sqlcode: – 407, sqlstate: 23502: the exact description of this error report is that the null value cannot be inserted into the column defined as not null. That is, the integrity constraint exception is violated
in development, we often encounter this error. The problem is also very simple, that is, “the column that cannot be empty is empty.”. For a table with many fields, it is difficult to check. How to accurately
locate?It’s very simple

We can learn more details from the error information, which can help us accurately locate the problem. The general error information is as follows:

com.ibm.db2.jcc.b.SqlE xception:DB2SQLerror :SQLCODE:-407,SQLSTATE:23502,SQLERRMC:TBSPACEID=2,TABLEID=201,COLNO=3

atcom.ibm.db2.jcc.b.sf.d(sf. java:1396 )

atcom.ibm.db2.jcc.c.jb.l(jb. java:356 )

atcom.ibm.db2.jcc.c.jb.a(jb. java:64 )

atcom.ibm.db2.jcc.c.w.a(w. java:48 )

atcom.ibm.db2.jcc.c.dc.c(dc. java:312 )

atcom.ibm.db2.jcc.b.tf.cb(tf. java:1723 )

atcom.ibm.db2.jcc.b.tf.d(tf. java:2315 )

atcom.ibm.db2.jcc.b.tf.Z(tf. java:1326 )

atcom.ibm.db2.jcc.b.tf.execute(tf. java:1310 )

atjava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor. java:886 )

atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor. java:908 )

atjava.lang.Thread.run(Thread. java:662 )

Message: integrity constraint exception(

—The error occurred in D: \ — path omitted ——–

—Theerroroccurredwhileapplyingaparametermap.

—Checktheaaa.sql-InlineParameterMap.

—Checkthestatement(updatefailed).

—C ause:com.ibm.db2.jcc.b.SqlException :DB2SQL error:SQLCODE :-407,SQLSTATE:23502,SQLERRMC:TBSPACEID=2,TABLEID=201,COLNO=3)

Carefully observe this error message: sqlcode: – 407, sqlstate: 23502, sqlerrmc: tbspaceid = 2, tableid = 201, colno = 3. It can be found that this error message has been positioned clearly. We just need to go to the system table syscat. Columns to query. The syscat.columns table is the system table, which holds the column details of all tables in the DB2 database. We only need to find which column is according to
view, table name and column number. Colno = 3 in the above error information is the column number of the error. As follows:

SELECT
*
FROM
SYSCAT.COLUMNS
WHERE
TABSCHEMA = ‘DB’ AND
TABNAME = ‘TT_ PARAM_ LOG’ AND
COLNO = ‘3’

Similar Posts: