Oracle Objects for OLE C++ Class Library Release 9.2 Part Number A95896-01 |
|
Applies To
Description
This method returns the name of the database to which this connection is connected.
Usage
const char *GetDatabaseName(void) const
Remarks
You need three things to connect to an Oracle database: the database name, the username, and the password. GetConnectString returns the username. The password is not available because, for security reasons, the class library (and its implementation objects) do not keep the password. OConnection::GetDatabaseName and ODatabase::GetName return a pointer to the database name.
It is possible for several database objects to share a connection. However, they will not share a connection unless they have the same database name.
The actual memory that the pointer points to is managed by the object. It should not be freed by the caller. It will be freed when the object is destroyed or closed.
Return Value
A valid, null terminated const char pointer on success; NULL on failure.
Example
This example gets the database name.
// we start with a dynaset named empdyn (which is open)
// get the dynaset's connection
OConnection tempconn = empdyn.GetConnection();
// now get the database name
const char *dbname = tempconn.GetDatabaseName();
/*
Note that we must use dbname (or copy it) before tempcon goes out of scope, because tempconn's destructor will free the string.
*/
|
Copyright © 1998, 2002 Oracle Corporation. All Rights Reserved. |
|