⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 db.h

📁 在动态库中实现异步导出大数据量的oracle数据
💻 H
字号:
#ifndef __DB_H_
#define __DB_H_

#include "ocicpp.h"
#include "Connection.h" 

namespace OCICPP {
using std::string;
#if (0)
	dvoid *malloc_func (dvoid * /* ctxp */, size_t size)
		{ return (malloc (size)); }
	dvoid *realloc_func (dvoid * /* ctxp */, dvoid *ptr, size_t size)
		{ return (realloc (ptr, size)); }
	void free_func (dvoid * /* ctxp */, dvoid *ptr)
		{ free (ptr); }
#else
#	define	malloc_func		NULL
#	define	realloc_func	NULL
#	define	free_func		NULL
#endif

class db {
	public:
		static OCIEnv *envhp;
//		static ub4 InitMode;
		// static Connection *con;
/*static void init(ub4 InitMode=OCI_DEFAULT) {
			 (void) OCIInitialize(InitMode, (dvoid *)0, (dvoid * (*)(dvoid *, size_t)) 0,
			                      (dvoid * (*)(dvoid *, dvoid *, size_t))0, (void (*)(dvoid *, dvoid *)) 0 );
			 (void) OCIEnvInit( (OCIEnv **) &db::envhp, OCI_DEFAULT, (size_t) 0,(dvoid **) 0 ); 
		}
*/		
		static void init(ub4 InitMode=OCI_THREADED|OCI_OBJECT) {
		OCIEnvCreate (
		&envhp,
		InitMode,//OCI_DEFAULT,
		NULL,		// context
		malloc_func,	// malloc
		realloc_func,	// realloc
		free_func,		// free
		0,			// extra memory to allocate
		NULL);		// pointer to user-memory

//			 (void) OCIInitialize(InitMode, (dvoid *)0, (dvoid * (*)(dvoid *, size_t)) 0,(dvoid * (*)(dvoid *, dvoid *, size_t))0, (void (*)(dvoid *, dvoid *)) 0 );
//			 (void) OCIEnvInit( (OCIEnv **) &db::envhp, OCI_DEFAULT, (size_t) 0,(dvoid **) 0 ); 
		}

		static Connection *connect(const string &tnsname,const string &user,const string &password) {
			return new Connection(db::envhp,tnsname,user,password);
		}
		static void connect(const string &tnsname,
					   const string &user,
					   const string &password,
					   Connection &con) {
			con.init(db::envhp,tnsname,user,password);
		}
};

}
#endif

⌨️ 快捷键说明

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