Re: How to use tnsping programmatically
Date: Wed, 8 Apr 2009 05:53:55 -0700 (PDT)
Message-ID: <e6de7010-1bfd-4b98-99fa-58de3cf1c915_at_v19g2000yqn.googlegroups.com>
On Apr 8, 3:35�am, "Strange Cat _at_ Work" <du..._at_dummy.com> wrote:
> Hello everyone,
>
> I'd like to know if it is possible to use tnsping programmatically in order
> to check if Oracle server is available... I've been asked not to continuosly
> try connection and disconnection in order to save network/system resources.
>
> I will be using DotNet 2.0SP1 but any clue is welcome.
>
> Thanx in advance
> Paolo
tnsping verifies that the listener is running, and not much else. It doesn't connect to the database so it can't tell you if the database is down or not, as this example proves:
c:\>tnsping sning
TNS Ping Utility for 32-bit Windows: Version 11.1.0.6.0 - Production on 08-APR-2009 07:45:53
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
c:\o_racle\Ora11g\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST
= snarg.dinglebop.net)(PORT = 1521)) (CONNECT_DATA = (SERVER =
DEDICATED)
(SERVICE_NAME = sning)))
OK (40 msec)
c:\>sqlplus /nolog
SQL*Plus: Release 11.1.0.6.0 - Production on Wed Apr 8 07:46:03 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
SQL> connect sys as sysdba
Enter password:
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> host
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
c:\>tnsping sning
TNS Ping Utility for 32-bit Windows: Version 11.1.0.6.0 - Production on 08-APR-2009 07:47:00
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
c:\o_racle\Ora11g\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST
= snarg.dinglebop.net)(PORT = 1521)) (CONNECT_DATA = (SERVER =
DEDICATED)
(SERVICE_NAME = sning)))
OK (20 msec)
c:\>
David Fitzjarrell Received on Wed Apr 08 2009 - 07:53:55 CDT