程序调用ORACLE的OCCI接口的内部函数报错,请大侠指导!

和平战马 2013-09-23 05:27:21
主机:HP-UX B.11.31 U ia64 (td)
用gdb调试程序的时候报下面错误,请大侠指导一下。谢谢!

在调用ORACLE的OCCI接口的内部函数报的错误:
m_pStmt = m_pDBConn->m_pConn->createStatement(strSQL);

程序运行调试的日志:
CDataBase Copy Constructor Called!
aCC runtime: pure virtual function called for class "oracle::occi::Connection".

Program received signal SIGABRT, Aborted
si_code: 0 - .
0x9fffffffbd20c970:0 in _lwp_kill+0x30 () from /usr/lib/hpux64/libpthread.so.1
(gdb) where
#0 0x9fffffffbd20c970:0 in _lwp_kill+0x30 ()
from /usr/lib/hpux64/libpthread.so.1
#1 0x9fffffffbd1772a0:0 in pthread_kill+0x990 ()
from /usr/lib/hpux64/libpthread.so.1
#2 0x9fffffffbc7f8080:0 in raise+0xe0 () from /usr/lib/hpux64/libc.so.1
#3 0x9fffffffbc9089b0:0 in abort+0x170 () from /usr/lib/hpux64/libc.so.1
#4 0x9fffffffbcf55c00:0 in __cxa_pure_virtual+0xe0 ()
from /usr/lib/hpux64/libCsup.so.1
#5 0x4000000000121010:0 in CBindSQL::Open (this=0x9fffffffffffc580,
strSQL=@0x9fffffffffffc568, eSQLType=0) at COracleDB.cpp:2706
#6 0x40000000001ccf80:0 in O_RecreateFile::LoadFileFormate (
this=0x9fffffffffffe4b0, nDsID=1501) at o_recreatefile.cpp:33
#7 0x4000000000165000:0 in main (argc=7, argv=0x9ffffffffffff168)
at DSAllot.cpp:185
(gdb) bt
#0 0x9fffffffbd20c970:0 in _lwp_kill+0x30 ()
from /usr/lib/hpux64/libpthread.so.1
#1 0x9fffffffbd1772a0:0 in pthread_kill+0x990 ()
from /usr/lib/hpux64/libpthread.so.1
#2 0x9fffffffbc7f8080:0 in raise+0xe0 () from /usr/lib/hpux64/libc.so.1
#3 0x9fffffffbc9089b0:0 in abort+0x170 () from /usr/lib/hpux64/libc.so.1
#4 0x9fffffffbcf55c00:0 in __cxa_pure_virtual+0xe0 ()
from /usr/lib/hpux64/libCsup.so.1
#5 0x4000000000121010:0 in CBindSQL::Open (this=0x9fffffffffffc580,
strSQL=@0x9fffffffffffc568, eSQLType=0) at COracleDB.cpp:2706
#6 0x40000000001ccf80:0 in O_RecreateFile::LoadFileFormate (
this=0x9fffffffffffe4b0, nDsID=1501) at o_recreatefile.cpp:33
#7 0x4000000000165000:0 in main (argc=7, argv=0x9ffffffffffff168)
at DSAllot.cpp:185
...全文
130 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
aizibion 2013-09-23
  • 打赏
  • 举报
回复
char sSql[1024]; //CRecordset Rs(_mDB); CBindSQL Rs(_pDb); try { sprintf(sSql,"SELECT * FROM TABLE_DS_DEF A WHERE A.DS_ID = %d ", nDsID ); 这里可能会出点问题,因为sSql没有初始化,格式化后,这个字串的内容可能因为没结束符而随机,你检查下,或者在sprintf用memset初始化一下。
和平战马 2013-09-23
  • 打赏
  • 举报
回复
DSAllot.cpp: int main( int argc, char *argv[] ) { CDataBase Db; //------处理BI15文件改名问题----------- CIniFile desini; string strUsername, strDBName, strPassword; if( bCreateFile ) { strUsername = desini.GetValue( "schoracle", "schorauser" ); strPassword = desini.GetValue( "schoracle", "schorapassword" ); strDBName = desini.GetValue( "schoracle", "schoraname" ); try { Db.Connect(strUsername.c_str(),strPassword.c_str(),strDBName.c_str(),1,100); } catch(CDBException &e) { sprintf(sLogMsg,"Initialize database env fail:%s", e.GetErrorMsg().c_str()); } oRecreateFile.SetDbConnection(Db); if(oRecreateFile.LoadFileFormate( nDsID ) ){ } } } catch( CConException& e ) { Db.Disconnect(); return -1; } return 0; } o_recreatefile.cpp: bool O_RecreateFile::LoadFileFormate( int nDsID ){ char sSql[1024]; //CRecordset Rs(_mDB); CBindSQL Rs(_pDb); try { sprintf(sSql,"SELECT * FROM TABLE_DS_DEF A WHERE A.DS_ID = %d ", nDsID ); Rs.Open(sSql,SELECT_QUERY); Rs.Execute(sSql); Rs.Close(); } catch(CDBException &e) { Rs.Close(); sprintf( _sLogMsg,"读取数据源定义失败:%s",e.GetErrorMsg().c_str()); throw CConException(9009,ERR_BADLY,_sLogMsg); } return true; } COracleDB.cpp: int CBindSQL::Open(const string& strSQL, int eSQLType) { Close(); if(strSQL.empty()) { string strMethodName = "int CBindSQL::Open(const string& strSQL, int eSQLType)"; m_iErrorCode = INVALID_PARAMETER; m_strErrorMsg = strMethodName + " Call Invalid!SQL String is NULL"; if(m_bOutputErrorMsg) { cerr<<strMethodName + " Call Invalid!"<<endl; cerr<<"Code: "<<m_iErrorCode<<" Msg: "<<m_strErrorMsg<<endl; } Close(); THROW_EXCEPTION(m_iErrorCode, m_strErrorMsg); } if(m_pDBConn->m_pConn == NULL) { string strMethodName = "int CBindSQL::Open(const string& strSQL, int eSQLType)"; m_iErrorCode = INVALID_PRE_CONDITION; m_strErrorMsg = strMethodName + " Call Invalid!BindSQL not connected to database yet"; if(m_bOutputErrorMsg) { cerr<<strMethodName<<" Call Invalid!"<<endl; cerr<<"Code: "<<m_iErrorCode<<" Msg: "<<m_strErrorMsg<<endl; } Close(); THROW_EXCEPTION(m_iErrorCode, m_strErrorMsg); } if(eSQLType != SELECT_QUERY && eSQLType != NONSELECT_DML && eSQLType != FUNCTION_OR_PROCEDURE && eSQLType != SQL_DDL) { string strMethodName = "int CBindSQL::Open(const string& strSQL, int eSQLType)"; m_iErrorCode = INVALID_PARAMETER; m_strErrorMsg = strMethodName + " Call Invalid!parameter sql type not valid "; if(m_bOutputErrorMsg) { cerr<<strMethodName<<" Call Invalid!"<<endl; cerr<<"Code: "<<m_iErrorCode<<" Msg: "<<m_strErrorMsg<<endl; } Close(); THROW_EXCEPTION(m_iErrorCode, m_strErrorMsg); } if(m_eSQLType != INVALID_TYPE) { string strMethodName = "int CBindSQL::Open(const string& strSQL, int eSQLType)"; m_iErrorCode = INVALID_PARAMETER; m_strErrorMsg = strMethodName + " Call Invalid!parameter sql type not initialized, Maybe Re-Open before Closed, Please Close First!"; if(m_bOutputErrorMsg) { cerr<<strMethodName<<" Call Invalid!"<<endl; cerr<<"Code: "<<m_iErrorCode<<" Msg: "<<m_strErrorMsg<<endl; } Close(); THROW_EXCEPTION(m_iErrorCode, m_strErrorMsg); } m_eSQLType = eSQLType; try { if(m_eSQLType == SELECT_QUERY) { m_pStmt = m_pDBConn->m_pConn->createStatement(strSQL); //For SELECT Query to enhance performance, set the number of rows to prefetch in each round-trip to the server m_pStmt->setPrefetchRowCount(PREFETCH_ROW_COUNT); } else if(m_eSQLType == NONSELECT_DML) { m_pStmt = m_pDBConn->m_pConn->createStatement(strSQL); } else if(m_eSQLType == SQL_DDL) { m_pStmt = m_pDBConn->m_pConn->createStatement(strSQL); } else if(m_eSQLType == FUNCTION_OR_PROCEDURE) { if(GetProcInfo(strSQL) == 0) { string strProcSQL = GetExecuteProcSQL(strSQL); m_pStmt = m_pDBConn->m_pConn->createStatement(strProcSQL); } } else; int nParamCount = FigureInputParamCount(strSQL, eSQLType); SetInputParamCount(nParamCount); m_iErrorCode = 0; m_strErrorMsg = "Success"; } catch(SQLException ex) { string strMethodName = "int CBindSQL::Open(const string& strSQL, int eSQLType)"; m_iErrorCode = ex.getErrorCode(); m_strErrorMsg = ex.getMessage(); if(m_bOutputErrorMsg) { cerr<<strMethodName<<" Failed! SQL String: "<<strSQL<<endl; cerr<<"Code: "<<m_iErrorCode<<" Msg: "<<m_strErrorMsg << endl; } Close(); THROW_EXCEPTION(m_iErrorCode, m_strErrorMsg); } return m_iErrorCode; }
aizibion 2013-09-23
  • 打赏
  • 举报
回复
看堆栈跟你的代码对不上,你贴多点代码吧

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧