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 > Determining which database you are connected to

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-02-04, 09:06
spgreenw spgreenw is offline
Registered User
 
Join Date: Dec 2003
Posts: 4
Determining which database you are connected to

Any ideas how I determine which database I am connected to through a simple command/s?

Example: If I am using a telnet session and have connected to a database TESTDB. I open up another telnet session and connect to DEVDB.

If I lose track of which window is connected to which database, is there a command I can use?

I can do a 'list applications' to show all application connections but this does not help.

Any ideas?

Thanks.
Reply With Quote
  #2 (permalink)  
Old 03-02-04, 09:11
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: Determining which database you are connected to

db2 connect
or
db2 get connection state
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 03-03-04, 04:11
disaster disaster is offline
Registered User
 
Join Date: Feb 2004
Posts: 24
Re: Determining which database you are connected to

hi,

if u are connected to a udb for windows database the statement

select current server
from sysibm.sysdummy1;

will return the database u are connected to.

i'm just trying to execute the same statement on db2 for z/os
but the gateway is currently down. result is coming later !!!

regards

marc gaines

Quote:
Originally posted by sathyaram_s
db2 connect
or
db2 get connection state
Reply With Quote
  #4 (permalink)  
Old 03-03-04, 05:09
spgreenw spgreenw is offline
Registered User
 
Join Date: Dec 2003
Posts: 4
Thanks for your answers. That's fantastic.

Your commands have helped me greatly. I was looking for a way to test the current database connection in a shell script before doing any destructive actions ie.DELETE FROM.

I know I can do CONNECT RESET, TERMINATE etc, but due to a problem we experienced earlier this week we want to be certain we are connected to the right database.

I'm sure you know, but in case you don't; if you have a shell script that fails in connecting to a database, the script will continue (obviously only if you don't have error checking in it!) and use the underlying telnet database connection if you have one.

Thanks again.
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