db2 windows SQL1024N A database connection does not exist

i run the script and keep getting the error message in the title please help;
all i'm doing is a simple script to see if the database is up;

echo.                                                              
echo Check Database is running (start)                                    
echo.                                                            
echo.
echo. Uses:      
echo.            %LOG_FILE%
echo.            %DB2DATABASE%
                                                            
SETLOCAL



set DB2DATABASE=%1
set LOG_FILE=%2


db2cmd /w /c /i DB2 CONNECT TO %DB2DATABASE%                            
db2 "select 1 from sysibm.sysdummy1"                                                

set BACKUP_CHECK_LEVEL=%errorlevel%                                                                          
if %BACKUP_CHECK_LEVEL% NEQ 0 (
        echo.                                                                                   
        echo *** Database could be down ***                                            >> %LOG_FILE%
        echo.                                                                                   
        Exit 98                                                                                    
     )


ENDLOCAL


echo.                                                              
echo Check Database is running (end)                                    
echo.                                                            
echo.
LVL 1
hraja77Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kent OlsenDBACommented:
I think that I'd just use the *db2* command instead of opening another window.

db2 CONNECT TO %DB2DATABASE%                            
db2 "select 1 from sysibm.sysdummy1"
0
hraja77Author Commented:
i still get the same error
0
hraja77Author Commented:
i actually get DB21061E  Command line environment not initialized
0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Kent OlsenDBACommented:
Ahha.  That's an entirely different issue.  :)

The db2 environment is set up by running the db2profile.  It was created when the db2 client, db2 connect, or the db2 server was installed on your computer.

By default, running command.com (or cmd.exe) does not run the db2 profile.  You can modify your system so that it does, or you can run the command window from the script that was created by db2.

  Start / All Programs / IBM DB2 / DB2COPY1 / command line tools / command window

Better yet, create a shortcut to it on your desktop.


Kent
0
mustaccioCommented:
To add to what Kdo said, you appear to wish to run this script as a batch. In that case you would need to put all your db2 commands, minus db2cmd into a single script, then execute it as
db2cmd /w /c /i yourscript.bat

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hraja77Author Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DB2

From novice to tech pro — start learning today.