我们建议您在调试存储过程之前导入该数据库以避免此问题。
当您在本地数据库上调试“SQL 存储过程”时,可能接收到错误号 SQL1224N:
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] SQL1224N 不能启动数据库代理进程来响应请求,或者该代理进程因为数据库系统关闭或强制命令而终止。SQLSTATE=55032
这是 Linux 内核中的问题(Linux 内核 Bugzilla bug #351)造成的。下列指示信息是一种变通方法,它使用 DB2 的 TCPIP 连接方法(作为回送)而不是“调用级接口”(CLI)。对于此过程,调试器将使用与以前一样的数据库别名:
步骤 2 至步骤 7 要求您作为 DB2 实例所有者登录。
db2set db2comm
如果输出不包含关键字 tcpip,则需要输入以下命令以将 db2comm 注册表变量更新为包括 tcpip:
db2set db2comm=<existing protocol names>,tcpip
db2comm 注册表变量确定在启动数据库管理器时将启用哪个协议的连接管理器。可通过用逗号隔开这些关键字来对多个通信协议设置此变量,例如,db2set db2comm=tcpip,appc。
您需要重新发出 db2start 命令以启动用于由 db2comm 注册表参数指定的协议的连接管理器。既然我们将在步骤 7 中重新启动 DB2,现在就不需要这样做。
要检查 SVCENAME 的当前设置,输入以下命令:
db2 get dbm cfg | grep -i svcename
如果需要更新 SVCENAME 的设置,输入以下命令:
db2 update dbm cfg using svcename <connection service name>
其中 <connection service name> 是区分大小写的,而且必须与位于 /etc/services 中的服务端口的名称相匹配(例如,db2 update dbm cfg using svcename db2c_db2inst1)。
在发出下一个 db2start 命令之前,数据库管理器配置的更新将不起作用。我们将在步骤 7 中进行此操作。
db2 catalog tcpip node <nodename> remote <hostname> server <connection service name>
其中,
要验证 catalog 命令正常工作,发出以下命令:
db2 list node directory
此命令的样本输出为(为了便于阅读,已除去空白行):
Node Directory Number of entries in the directory = 1 Node 1 entry: Node name = MYNODE Comment = Protocol = TCPIP Hostname = 127.0.0.1 Service name = db2c_db2inst1
例如,db2 catalog db WAS as WASLOOP db2 uncatalog db WAS db2 catalog db WASLOOP as WAS at node MYNODE
注意:
步骤 5a 至 5c 的样本输出
在步骤 5a 之前,已经创建了名为 WAS 的本地数据库。db2 list db directory 命令的输出类似于以下消息:
System Database Directory Number of entries in the directory = 1 Database 1 entry: Database alias = WAS Database name = WAS Local database directory = /home/ctsui Database release level = 9.00 Comment = Directory entry type = Indirect Catalog node number = 0
在执行步骤 5a 之后,db2 list db directory 的输出类似于以下消息:
System Database Directory Number of entries in the directory = 2 Database 1 entry: Database alias = WAS Database name = WAS Local database directory = /home/ctsui Database release level = 9.00 Comment = Directory entry type = Indirect Catalog node number = 0 Database 2 entry: Database alias = WASLOOP Database name = WAS Local database directory = /home/ctsui Database release level = 9.00 Comment = Directory entry type = Indirect Catalog node number = 0
在执行步骤 5b 之后,db2 list db directory 的输出类似于以下消息:
System Database Directory Number of entries in the directory = 1 Database 1 entry: Database alias = WASLOOP Database name = WAS Local database directory = /home/ctsui Database release level = 9.00 Comment = Directory entry type = Indirect Catalog node number = 0
在执行步骤 5c 之后,db2 list db directory 的输出类似于以下消息:
System Database Directory Number of entries in the directory = 2 Database 1 entry: Database alias = WAS Database name = WASLOOP Node name = MYNODE Database release level = 9.00 Comment = Directory entry type = Remote Catalog node number = -1 Database 2 entry: Database alias = WASLOOP Database name = WAS Local database directory = /home/ctsui Database release level = 9.00 Comment = Directory entry type = Indirect Catalog node number = 0
要验证 catalog db 命令正常工作,发出下列两个命令(并查看以下样本输出):
db2 connect to wasloop db2 connect to was
其中 db2 connect to wasloop 将打印连接信息,而 db2 connect to was 将产生 SQL1403N。
db2 connect to wasloop 的样本输出:
Database Connection Information System Database Directory Database server = DB2/6000 6.1.0 SQL authorization ID = CTSUI Local database alias = WASLOOP
db2 connect to was 的样本输出:
Database Connection Information System Database Directory Database server = DB2/6000 6.1.0 SQL authorization ID = CTSUI Local database alias = WAS
db2 update dbm cfg using authentication client
要验证该命令正常工作,使用以下命令显示新设置:
db2 get dbm cfg
样本输出:
.... Database manager authentication (AUTHENTICATION) = CLIENT ....
db2stop db2start
注意:您可能需要使用 db2stop force 来关闭所有活动的数据库连接。
例如,db2 attach to MYNODE user myid using mypasswd db2 drop db WAS