IDE用的Code::Blocks,编译环境TDM-GCC,算是mingw的一个分支版本吧,OTL已经更新到最新版本了
代码也是照着OTL文档写的,编译、链接都没问题
包含文件时,用了OTL_ORA10G_R2宏定义,如下:
#defineOTL_ORA10G_R2
#include"otl/otlv4.h"
现在的问题是,rlogon失败后,抛出异常,但是otl_exception::code为0,otl_exception::msg为空字符串,无法获取到错误信息
使用VC编译同样代码,otl_exception::code实际为12154
在Code::Blocks里调试代码,发现是这里的问题:
voidrlogon(constchar*connect_str,constintauto_commit=0)
{
throw_count=0;
retcode=connect_struct.rlogon(connect_str,auto_commit);
if(retcode)
connected=1;
else{
connected=0;
increment_throw_count();
if(get_throw_count()>1)return;
if(otl_uncaught_exception())return;
OTL_TMPL_EXCEPTIONex(connect_struct);
connect_struct.cleanup();
throwex;
}
}
OTL_TMPL_EXCEPTIONex(connect_struct);本应调用otl_tmpl_exception的构造函数:
otl_tmpl_exception(TConnectStruct&conn_struct,constchar*sqlstm=0)
#ifdefined(__GNUC__)&&(__GNUC__>=3)
throw()
#else
OTL_NO_THROW
#endif
{
stm_text[0]=0;
var_info[0]=0;
if(sqlstm){
OTL_STRNCPY_S(OTL_RCAST(char*,stm_text),
sizeof(stm_text),
sqlstm,
sizeof(stm_text)-1);
stm_text[sizeof(stm_text)-1]=0;
}
conn_struct.error(OTL_SCAST(TExceptionStruct&,*this));
OTL_TRACE_EXCEPTION(this->code,this->msg,this->stm_text,this->var_info)
}
但是下断点,甚至放了个assert(0);在里面,都发现根本没进这个函数(VC下调试是进了该函数的)
于是修改otl这个头文件,加了个voidCopy(TConnectStruct&conn_struct,constchar*sqlstm=0)函数
在OTL_TMPL_EXCEPTIONex(connect_struct);之后添加ex.Copy(connect_struct),终于执行相应代码了
结果结果……conn_struct.error(OTL_SCAST(TExceptionStruct&,*this));这一句又进不去了!
茫然啊,如果在数据库操作失败时无法获得实际的错误码和错误描述的话,但这个代码根本就没实用价值。
求帮忙。。。
分 --> |