Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Posts
    4

    Unanswered: 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.

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    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.

  3. #3
    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

    Originally posted by sathyaram_s
    db2 connect
    or
    db2 get connection state

  4. #4
    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.

Posting Permissions

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