db2 A database connection does not exist

claire_wu 2010-05-27 04:47:20
我写了段代码:
void func(void){
system("db2cmd -c -w -i db2 connect to Q10F user QADMIN using QADMIN");
system("db2cmd -c -w -i db2 -tvf IRM_DB_setup.sql");
}

但出错:DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL1024N A database connection does not exist. SQLSTATE=08003

实际上数据库连接成功了, 但是第二语句好像和第一个语句不在一个session.

请问如何解决?
...全文
1244 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
claire_wu 2010-05-28
  • 打赏
  • 举报
回复
我在程序里面将下面两个语句写道临时文件temp.bat里面:
db2 connect to Q10F user QADMIN using QADMIN
db2 -tvf IRM_DB_setup.sql

然后执行system("db2cmd -c -w -i temp.bat")可以解决这个问题,也许不是最好的解决方案。
claire_wu 2010-05-27
  • 打赏
  • 举报
回复
请问怎么合成?
我尝试了几种方法都失败了。。。
iihero_ 2010-05-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 claire_wu 的回复:]

谢谢回复,我自己代码里面已经获取状态了,删了这些code,只是为了让大家看起来更直观, 这些代码只是我代码的一部分哦
[/Quote]
好的。
建议两条命令合成一个。应该可以的。
claire_wu 2010-05-27
  • 打赏
  • 举报
回复
谢谢回复,我自己代码里面已经获取状态了,删了这些code,只是为了让大家看起来更直观, 这些代码只是我代码的一部分哦
iihero_ 2010-05-27
  • 打赏
  • 举报
回复
与其这样,还不如使用一个批处理。
system(,,,),返回值的状态也不去获取,这代码不能这么写的。
Delphi 7.1 Update Release Notes=======================================================This file contains important supplemental and late-breakinginformation that may not appear in the main productdocumentation, and supersedes information contained in otherdocuments, including previously installed release notes.Borland recommends that you read this file in its entirety.NOTE: If you are updating a localized version of Delphi 7, visit the Borland Registered User web site to obtain a localized readme file that may contain important late- breaking information not included in this readme file.IMPORTANT: Delphi must be closed before installing this update. =====================================================CONTENTS * INSTALLING THIS UPDATE * UPDATING LOCALIZED VERSIONS OF DELPHI 7 * KNOWN ISSUES * ISSUES ADDRESSED BY THIS UPDATE - IDE - CORE DATABASE - DATASNAP - DBGO (ADO COMPONENTS) - dbExpress - dbExpress COMPONENTS AND DB VCL - dbExpress CORE DRIVER AND METADATA - dbExpress VENDOR ISSUES - dbExpress CERTIFICATION - WEB SNAP - ACTIVEX - COMPILER - RTL - VCL - THIRD PARTY - BOLD FOR DELPHI * VERIFYING THAT THE UPDATE WAS SUCCESSFUL * FILES INSTALLED BY THIS UPDATE =======================================================INSTALLING THIS UPDATE* This update can not be applied to Delphi 7 Architect Trial version. * This update can not be removed after it is installed.* You will need the original Delphi 7 installation CD available to install this update.* To install this update from the CD, insert the CD, and launch the d7_ent_upd1.exe file appropriate for your locale.* To install this update from the Web, double-click the self-executing installation file and follow the prompts. * The Delphi 7 documentation PDF files are available on the update CD.========================================================UPDATING LOCALIZED VERSIONS OF DELPHI 7* This update can be applied only to the English version of Delphi 7. There are separate updates for the German, French and Japanese ver

5,889

社区成员

发帖
与我相关
我的任务
社区描述
IBM DB2 是美国IBM公司开发的一套关系型数据库管理系统,它主要的运行环境为UNIX(包括IBM自家的AIX)、Linux、IBM i(旧称OS/400)、z/OS,以及Windows服务器版本
社区管理员
  • DB2
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧