#include "stdafx.h"
#include <iostream>
using namespace std;
#include <stdio.h>
#include <Windows.h>
#define OTL_ODBC
#include "otlv4.h"
UINT run(LPVOID pd)
{
otl_connect db; // connect object
try{
// db.rlogon("Driver={Microsoft ODBC for Oracle};ConnectString=MYTEST;Uid=sms;Pwd=sms;");无法关闭连接,内存泄露
db.rlogon("Driver={Oracle in OraClient11g_home1};Dbq=MYTEST;Uid=sms;Pwd=sms;",1);//正常关闭.
}
catch(otl_exception& p){ // intercept OTL exceptions
cerr<<p.msg<<endl; // print out error message
cerr<<p.stm_text<<endl; // print out SQL that caused the error
cerr<<p.var_info<<endl; // print out the variable that caused the error
}
//db.commit();
db.logoff(); // disconnect from Oracle
return 0;
}
int main()
{
//otl_connect::otl_initialize(); // initialize OCI environment
while(1)
{
run(NULL);
Sleep(1);
}
}
结果测试 如果使用OTL ODBC 连接 ORACLE ,并且使用微软自带的驱动,就会出问题,无法释放内存,内存会持续飙升,可能是由于Microsoft ODBC for Oracle驱动太老了,无法适应新的oracle,
所以如果你使用OTL ODBC连接 ORACLE数据库,建议使用官方驱动.