Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 是否有Db2标量函数来检索给定SQLCODE的完整错误消息信息?_Java_Db2_Db2 Luw - Fatal编程技术网

Java 是否有Db2标量函数来检索给定SQLCODE的完整错误消息信息?

Java 是否有Db2标量函数来检索给定SQLCODE的完整错误消息信息?,java,db2,db2-luw,Java,Db2,Db2 Luw,如果我有SQL错误代码,我想知道是否有任何现有的解决方案可以在代码中获得详细的DB错误解释。我想把这些信息转储到日志中,这样我就不必每次遇到谷歌的时候都去查了 目标tach堆栈是-Java、DB2 谢谢大家! 函数SYSPROC.SQLERRM将返回给定SQLCODE的错误消息 例如,这将返回SQLCODE 100的短消息(即SQL100W) 像这样 1 -----------------------------------------------------------------------

如果我有SQL错误代码,我想知道是否有任何现有的解决方案可以在代码中获得详细的DB错误解释。我想把这些信息转储到日志中,这样我就不必每次遇到谷歌的时候都去查了

目标tach堆栈是-Java、DB2


谢谢大家!

函数
SYSPROC.SQLERRM
将返回给定SQLCODE的错误消息

例如,这将返回SQLCODE 100的短消息(即
SQL100W

像这样

1
---------------------------------------------------------------------------------------------------
SQL0100W  No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.

  1 record(s) selected.
这将返回完整的消息

VALUES (SYSPROC.SQLERRM ('SQL100W', '', '', 'en_US', 0))
会回来的

1                                                                                                                                                                                                                  
----------------------------------------------------------------------------

SQL0100W  No row was found for FETCH, UPDATE or DELETE; or the result of
      a query is an empty table.

Explanation: 

One of the following conditions is true:

*  No row was found that meets the search conditions specified in an
   UPDATE or DELETE statement.

*  The result of a SELECT statement was an empty table.

*  A FETCH statement was executed when the cursor was positioned after
   the last row of the result table.

*  The result of the SELECT used in an INSERT statement is empty.

No data was retrieved, updated, or deleted.

User response: 

No action is required. Processing can continue.

sqlcode: +100

sqlstate: 02000



  1 record(s) selected.

用谷歌搜索错误代码有什么不对?您是否希望有许多错误?我确实有许多应用程序共享相同的底层框架。我希望可以直接从日志中访问相同的错误解释,以确保支持人员和开发人员对错误有相同的理解,并且支持人员甚至可以在可能的情况下主动解决其中一些错误,如果你在Java代码中捕捉到了这些SQL异常,那么为什么不能在堆栈跟踪中添加更多信息呢?我认为,最好的办法是在你写日志的时候处理这个问题。我想两者兼而有之。ST会告诉问题发生在哪里,但是任何数据库端错误都需要对SQL代码进行详细解释。无论我多么希望在运行时以所需的方式解决每个异常,这并不总是可能的。请将SQL错误的详细描述存储在属性文件中,其中键是数字代码。非常感谢!这正是我要找的。我不知道为什么这个问题被否决了,但我真的希望有相同需求的人能够看到你的答案!
1                                                                                                                                                                                                                  
----------------------------------------------------------------------------

SQL0100W  No row was found for FETCH, UPDATE or DELETE; or the result of
      a query is an empty table.

Explanation: 

One of the following conditions is true:

*  No row was found that meets the search conditions specified in an
   UPDATE or DELETE statement.

*  The result of a SELECT statement was an empty table.

*  A FETCH statement was executed when the cursor was positioned after
   the last row of the result table.

*  The result of the SELECT used in an INSERT statement is empty.

No data was retrieved, updated, or deleted.

User response: 

No action is required. Processing can continue.

sqlcode: +100

sqlstate: 02000



  1 record(s) selected.