📄 dbapi.hpp
字号:
// Delete statement for cursor virtual void Delete(const string& table) = 0; // Cancel cursor virtual void Cancel() = 0; // Close cursor virtual void Close() = 0; // Get the parent connection // NOTE: if the original connections was cloned, returns cloned // connection virtual class IConnection* GetParentConn() = 0;};///////////////////////////////////////////////////////////////////////////////// IBulkInsert:://// Interface for bulk insert//class NCBI_DBAPI_EXPORT IBulkInsert{public: virtual ~IBulkInsert(); // Bind columns virtual void Bind(unsigned int col, CVariant* v) = 0; // Add row to the batch virtual void AddRow() = 0; // Store batch of rows virtual void StoreBatch() = 0; // Cancel bulk insert virtual void Cancel() = 0; // Complete batch virtual void Complete() = 0; // Close virtual void Close() = 0;};///////////////////////////////////////////////////////////////////////////////// IConnection:://// Interface for a database connection//class NCBI_DBAPI_EXPORT IConnection {public: enum EConnMode { eBulkInsert = I_DriverContext::fBcpIn, ePasswordEncrypted = I_DriverContext::fPasswordEncrypted }; // Destructor virtual ~IConnection(); // Connection modes virtual void SetMode(EConnMode mode) = 0; virtual void ResetMode(EConnMode mode) = 0; virtual unsigned int GetModeMask() = 0; // Force single connection mode, default false // NOTE: disable this mode before using BLOB output streams // from IResultSet, because extra connection is needed // in this case virtual void ForceSingle(bool enable) = 0; // Get parent datasource object virtual IDataSource* GetDataSource() = 0; // Connect to the database virtual void Connect(const string& user, const string& password, const string& server, const string& database = kEmptyStr) = 0; // Clone existing connection. All settings are copied except // message handlers virtual IConnection* CloneConnection() = 0; // Set current database virtual void SetDatabase(const string& name) = 0; // Get current database virtual string GetDatabase() = 0; // Check if the connection is alive virtual bool IsAlive() = 0; // NEW INTERFACE: no additional connections created // while using the next four methods. // Objects obtained with these methods can't be used // simultaneously (like opening cursor while a stored // procedure is running on the same connection) // Get statement object for regular SQL queries virtual IStatement* GetStatement() = 0; // Get callable statement object for stored procedures virtual ICallableStatement* GetCallableStatement(const string& proc, int nofArgs = 0) = 0; // Get cursor object virtual ICursor* GetCursor(const string& name, const string& sql, int nofArgs = 0, int batchSize = 1) = 0; // Create bulk insert object virtual IBulkInsert* GetBulkInsert(const string& table_name, unsigned int nof_cols) = 0; // END OF NEW INTERFACE // Get statement object for regular SQL queries virtual IStatement* CreateStatement() = 0; // Get callable statement object for stored procedures virtual ICallableStatement* PrepareCall(const string& proc, int nofArgs = 0) = 0; // Get cursor object virtual ICursor* CreateCursor(const string& name, const string& sql, int nofArgs = 0, int batchSize = 1) = 0; // Create bulk insert object virtual IBulkInsert* CreateBulkInsert(const string& table_name, unsigned int nof_cols) = 0; // Close connection virtual void Close() = 0; // If enabled, redirects all error messages // to CDB_MultiEx object (see below) virtual void MsgToEx(bool v) = 0; // Returns all error messages as a CDB_MultiEx object virtual CDB_MultiEx* GetErrorAsEx() = 0; // Returns all error messages as a single string virtual string GetErrorInfo() = 0; // Returns the internal driver connection object virtual CDB_Connection* GetCDB_Connection() = 0;};///////////////////////////////////////////////////////////////////////////////// IDataSource:://// Interface for a datasource//class NCBI_DBAPI_EXPORT IDataSource{ friend class CDriverManager;protected: // Prohibit explicit deletion. Use CDriverManager::DestroyDs() call virtual ~IDataSource();public: // Get connection virtual IConnection* CreateConnection() = 0; virtual void SetLoginTimeout(unsigned int i) = 0; // Set the output stream for server messages. // Set it to zero to disable any output and collect // messages in CDB_MultiEx (see below) virtual void SetLogStream(ostream* out) = 0; // Returns all server messages as a CDB_MultiEx object virtual CDB_MultiEx* GetErrorAsEx() = 0; // Returns all server messages as a single string virtual string GetErrorInfo() = 0; // Returns the pointer to the general driver interface virtual I_DriverContext* GetDriverContext() = 0;};END_NCBI_SCOPE/* @} *//* * =========================================================================== * $Log: dbapi.hpp,v $ * Revision 1000.3 2004/06/01 19:17:52 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.30 * * Revision 1.30 2004/04/26 14:17:40 kholodov * Added: ExecuteQuery() method * * Revision 1.29 2004/04/22 15:15:09 kholodov * Added: PurgeResults() * * Revision 1.28 2004/04/22 14:22:51 kholodov * Added: Cancel() * * Revision 1.27 2004/03/09 20:37:37 kholodov * Added: four new public methods * * Revision 1.26 2003/12/15 20:05:40 ivanov * Added export specifier for building DLLs in MS Windows. * * Revision 1.25 2003/11/18 17:32:26 ucko * Make IConnection::CloneConnection pure virtual. * * Revision 1.24 2003/11/18 17:00:36 kholodov * Added: CloneConnection() method to IConnection interface * * Revision 1.23 2003/09/10 18:28:04 kholodov * Added: GetCDB_Connection() method * * Revision 1.22 2003/05/16 20:17:01 kholodov * Modified: default 0 arguments in PrepareCall() * * Revision 1.21 2003/04/11 17:45:55 siyan * Added doxygen support * * Revision 1.20 2003/03/07 21:22:31 kholodov * Added: IsAlive() method * * Revision 1.19 2003/02/12 15:53:23 kholodov * Added: WasNull() method * * Revision 1.18 2003/02/10 17:17:15 kholodov * Modified: made IDataSource::dtor() non-public * * Revision 1.17 2002/11/27 17:21:30 kholodov * Added: Error output redirection to CToMultiExHandler object * in IConnection interface. * * Revision 1.16 2002/10/31 22:37:12 kholodov * Added: DisableBind(), GetColumnNo(), GetTotalColumns() methods * * Revision 1.15 2002/10/21 20:38:17 kholodov * Added: GetParentConn() method to get the parent connection from IStatement, * ICallableStatement and ICursor objects. * * Revision 1.14 2002/10/04 12:53:20 kholodov * Fixed: IStatement::SetParam() accepts both imput and output parameters * * Revision 1.13 2002/10/03 18:51:03 kholodov * Added: IStatement::ExecuteLast() method * Added: IBulkInsert::Close() method * * Revision 1.12 2002/09/30 20:45:38 kholodov * Added: ForceSingle() method to enforce single connection used * * Revision 1.11 2002/09/23 18:24:12 kholodov * Added: IDataSource: GetErrorInfo() and GetErrorAsEx() methods. * Added: IConnection: GetDataSource() method. * * Revision 1.10 2002/09/16 19:34:41 kholodov * Added: bulk insert support * * Revision 1.9 2002/09/09 20:49:49 kholodov * Added: IStatement::Failed() method * * Revision 1.8 2002/08/26 15:37:58 kholodov * Added EAllowLog general purpose enum. * Modified GetBlobOStream() methods to allow disabling transaction log while updating BLOBs * * Revision 1.7 2002/07/08 15:57:53 kholodov * Added: GetBlobOStream() for BLOB updates to ICursor interface * * Revision 1.6 2002/04/25 13:35:05 kholodov * Added GetDriverContext() returning pointer to underlying I_DriverContext interface * * Revision 1.5 2002/04/05 19:36:16 kholodov * Added: IResultset::GetVariant(const string& colName) to retrieve * column values by column name * Added: ICallableStatement::ExecuteUpdate() to skip all resultsets returned * if any * * Revision 1.4 2002/02/08 22:43:12 kholodov * Set/GetDataBase() renamed to Set/GetDatabase() respectively * * Revision 1.3 2002/02/08 21:29:55 kholodov * SetDataBase() restored, connection cloning algorithm changed * * Revision 1.2 2002/02/08 17:47:35 kholodov * Removed SetDataBase() method * * Revision 1.1 2002/01/30 14:51:24 kholodov * User DBAPI implementation, first commit * * =========================================================================== */#endif /* DBAPI___DBAPI__HPP */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -