Re: How to use tnsping programmatically



Comments embedded.
On Apr 8, 8:43 am, "Strange Cat @ Work" <du...@xxxxxxxxx> wrote:
You can call tnsping from a shell script or a program, but how often
are you planning on running this check?
How often were you running your last check that managment or the
network team asked you not to run?
There is generally no real need to continuously check to see if the
database is there.  If the database is not there you will know in
fairly short order when the phone calls start coming in.  From within
an application you can just check the return code on the connect
call.  If the connect fails you will get an error code and you can
pass this on to an alert system (feature) to provide the database down/
unreachable error information.

Thanx for answering Mark,

the need is to avoid attempting the connection if the Oracle instance
appears to be unreachable.

Simply because you can tnsping the listener doesn't mean the database
is available.

We're developing a panel pc app that has to
connect to an Oracle server on demand (user touching screen and booking for
canteen).


Again, just because you can tnsping the listener does not guarantee
you can connect to the Oracle database, so your tnsping effort may
succeed only to have the users receive the following error:

ERROR:
ORA-12514: TNS:listener does not currently know of service requested
in connect descriptor

Or this error, if the database is hard-coded into the listener.ora
file:

ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist

Problem is that the Oracle server happens to be on the other side of the
mountains (and this is for real, no joke) and we've been warned about lack
of connectivity/bandwidth on this connection.

Yes, the tnsping utility *can* prove you do have connectivity to the
server if the listener is up. If the listener is down you'll receive
an ORA-12541 error, which might indicate you can get to the server,
and it might not.


So, to make a long story short, what i'm trying to do is avoid connection
(and users waiting for a timeout to occur in front of pc) if Oracle is not
tnspingable...


Again I say that simply because tnsping returns error-free doesn't
mean your database is running or that a connection attempt will be
successful. Honestly I am not being negative, I am just trying to
provide a realistic view of this situation.

Other ideas are welcome, of course :)

HTH -- Mark D Powell --

Thanx again
Paolo


David Fitzjarrell
.



Relevant Pages

  • RE: ADO.Net Connection Pooling Problem with Oracle
    ... the CLR is releasing the connection to your database. ... the number of database sessions in Oracle seem to ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Connecting to an Oracle Database
    ... You can also use FrontPage, ... Click Add to Catalog under "Database Connections" ... Put in your Oracle connection string in the custom connections dialog ...
    (microsoft.public.sharepoint.windowsservices)
  • RE: Query Oracle, show results (need help!!)
    ... After the DB connection, put this... ... I am trying to log into an Oracle database, ... Prepare the SQL statement for running and it'll be stored in Oracle buffer ...
    (perl.beginners)
  • ADO connection to Oracle
    ... the runtime version, however, the program terminates with no error ... The program always stops at the connection to the database. ... connection is made using generic OLE DB, not the Oracle data provider. ...
    (microsoft.public.vb.database.ado)
  • Re: tnsping fails, yet sqlplus connects
    ... Copyright 1997, 2005, Oracle. ... My expectation is that if TNSPING fails, so should an actual connection ... Are you running the tnsping and sqlplus from the same machine (server ...
    (comp.databases.oracle.server)