Figure 3-1. class Connection
namespace Oracle
{
class Connection
{
public:
// types
enum status_t { not_connected, connected };
// constructors/destructor
Connection(
const string&,
const string&,
const string& = "");
Connection(const string&);
virtual ~Connection();
// implementors
virtual void open();
virtual Stmt* prepare(const string&);
virtual void rollback();
virtual void commit();
virtual void close();
friend class Stmt;
};
}Connection(const string& connect_string);
Connection(const string& username, const string& password, const string& database_name);
The first form takes a standard Oracle connect string of the form "username/password@database". The second form takes the username, password and database name as separate arguments and is deprecated. The constructors simply initialize the object's data members; no connection is attempted.
This function rolls back any pending transactions and disconnects from the server.
This method takes as its single argument a string containing a SQL statement and returns a pointer to a Stmt object. The actual type of object created is either Select_Stmt or Non_Sel_Stmt.
The prepare() method creates a Stmt object with new, so the user must use delete to free the object when it is no longer needed.
This method is most useful for interactive programs where the type of the SQL statement is not known ahead of time. If the type of statement is known, the specific statement type class constructors (Select_Stmt::Select_Stmt() or Non_Sel_Stmt::Non_Sel_Stmt()) are preferred over prepare().