Skip Headers

Oracle® Objects for OLE C++ Class Library Developer's Guide
10g Release 1 (10.1)

Part Number B10119-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Feedback

GetDatabaseName Method

Applies To

OConnection

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.

*/