iconnection.h

来自「Oracle OCI 应用」· C头文件 代码 · 共 81 行

H
81
字号

/**
 * IConnection.h
 *
 * @author aizy
 * @date 2004-11-24
 */

#ifndef _DB_ICONNECTION_H_
#define _DB_ICONNECTION_H_

#include <vector>
#include <string>

#include "IStatement.h"
#include "ICallableStatement.h"

namespace db {

/**
 * 数据库连接接口
 */
class IConnection {
protected:
	virtual ~IConnection(){};

public:
	/**
	 * 创建CallableStatement
	 * 注意:该函数只负责创建ICallableStatement,不负责对其进行释放;
	 *       调用者需要在外部进行释放,调用ICallableStatement的Close函数
	 *       进行释放。
	 *
	 * @param sql sql语句
	 * @return ICallableStatement
	 * @throw SqlException 数据库访问错误时抛出该异常
	 */
	virtual ICallableStatement *PrepareCall(const std::string &sql) = 0;

	/**
	 * 创建IStatement
	 * 注意:该函数只负责创建IStatement,不负责对其进行释放;
	 *       调用者需要在外部进行释放,调用IStatement的Close函数
	 *       进行释放。
	 *
	 * @return IStatement
	 * @throw SqlException 数据库访问错误时抛出该异常
	 */
	virtual IStatement *CreateStatement() = 0;

	/**
	 * 关闭连接
	 * 注意:该函数内部需要释放IConnection实例
	 */
	virtual void Close() = 0;

	/**
	 * 设置提交模式
	 */
	virtual void SetAutoCommit(bool autoCommit) = 0;

	/**
	 * 取提交模式
	 */
	virtual bool GetAutoCommit() = 0;

	/**
	 * 提交在该连接上所做的所有操作
	 */
	virtual void Commit() = 0;

	/**
	 * 回滚在该连接上所做的所有操作
	 */
	virtual void Rollback() = 0;
};

}

#endif //_DB_ICONNECTION_H_

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?