Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2003
    Posts
    1,605

    Unanswered: Connection lost by Command Prompt - DB21061E Command line environment not initialize

    Hi,

    I am trying to execute batch commands from Windows Command Prompt on DB2 v7.2 fp5 on Windows XP SP1 environment.

    I did:
    1. Start | Run
    2. cmd <enter>
    3. I executed command:
    ECHO %DB2CLP%
    4. The above command returs some numeric number. This number I have put in Windows System Variable as DB2CLP=<number_got_in_step_3>
    5. Then executed db2 commands:
    db2 connect to sample
    db2 select * from db2admin.table
    etc.

    The problem: Waiting for some secounds (e.g. 5 secound) then executing another SQL statement returs the error: "DB21061E Command line environment not initialized.". If I repeat connect command it works fine. Just waiting for some secounds connection is lost. Why does Windows Command Prompt lost connection? What should I do to overcome this problem?

    Thanks,
    Grofaty

  2. #2
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    59
    Not sure why its happening, but have u tried the command window option supplied by db2

    start > programs > db2 > "command Window" . Here I believe you'll have the cmd window pre initialized by db2

    Cheers
    brat.

  3. #3
    Join Date
    Jan 2003
    Posts
    1,605
    Hi,

    brat4, DB2 Command Window works fine, but that is not my problem. I would like just to execute db2 commands from Windows Command Prompt!!! Now I have to execute first batch file to enable db2 environment and inside this first batch file I have to write command to run secound batch file witch has the db2 sql commands.

    I would just like to have ONLY ONE batch file (like on Linux). So my problem is: How to run db2 sql commands from just one batch file?

    Thanks,
    Grofaty

  4. #4
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    59
    Hi
    I guess I mis understood your requirement. But maybe the following link maybe helpful
    https://aurora.vcu.edu/db2help/db2n0/frame3.htm#db2n069

    and

    http://www-106.ibm.com/developerwork...ierros.html#cw

    Specially check the second link for "Calling a DB2 command window from a Wshell script" and the environment variable DB2BQTIME

    Sorry cant be of much help

    cheers
    brat.
    Last edited by brat4; 07-05-04 at 07:16.

  5. #5
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    I would use
    db2cmd /c /w /i db2 -tvf file1.sql

    Refer 'Command Reference' under db2cmd command title for information on the options (I tend to forget ;-) )

    Cheers
    Sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  6. #6
    Join Date
    Jan 2003
    Posts
    1,605
    Hi,

    Sathyaram_s, I know this solution, but this is not what I would like to have. I would like to have only one file - and this file should be the batch file. You wrote a solution with two files: batch and sql file.

    The main problem I have is that I can't read the secound batch file output results in the main batch program. So I would like to have only one batch file like described in my first post. Now my solution works: secound batch file writes the data to temp file and then main batch program reads that file. I would like to get rid of temp file. Because script is so complex that it requires multiple temp files - this is disaster.

    I just can't bealive that there is no solution on Windows, but there it is on Linux?

    My solution from first post works fine, just I have problems of "connection lost" error! Can be something done to overcome this problem.

    Grofaty

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •