If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Connection lost by Command Prompt - DB21061E Command line environment not initialize

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-29-04, 09:05
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
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
Reply With Quote
  #2 (permalink)  
Old 07-05-04, 03:25
brat4 brat4 is offline
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old 07-05-04, 05:21
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
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
Reply With Quote
  #4 (permalink)  
Old 07-05-04, 06:12
brat4 brat4 is offline
Registered User
 
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 06:16.
Reply With Quote
  #5 (permalink)  
Old 07-05-04, 06:51
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
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.
Reply With Quote
  #6 (permalink)  
Old 07-05-04, 07:24
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On