Link to home
Start Free TrialLog in
Avatar of hraja77
hraja77

asked on

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.
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

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"
Avatar of hraja77
hraja77

ASKER

i still get the same error
Avatar of hraja77

ASKER

i actually get DB21061E  Command line environment not initialized
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
ASKER CERTIFIED SOLUTION
Avatar of mustaccio
mustaccio
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hraja77

ASKER

thanks