Database Connection Functions

PostgreSQL 7.2 Documentation
Prev | Chapter 3. libpq++ - C++ Binding Library | Next

# 3.4. Database Connection Functions

- `PgConnection` makes a new connection to a backend database server.

      PgConnection::PgConnection(const char *conninfo)

  The `conninfo` string is the same as for the underlying libpq `PQconnectdb` function.

  Although typically called from one of the access classes, a connection to a backend server is possible by creating a `PgConnection` object.

- `ConnectionBad` returns whether or not the connection to the backend server succeeded or failed.

      bool PgConnection::ConnectionBad() const

  Returns true if the connection failed.

- `Status` returns the status of the connection to the backend server.

      ConnStatusType PgConnection::Status()

  Returns either `CONNECTION_OK` or `CONNECTION_BAD` depending on the state of the connection.

- `PgDatabase` makes a new connection to a backend database server.

      PgDatabase(const char *conninfo)

  After a `PgDatabase` has been created it should be checked to make sure the connection to the database succeeded before sending queries to the object. This can easily be done by retrieving the current status of the `PgDatabase` object with the `Status` or `ConnectionBad` methods.

- `DBName` returns the name of the current database.

      const char *PgConnection::DBName()

- `Notifies` returns the next notification from a list of unhandled notification messages received from the backend.

      PGnotify* PgConnection::Notifies()

  See `PQnotifies` in libpq for details.

Prev | Home | Next
libpq++ Classes | Up | Query Execution Functions