互联网服务

SQLCODE=-514,SQLSTATE=26501

今天遇到一个问题,技术场景:web应用通过java的RMI机制向四台CUBE作业服务器分别发送请求执行CUBE作业的命令,CUBE作业服务器接收到指令后向数据库服务器查询任务的状态值,但是这个查询抛出了 com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-514,SQLSTATE=26501,S...显示全部
今天遇到一个问题,技术场景:web应用通过java的RMI机制向四台CUBE作业服务器分别发送请求执行CUBE作业的命令,CUBE作业服务器接收到指令后向数据库服务器查询任务的状态值,但是这个查询抛出了 com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-514,SQLSTATE=26501,SQLERRMC=SQL_CURSH200C1,DRIVER=3.64.104

报错的sql为:select count(*) from mabas.s_task_schedule_info where runstatus=9 and task_name=?
使用JDBC的PreparedStatement 预编译方式执行SQL,其中TASK_NAME的值为CUBE_BAT_TASK1

该条sql的用途是判断是否能从数据库中执行查询,(是程序的第一条程序) 因为这里抛出了错误,所以程序无法进行。只能重启RMI程序,重启后正常,不过过一段时间还是报这个错误。

在测试环境中没有出现这种情况,在生产上出了几次了,需要重启RMI程序才能正常。
------------------------------------------------------------------------------------------------
这个sqlcode的文档解释是:
SQL0514N

The cursor name is not in a prepared state.
Explanation

The application program tried to use a cursor name that is not in a prepared state. The cursor is associated with a statement that either (1) was never prepared, (2) was made not valid by a ROLLBACK, or (3) was made not valid by either an explicit or implicit rebind of the package.

The statement cannot be processed.
User response

For case (1), prepare the statement named in the DECLARE CURSOR statement for name before you try to open the cursor. For case (2), do not issue a ROLLBACK until after you finish using the cursor. For case (3), the prepare for the cursor must be reissued.

sqlcode: -514

sqlstate: 26501
----------------------------------------------------------------------------

这条sql就是动态sql,单条执行的。而非存储过程中的。不太符合sqlcode的解释。希望高手帮忙解决一下,多谢!

附件:

附件图标故障日志文件.rar (58.68 KB)

收起
参与11

查看其它 8 个回答rczhan的回答

rczhanrczhan测试工程师德派克

@wencycool数据库管理员        , 山东


这个问题是怎么解决的?我现在也碰到了这个问题。烦请告知一下解决方法谢谢。

银行 · 2017-04-18
浏览881

回答者

rczhan
测试工程师德派克

回答状态

  • 发布时间:2017-04-18
  • 关注会员:2 人
  • 回答浏览:881
  • X社区推广