OCCI-getString error
The following is a small console program written with Visual C++
6.0 sp 4.
The program has a crash when it tries to destruct the
string variable fodt in the while loop.
Is this a known bug or is there an error in the code ?
Bertil Reppen
#include "stdafx.h"
#include <iostream>
//#include <string.h>
#include <occi.h>
using namespace std;
using namespace oracle::occi;
int main(int argc, char* argv[])
const string username = "BERTIL";
const string password = "REPPXX";
const string url = "aoye.apintdom.no";
Environment *env = Environment::createEnvironment (
Environment::DEFAULT);
try
Connection *conn = env->createConnection
(username, password, url);
string sqlQuery = "SELECT pasientnr1,to_char
(FODSELSDATO,'dd-mm-yyyy') FROM pasient_nr";
Statement *stmt = conn->createStatement
(sqlQuery);
ResultSet *rs = stmt->executeQuery ();
while (rs->next ())
long pasno = rs->getInt(1);
string fodt = rs->getString(2);
stmt->closeResultSet (rs);
conn->terminateStatement (stmt);
env->terminateConnection (conn);
catch (SQLException ea)
cout << ea.what();
catch (exception &excp)
cout << excp.what() << endl;
Environment::terminateEnvironment (env);
return 0;
Israel,
Most of these errors do indeed arise from missing/wrong
compilation flags/defines. Check out OCCI samples and
the "make.bat" files in your %ORACLE_HOME%\rdbms\demo directory
for the correct flags, includes, and libraries. Here is an
example,
:occimake
cl -GX -DWIN32COMMON -I. -I%ORACLE_HOME%\oci\include -I. -D_DLL -
D_MT %1.cpp /link /LIBPATH:%ORACLE_HOME%\oci\lib\msvc oci.lib
msvcrt.lib msvcprt.lib oraocci9.lib /nod:libc
Regards,
Geoff
the problem also occurs on VC 6.0 without any service pack.
pay attention that the following expression:
typeid(rs->getString(1)
leads to a compiler internal error (getXXX other than string
works just fine !!!).
this, along with some other testings i've conducted might
indicate that oraocci9.lib has been compiled with stl (or just
string) which differs from the version supplied with msvc.
it also can result from missing/wrong compilation flags/defines.
i'm still working on this.
if anyone finds the answer PLEASE contact me !!!
regards,
Israel Kalush
Similar Messages
-
Oracle10.1.0 and gcc3.4.3 ,getString error
environment:
Red Hat Enterprise Linux AS release 4 (Nahant)
Oracle Database 10g Enterprise Edition Release 10.1.0.3.0
gcc3.4.3
ORACLE_HOME = /u01/app/oracle/product/10.1.0/db_1
compile command is:
g++ -o a.out -I/u01/app/oracle/product/10.1.0/db_1/rdbms/public -L/u01/app/oracle/product/10.1.0/db_1/lib -L/u01/app/oracle/product/10.1.0/db_1/rdbms/lib/ -locci -lclntsh test.cpp
I have a OCCI program test.cpp,
if I use Oracle website's gcc3.2.3's lib,compile is ok,but when use ResultSet's getString, error:*** glibc detected *** double free or corruption (!prev): 0x083f5a98 ***
but when changed to gcc3.4.3's lib, error:
/u01/app/oracle/product/10.1.0/db_1/lib/libocci.so: undefined reference to `OCIClientVersion'
/u01/app/oracle/product/10.1.0/db_1/lib/libocci.so: undefined reference to `OCILobArrayWrite'
/u01/app/oracle/product/10.1.0/db_1/lib/libocci.so: undefined reference to `OCILobArrayRead'
/u01/app/oracle/product/10.1.0/db_1/lib/libocci.so: undefined reference to `OCIPClearMxCtr'
/u01/app/oracle/product/10.1.0/db_1/lib/libocci.so: undefined reference to `OCIPIsStmtSelectForUpdate'
who can help me ?can you please refer this page and try again ?
http://download-east.oracle.com/docs/cd/B19306_01/install.102/b15660/post_inst_task.htm#sthref939 -
Occi GetString causing a exception with ntdll.dll oracle 10g and MS 2005
hi,
I am getting an exception with using Visual Studio 2005(VC++8) and occi.h 10g client.
When I run the release version I get an exception in ntdll.dll.
The problem is in the getString(). The field in the oracle table is defined as a varchar2(300).
I am new to oracle occi and need a solution because we cannot migrate to another version of the database.
These are the solutions I have tried:
download patches for MS Visual studio
download patched for oracle 10g client
Check that the charset it correct for std:string
I see that others have had the same problem but no one has a solution. If anyone has a solution please email me because I have searched for days!
Thanks
SherylAloha
Thank you for your response, I am new to posting, occi and C++. Can I send you the files.
Sorry didnt read this reply until today.
The email is [email protected].
This environment:
1> windows xp
2> MS Studio 5 VC++8
3> OCCI 10.2.0.3.0 (patch 13)libraries for Microsoft Visual C++ 8
4> I am using the Instant Client
5> I am using /MD Multithreaded DLL
6> Charset is oracle::occi::Environment::createEnvironment ("US7ASCII","AL16UTF16",Environment::DEFAULT);
7> We running the application in release mode and getting this error with a bad memory reference on getString().
I am getting a memory reference error on the getString(4).
This is the code that is causing the error
try
string istmt ="SELECT FILE_ID,FILES.FTYP_ID,LTRIM(RTRIM(FILEPATH)),LTRIM(RTRIM(FILENAME)),TITLE FROM FILES,FILE_TYPES WHERE FILE_TYPES.EXTN = 'img'AND file_types.ftyp_id = files.ftyp_id AND FILES.HDR_SCAN_DATE IS NULL ORDER BY FILEPATH, FILENAME ";
ResultSet * set = db->select(istmt);
if (set == NULL)
LogT::Get()->log(Logger::LOG_LEVEL_INFO,"No file to process occured in : %s ", methodName.c_str());
return;
LogT::Get()->log(Logger::LOG_LEVEL_INFO,"Did select in : %s ", methodName.c_str());
while (set->next())
LogT::Get()->log(Logger::LOG_LEVEL_INFO,"Doing a set next in : %s ", methodName.c_str());
if (set->isNull(1) || set->isNull(2) || set->isNull(4) || set->isNull(3))
LogT::Get()->log(Logger::LOG_LEVEL_INFO,"a value is null continue in : %s ", methodName.c_str());
continue;
try {
LogT::Get()->log(Logger::LOG_LEVEL_INFO,"About to get string 3 in : %s ", methodName.c_str());
std::string test(set->getString(3));
fname.assign(test);
LogT::Get()->log(Logger::LOG_LEVEL_INFO,"File name: %s in : %s ",fname.c_str(), methodName.c_str());
} catch (exception ex9) {
LogT::Get()->log(Logger::LOG_LEVEL_ERROR,"Exception in get string msg: occured in : %s ",ex9.what(), methodName.c_str());
continue;
LogT::Get()->log(Logger::LOG_LEVEL_INFO,"getting int 1 in : %s ", methodName.c_str());
fid = set->getInt(1);
LogT::Get()->log(Logger::LOG_LEVEL_INFO,"getting string 4 in : %s ", methodName.c_str());
fn.assign(set->getString(4));
LogT::Get()->log(Logger::LOG_LEVEL_INFO,"after getting string 4 in : %s ", methodName.c_str());
//dont append a slash if not need
size_t pos = fname.find_last_of("\\");
if(pos != fname.length()-1)
fname.append("\\");
fname.append(fn);
LogT::Get()->log(Logger::LOG_LEVEL_INFO,"adding %s to map in : %s ",fname.c_str(), methodName.c_str());
fnames.insert (std::pair<unsigned int,std::string>(fid,fname));
// int ftype = set->getInt(2);
LogT::Get()->log(Logger::LOG_LEVEL_INFO,"got fid:%d, fname:%s fn: %s to map in : %s ",fid,fname.c_str(),fn.c_str(), methodName.c_str());
catch (SQLException ex)
LogT::Get()->log(Logger::LOG_LEVEL_ERROR,"Sql Exception code: %d message: %s occured in : %s ",ex.getErrorCode(),ex.getMessage().c_str(), methodName.c_str());
db->exceptionHandler("SELECT PARAMS",ex.getErrorCode(),ex.getMessage());
throw;
catch (exception ex3)
LogT::Get()->log(Logger::LOG_LEVEL_ERROR,"Exception occured message: %sin : %s ", ex3.what(),methodName.c_str());
db->exceptionHandler("SELECT PARAMS",1,ex3.what());
throw;
catch (...) {
LogT::Get()->log(Logger::LOG_LEVEL_ERROR,"Error occured in : %s ", methodName.c_str());
This is the code for the select in occi
/* Select statement for oracle occi*/
void * OraDb::select(std::string& sqlStr,std::map<std::string,VALUES,classcomp> & val) {
string methodName = "OraDb::select";
ResultSet *selectRset;
try {
this->stmt->setSQL(sqlStr);
this->bind(val);
selectRset = this->stmt->executeQuery ();
oracle::occi::Statement::Status res = this->stmt->status();
while(res != oracle::occi::Statement::RESULT_SET_AVAILABLE) {
LogT::Get()->log(Logger::LOG_LEVEL_INFO,"the results set isnt ready");
res = this->stmt->status();
catch (SQLException ex)
LogT::Get()->log(Logger::LOG_LEVEL_ERROR,"Sql Error in %s code: %d Message:%s",methodName.c_str(),ex.getErrorCode(),ex.getMessage().c_str());
//Add error to error log
this->exceptionHandler(methodName,ex.getErrorCode(),ex.getMessage());
throw;
catch (exception ex3)
LogT::Get()->log(Logger::LOG_LEVEL_ERROR,"Error in %s Message:%s",methodName.c_str(),ex3.what());
this->exceptionHandler(methodName,1,ex3.what());
//Add error to errorlog
throw;
return selectRset;
This is the logs I get
ParamsTb::selectImgParams
in method OraDb::select this is the statement:SELECT FILE_ID,FILES.FTYP_ID,LTRIM(RTRIM(FILEPATH)),LTRIM(RTRIM(FILENAME)),TITLE FROM FILES,FILE_TYPES WHERE FILE_TYPES.EXTN = 'img'AND file_types.ftyp_id = files.ftyp_id AND FILES.HDR_SCAN_DATE IS NULL
Did select in : FilesTb::selectImgFiles
Doing a set next in : FilesTb::selectImgFiles
About to get string 3 in : FilesTb::selectImgFiles
File name: \\e1-stor\Backup Data\Backup Folder Archive (from e1-stor)\MOST-1_backup\CamIRa\fpa\384-for-MnM\ in : FilesTb::selectImgFiles
getting int 1 in : FilesTb::selectImgFiles
getting string 4 in : FilesTb::selectImgFiles
after getting string 4 in : FilesTb::selectImgFiles
adding \\e1-stor\Backup Data\Backup Folder Archive (from e1-stor)\MOST-1_backup\CamIRa\fpa\384-for-MnM\\foeHeaderAirplane.img to map in : FilesTb::selectImgFiles
got fid:4766408, fname:\\e1-stor\Backup Data\Backup Folder Archive (from e1-stor)\MOST-1_backup\CamIRa\fpa\384-for-MnM\\foeHeaderAirplane.img fn: foeHeaderAirplane.img to map in : FilesTb::selectImgFiles
Doing a set next in : FilesTb::selectImgFiles
About to get string 3 in : FilesTb::selectImgFiles
File name: \\e1-stor\Backup Data\Backup Folder Archive (from e1-stor)\MOST-1_backup\HFDS20080826\384-for-MnM\ in : FilesTb::selectImgFiles
getting int 1 in : FilesTb::selectImgFiles
getting string 4 in : FilesTb::selectImgFiles
after getting string 4 in : FilesTb::selectImgFiles
adding \\e1-stor\Backup Data\Backup Folder Archive (from e1-stor)\MOST-1_backup\HFDS20080826\384-for-MnM\\foeHeaderAirplane.img to map in : FilesTb::selectImgFiles
got fid:4778728, fname:\\e1-stor\Backup Data\Backup Folder Archive (from e1-stor)\MOST-1_backup\HFDS20080826\384-for-MnM\\foeHeaderAirplane.img fn: foeHeaderAirplane.img to map in : FilesTb::selectImgFiles
Doing a set next in : FilesTb::selectImgFiles
About to get string 3 in : FilesTb::selectImgFiles
File name: \\e1-stor\Backup Data\Backup Folder Archive (from e1-stor)\workstations\HFDS2-10-1-0-99\c\WINDOWS\system32\drivers\ in : FilesTb::selectImgFiles
getting int 1 in : FilesTb::selectImgFiles
getting string 4 in : FilesTb::selectImgFiles
after getting string 4 in : FilesTb::selectImgFiles
adding \\e1-stor\Backup Data\Backup Folder Archive (from e1-stor)\workstations\HFDS2-10-1-0-99\c\WINDOWS\system32\drivers\\netwlan5.img to map in : FilesTb::selectImgFiles
got fid:4873869, fname:\\e1-stor\Backup Data\Backup Folder Archive (from e1-stor)\workstations\HFDS2-10-1-0-99\c\WINDOWS\system32\drivers\\netwlan5.img fn: netwlan5.img to map in : FilesTb::selectImgFiles
Doing a set next in : FilesTb::selectImgFiles
About to get string 3 in : FilesTb::selectImgFiles
File name: \\e1-stor\Backup Data\Backup Folder Archive (from e1-stor)\workstations\rwolfshagen\c\Resp-C4\ in : FilesTb::selectImgFiles
getting int 1 in : FilesTb::selectImgFiles
getting string 4 in : FilesTb::selectImgFiles
I dumped a few things from last night’s Dr. Watson run, shown below, which may help:
manifest.txt
Server=watson.microsoft.com
UI LCID=1033
Flags=1672016
Brand=WINDOWS
TitleName=ImgHeaderLoader.exe
DigPidRegPath=HKLM\Software\Microsoft\Windows NT\CurrentVersion\DigitalProductId
ErrorText=This error occurred on 6/25/2009 at 1:47:02 AM.
HeaderText=ImgHeaderLoader.exe encountered a problem and needed to close.
Stage1URL=/StageOne/ImgHeaderLoader_exe/0_0_0_0/ntdll_dll/5_2_3790_4455/0002b67d.htm
Stage2URL=/dw/stagetwo.asp?szAppName=ImgHeaderLoader.exe&szAppVer=0.0.0.0&szModName=ntdll.dll&szModVer=5.2.3790.4455&offset=0002b67d
DataFiles=C:\DOCUME~1\ndana\LOCALS~1\Temp\1\WER141d.dir00\ImgHeaderLoader.exe.mdmp|C:\DOCUME~1\ndana\LOCALS~1\Temp\1\WER141d.dir00\appcompat.txt
Heap=C:\DOCUME~1\ndana\LOCALS~1\Temp\1\WER141d.dir00\ImgHeaderLoader.exe.hdmp
ErrorSubPath=ImgHeaderLoader.exe\0.0.0.0\ntdll.dll\5.2.3790.4455\0002b67d
DirectoryDelete=C:\DOCUME~1\ndana\LOCALS~1\Temp\1\WER141d.dir00
appcompat.txt
<?xml version="1.0" encoding="UTF-16"?>
<DATABASE>
<EXE NAME="ImgHeaderLoader.exe" FILTER="GRABMI_FILTER_PRIVACY">
<MATCHING_FILE NAME="common.dll" SIZE="6656" CHECKSUM="0xA0D33EDD" MODULE_TYPE="WIN32" PE_CHECKSUM="0x8ADC" LINKER_VERSION="0x0" LINK_DATE="06/25/2009 00:44:47" UPTO_LINK_DATE="06/25/2009 00:44:47" />
<MATCHING_FILE NAME="FileLoader.exe" SIZE="65536" CHECKSUM="0x15C68C49" MODULE_TYPE="WIN32" PE_CHECKSUM="0x16CC5" LINKER_VERSION="0x0" LINK_DATE="06/23/2009 02:29:33" UPTO_LINK_DATE="06/23/2009 02:29:33" />
<MATCHING_FILE NAME="FileLoaderOriginal.exe" SIZE="65536" CHECKSUM="0x6672AE23" MODULE_TYPE="WIN32" PE_CHECKSUM="0x17E45" LINKER_VERSION="0x0" LINK_DATE="06/20/2009 03:34:40" UPTO_LINK_DATE="06/20/2009 03:34:40" />
<MATCHING_FILE NAME="ImgHeaderLoader.exe" SIZE="118784" CHECKSUM="0xBA94D6AE" MODULE_TYPE="WIN32" PE_CHECKSUM="0x20F4B" LINKER_VERSION="0x0" LINK_DATE="06/24/2009 22:42:49" UPTO_LINK_DATE="06/24/2009 22:42:49" />
<MATCHING_FILE NAME="x.exe" SIZE="65536" CHECKSUM="0x66982AE3" MODULE_TYPE="WIN32" PE_CHECKSUM="0x103FD" LINKER_VERSION="0x0" LINK_DATE="06/18/2009 23:55:27" UPTO_LINK_DATE="06/18/2009 23:55:27" />
</EXE>
<EXE NAME="ntdll.dll" FILTER="GRABMI_FILTER_THISFILEONLY">
<MATCHING_FILE NAME="ntdll.dll" SIZE="774144" CHECKSUM="0x74ACB78F" BIN_FILE_VERSION="5.2.3790.4455" BIN_PRODUCT_VERSION="5.2.3790.4455" PRODUCT_VERSION="5.2.3790.4455" FILE_DESCRIPTION="NT Layer DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows® Operating System" FILE_VERSION="5.2.3790.4455 (srv03_sp2_gdr.090203-1205)" ORIGINAL_FILENAME="ntdll.dll" INTERNAL_NAME="ntdll.dll" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0xC2B9D" LINKER_VERSION="0x50002" UPTO_BIN_FILE_VERSION="5.2.3790.4455" UPTO_BIN_PRODUCT_VERSION="5.2.3790.4455" LINK_DATE="02/09/2009 11:02:56" UPTO_LINK_DATE="02/09/2009 11:02:56" VER_LANGUAGE="English (United States) [0x409]" />
</EXE>
<EXE NAME="kernel32.dll" FILTER="GRABMI_FILTER_THISFILEONLY">
<MATCHING_FILE NAME="kernel32.dll" SIZE="1038336" CHECKSUM="0x7EFD9E0D" BIN_FILE_VERSION="5.2.3790.4480" BIN_PRODUCT_VERSION="5.2.3790.4480" PRODUCT_VERSION="5.2.3790.4480" FILE_DESCRIPTION="Windows NT BASE API Client DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows® Operating System" FILE_VERSION="5.2.3790.4480 (srv03_sp2_gdr.090321-1244)" ORIGINAL_FILENAME="kernel32" INTERNAL_NAME="kernel32" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0x101B44" LINKER_VERSION="0x50002" UPTO_BIN_FILE_VERSION="5.2.3790.4480" UPTO_BIN_PRODUCT_VERSION="5.2.3790.4480" LINK_DATE="03/21/2009 17:08:26" UPTO_LINK_DATE="03/21/2009 17:08:26" VER_LANGUAGE="English (United States) [0x409]" />
</EXE>
</DATABASE>
THANKS!!!!! -
I'm having trouble executing code using the OCCI libraries. I suspect that it's an issue with the version of OCCI that I'm using but can't seem to resolve the problem myself.
On Windows 7, I'm using the OCCI libraries from the Oracle Express 11.2 32 bit install. I'm compiling in Eclipse Luna (for 32 bit) 1a using the CDT plugin. I'm using the compiler from Microsoft Visual Studio 12.0.
I'm using the oraocci.lib. (If I use the oraocci11d.lib, my code crashes just trying to make a database connection.) My current problem is with the oracle::occi::ResultSet::getString method. If I call it once on my ResultSet, it works fine. The second call causes my program to crash.
Here is my code:
std::sqlStr;
sqlStr = "SELECT START, END, BATCH_ID, AGENT_ID FROM AGENTS WHERE ID = :1";
connection code, stmt creation, etc
oracle::occi::ResultSet *rs = stmt->executeQuery();
if (rs->next()
double start = rs->getDouble(1);
double end = rs->getDouble(2);
std::string batch = rs->getString(3);
std::string agent = rs->getString(4); // CRASH!
Here is the exception that I get when I try to debug:
"Unhandled exception at 0x00D82CB8 in DARTester.exe: 0xC0000005: Access violation reading location 0x0000005."
Any help would be greatly appreciated.It is my fault. I use Fedore Core 4 and gcc4.0. By default it linking with libstdc++.6.so, but when I linkint direct with libstdc++.5.so it OK.
Thank you for support! -
Resultset.getString(). error
I'm using Oracle 10g with jrockit 1.4.2_13.
While looping through a cursor it blows up while executing resultset.getString().
This code has been working for years and just blows up on a specific piece of data.
The data it's trying to retrieve is .0548. Similar data is retrieved successfully.
at oracle.sql.LnxLibThin.lnxnuc(LnxLibThin.java:6071)
at oracle.sql.NUMBER.toText(NUMBER.java:2682)
at oracle.jdbc.driver.NumberCommonAccessor.getString(NumberCommonAccessor.java:5303)
at oracle.jdbc.driver.T4CNumberAccessor.getString(T4CNumberAccessor.java:83)
at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:355)
I've tried to upgrade to the latest ojdbc14.jar driver with negative results.
Here is the code snippet:
for(int i=1;i<=size;i++){
str_columnName = (String)ht_elementMappings.get((i)+"");
sbf_rowData.append("\t\t<"+str_columnName+">");
//Blows up on the 18th column during the getString
str_columnValue = rs_object.getString(i);
sbf_rowData.append( str_columnValue );
sbf_rowData.append("</"+str_columnName+">");
sbf_rowData.append("\n");
sbf_rowData.append("\t</ROW>");
sbf_rowData.append("\n");
bufferedWriter.write(sbf_rowData.toString());
Thanks in advance for any thoughts.(1) and (3) are related to gcc versions to use with OCCI. OCCI 10.1 and 10.2 support gcc 3.2.3 (and gcc 2.96). In addition, OCCI 10.2 supports gcc 3.4.3 (libraries are available on OTN).
2) For retreiving the column names in a ResutSet, you need to use the ResultSet::getColumnListMetaData() interface. You can implement your own solution to call ResultSet::getXXX methods by column name e.g :-
vector<MetaData> md = rs->getColumnListMetaData();
map<string, int> columns;//column names to number mapping
for (int i = 0; i < md.size(); i++) columns[md[i].getString(MetaData::ATTR_NAME)] = i;
//now "use" column names!
string ename = rs->getString(columns["ENAME"));
-Shankar -
OCCI Compile Error.. Please Help me....
I'm Developing on the Compaq Tru64 Unix Version 5.1b
I'm attempting to compile/link Oracle OCCI demo using Tru64 cxx with no success
Compile error:
cxx: Warning: /pdms_appl/oracle/product/rdbms/demo/occiObjects.h, line 119:
function "oracle::occi::PObject::operator new(std::size_t, void *)"
has no corresponding operator delete (to be called if an exception
is thrown during initialization of an allocated object)
void operator new(size_t size, void adctx);
--------------^
cxx: Warning: /pdms_appl/oracle/product/rdbms/demo/occiObjects.h, line 116:
function "oracle::occi::PObject::operator new(std::size_t, const
oracle::occi::Connection *, const std::string &, const char *)" has
no corresponding operator delete (to be called if an exception is
thrown during initialization of an allocated object)
void operator new(size_t size, const Connection x,
--------------^
Runtime Error:
PDMS_pdms.bitekic.co.kr:/pdms_appl/oracle/product/rdbms/demo> occipool
resolve_symbols: loader error: dlopen: libocci.so.9.0: symbol "OCIPSetObjectPtrNull" unresolvedI think you can ignore the compilation warnings.
For the unresolved symbol error while running the OCCI app, can you try static linking of the application with libocci9.a & libclntst.a ? e.g :-
make -f demo_rdbms.mk buildocci_static EXE=occipool OBJS=occipool.o
Regards,
Shankar -
Hi All,
I'm new to Occi, I've tried running a sample program and I'm getting this Linker Error on VC 2008, I've copied oraocci11.lib to my project directory and I'm still getting this linker error, Can someone please help me out.
My Environment is
VC++ 2008
Oracle 11i
On Windows XP 32 Bit OS
1>Compiling...
1>stdafx.cpp
1>Compiling...
1>OracleConnectSample.cpp
1>AssemblyInfo.cpp
1>Generating Code...
1>Compiling resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Linking...
1>OracleConnectSample.obj : error LNK2028: unresolved token (0A0002BD) "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall oracle::occi::SQLException::getMessage(void)const " (?getMessage@SQLException@occi@oracle@@$$FUBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function __catch$?main@@$$HYAHHPAPAD@Z$0
1>OracleConnectSample.obj : error LNK2028: unresolved token (0A0002BF) "public: virtual __thiscall oracle::occi::SQLException::~SQLException(void)" (??1SQLException@occi@oracle@@$$FUAE@XZ) referenced in function __catch$?main@@$$HYAHHPAPAD@Z$0
1>OracleConnectSample.obj : error LNK2028: unresolved token (0A0002C0) "public: static void __cdecl oracle::occi::Environment::terminateEnvironment(class oracle::occi::Environment *)" (?terminateEnvironment@Environment@occi@oracle@@$$FSAXPAV123@@Z) referenced in function "int __cdecl main(int,char * *)" (?main@@$$HYAHHPAPAD@Z)
1>OracleConnectSample.obj : error LNK2028: unresolved token (0A0002C4) "public: unsigned int __thiscall oracle::occi::Blob::length(void)const " (?length@Blob@occi@oracle@@$$FQBEIXZ) referenced in function "int __cdecl main(int,char * *)" (?main@@$$HYAHHPAPAD@Z)
1>OracleConnectSample.obj : error LNK2028: unresolved token (0A0002C5) "public: __thiscall oracle::occi::Blob::~Blob(void)" (??1Blob@occi@oracle@@$$FQAE@XZ) referenced in function "int __cdecl main(int,char * *)" (?main@@$$HYAHHPAPAD@Z)
1>OracleConnectSample.obj : error LNK2028: unresolved token (0A0002C7) "public: __thiscall oracle::occi::Blob::Blob(class oracle::occi::Blob const &)" (??0Blob@occi@oracle@@$$FQAE@ABV012@@Z) referenced in function "int __cdecl main(int,char * *)" (?main@@$$HYAHHPAPAD@Z)
1>OracleConnectSample.obj : error LNK2028: unresolved token (0A0002CC) "public: static class oracle::occi::Environment * __cdecl oracle::occi::Environment::createEnvironment(enum oracle::occi::Environment::Mode,void *,void * (__cdecl*)(void *,unsigned int),void * (__cdecl*)(void *,void *,unsigned int),void (__cdecl*)(void *,void *))" (?createEnvironment@Environment@occi@oracle@@$$FSAPAV123@W4Mode@123@PAXP6APAX1I@ZP6APAX11I@ZP6AX11@Z@Z) referenced in function "int __cdecl main(int,char * *)" (?main@@$$HYAHHPAPAD@Z)
1>OracleConnectSample.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall oracle::occi::SQLException::~SQLException(void)" (??1SQLException@occi@oracle@@$$FUAE@XZ) referenced in function __catch$?main@@$$HYAHHPAPAD@Z$0
1>OracleConnectSample.obj : error LNK2019: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall oracle::occi::SQLException::getMessage(void)const " (?getMessage@SQLException@occi@oracle@@$$FUBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function __catch$?main@@$$HYAHHPAPAD@Z$0
1>OracleConnectSample.obj : error LNK2019: unresolved external symbol "public: static void __cdecl oracle::occi::Environment::terminateEnvironment(class oracle::occi::Environment *)" (?terminateEnvironment@Environment@occi@oracle@@$$FSAXPAV123@@Z) referenced in function "int __cdecl main(int,char * *)" (?main@@$$HYAHHPAPAD@Z)
1>OracleConnectSample.obj : error LNK2019: unresolved external symbol "public: unsigned int __thiscall oracle::occi::Blob::length(void)const " (?length@Blob@occi@oracle@@$$FQBEIXZ) referenced in function "int __cdecl main(int,char * *)" (?main@@$$HYAHHPAPAD@Z)
1>OracleConnectSample.obj : error LNK2019: unresolved external symbol "public: __thiscall oracle::occi::Blob::~Blob(void)" (??1Blob@occi@oracle@@$$FQAE@XZ) referenced in function "int __cdecl main(int,char * *)" (?main@@$$HYAHHPAPAD@Z)
1>OracleConnectSample.obj : error LNK2019: unresolved external symbol "public: __thiscall oracle::occi::Blob::Blob(class oracle::occi::Blob const &)" (??0Blob@occi@oracle@@$$FQAE@ABV012@@Z) referenced in function "int __cdecl main(int,char * *)" (?main@@$$HYAHHPAPAD@Z)
1>OracleConnectSample.obj : error LNK2019: unresolved external symbol "public: static class oracle::occi::Environment * __cdecl oracle::occi::Environment::createEnvironment(enum oracle::occi::Environment::Mode,void *,void * (__cdecl*)(void *,unsigned int),void * (__cdecl*)(void *,void *,unsigned int),void (__cdecl*)(void *,void *))" (?createEnvironment@Environment@occi@oracle@@$$FSAPAV123@W4Mode@123@PAXP6APAX1I@ZP6APAX11I@ZP6AX11@Z@Z) referenced in function "int __cdecl main(int,char * *)" (?main@@$$HYAHHPAPAD@Z)
1>E:\Samples\OracleConnectSample\Debug\OracleConnectSample.exe : fatal error LNK1120: 14 unresolved externals
Thanks
SunilHi,
It looks like you may not have added the occi library to the linker input in the project properties.
Something like:
Select Project –> <Name> Properties... from the menu (substitute your project name)
Expand Configuration Properties node, expand Linker node, select Input item, enter "oraocci11d.lib" for a debug build or "oraocci11.lib" for a release build.
Regards,
Mark -
Machine: Itanium 2 (ia64)
OS: Red Hat Enterprise Linux AS release 3 (Taroon Update 5)
Oracle: Oracle 10g R2 (10.2.0.1.0) for Linux Itanium
Compiler: gcc-3.2.3-52
Problem:
when I compile my application i get the following errors:
/oracle/oracle/product/10.2.0/db_1/lib/libocci.so: undefined reference to `__intel_personality_routine'Hello Mr. Romeo,
Unfortunately this week I don't have access to the build and development platform IA64 RHEL 4.5 so I can offer you just some approximate hints related to your last question (my current working platform is Solaris 10 x86-64 but there are similarities):
0. Unpack your shipped ORACLE database package using:
gunzip <oracle version>database<OS platform>_<OS architecture>.cpio.gz
cpio -ivd < <oracle version>database<OS platform>_<OS architecture>.cpio
1.In order to see what are the components including OCCI please run one of the belows:
find database/ -name '*' -type f -exec grep -i 'libocci' {} \; 1>occi.lst 2>/dev/null
or better
for f in `find database/ -name '*.jar' -type f -print`; do unzip -l $f | grep occi; if [ $? -eq 0 ]; then printf "COMPONENT ------------------ %s\n" $f; fi; done
basically you should get the following list of components:
database/stage/Components/oracle.rdbms.rsf.ic/10.2.0.1.0/1/DataFiles/filegroup2.jar
database/stage/Components/oracle.rdbms.oci/10.2.0.1.0/1/DataFiles/filegroup3.jar
database/stage/Components/oracle.rdbms.oci/10.2.0.1.0/1/DataFiles/filegroup2.jar
database/stage/Components/oracle.rdbms.oci/10.2.0.1.0/1/DataFiles/filegroup1.jar
database/stage/Components/oracle.rsf.hybrid/10.2.0.0.0/1/DataFiles/filegroup3.jar
As you can see there three distinct components including references to troublesome OCCI component.
The first (oracle.rdbms.rsf.ic) one usually includes the shared library 'lib/libocci.so.10.1' which was built under the mixed RFC.IC environment: please check it by:
-- create temporary directory AAA:
mkdir -p AAA
-- extract the component you need out of archive:
unzip database/stage/Components/oracle.rdbms.rsf.ic/10.2.0.1.0/1/DataFiles/filegroup2.jar lib/libocci.so.10.1 -d AAA/
-- check it by:
file AAA/lib/libocci.so.10.1 (to get the binary file profile info)
nm -Al AAA/lib/libocci.so.10.1 | grep __intel_personality_routine (searching out for undefined symbol...please refer man page of nm for further info)
objdump -h AAA/lib/libocci.so.10.1 (to collect ELF-EFI profile info ...first two are important -h and -f ...)
objdump -f AAA/lib/libocci.so.10.1
objdump -x AAA/lib/libocci.so.10.1
Here try to pick up some conclusions and eventually send me the outputs if don't manage figure out the outputs you get.
The next three entries are coming from the component oracle.rdbms.oci (our bad guy...) and should contain something like:
2733 09-13-05 13:23 bin/genoccish
%ORACLE_HOME%/bin/genoccish
COMPONENT ------------------ database/stage/Components/oracle.rdbms.oci/10.2.0.1.0/1/DataFiles/filegroup3.jar
2425378 10-19-05 16:55 lib/libocci10.a
%ORACLE_HOME%/lib/libocci10.a
1259357 10-04-05 16:27 lib/libocci10_296.so.10.1
%ORACLE_HOME%/lib/libocci10_296.so.10.1
1752124 10-04-05 16:27 lib/libocci10_296.a
%ORACLE_HOME%/lib/libocci10_296.a
COMPONENT ------------------ database/stage/Components/oracle.rdbms.oci/10.2.0.1.0/1/DataFiles/filegroup2.jar
2115 10-15-02 02:19 rdbms/public/occi.h
%ORACLE_HOME%/rdbms/public/occi.h
11600 03-03-04 03:59 rdbms/public/occiAQ.h
%ORACLE_HOME%/rdbms/public/occiAQ.h
38530 06-23-05 07:55 rdbms/public/occiCommon.h
%ORACLE_HOME%/rdbms/public/occiCommon.h
73063 01-10-05 20:08 rdbms/public/occiControl.h
%ORACLE_HOME%/rdbms/public/occiControl.h
35218 11-08-04 21:36 rdbms/public/occiData.h
%ORACLE_HOME%/rdbms/public/occiData.h
29156 11-13-03 20:59 rdbms/public/occiObjects.h
%ORACLE_HOME%/rdbms/public/occiObjects.h
COMPONENT ------------------ database/stage/Components/oracle.rdbms.oci/10.2.0.1.0/1/DataFiles/filegroup1.jar
The last one just include related header files and have no relevance in our issue, so lets have a look over the first two:
bin/genoccish – is the well known generation script (you already dealt with it)
lib/libocci10.a – is the static library which isn't built from *.o files being already shipped :-(
lib/libocci10_296.a – are for gcc296 and should be used only for GCC296...
So our static library (archive) lib/libocci10.a should be also checked by:
nm -Al AAA/lib/libocci10.a | grep __intel_personality_routine (searching out for undefined symbol...please refer man page of nm for further info)
Most probable the symbol is there and is undefined...:-( So for the time being our work-around seems to be the only way we have !!!
The last component is for hybrid platforms only (it could be missing from your IA64...I am not sure is IA64 is still treated as an hybrid platform...:-) ) and contains the 32 bit versions...you can check them as in the previous cases from above but assuming that these 32 bit versions are clean (not referring any uresoved symbols...:-)) this is restricting you to build your applications for 32 bit only...
1764366 09-08-05 03:43 lib32//libocci10.a
%ORACLE_HOME%/lib32//libocci10.a
1397960 10-20-05 02:54 lib32//libocci.so.10.1
%ORACLE_HOME%/lib32//libocci.so.10.1
COMPONENT ------------------ database/stage/Components/oracle.rsf.hybrid/10.2.0.0.0/1/DataFiles/filegroup3.jar
All the best and let me know if you need more support with that,
Ioan -
in visual C++ 6.0, i get the following error while compilition an occi source file :
:\ORACLE\ORA90\OCI\INCLUDE\oratypes.h(267) : error C2378: 'text' : redefinition; symbol cannot be overloaded with a typedef
d:\Microsoft Visual Studio\VC98\INCLUDE\fstream.h(161) : see declaration of 'text'
maybe one can help me finding the solution...
Thanks,
Rigis KuckaertzTry setting the following preprocessor directive (under project options):
LUSEMFC
This should cause oratypes.h to not try and typedef 'text' -
In Visual C++ 6.0, I get the following error during compilation of an OCCI source file :
e:\ORACLE\ORA90\OCI\INCLUDE\oratypes.h(267) : error C2378: 'text' : redefinition; symbol cannot be overloaded with a typedef
d:\Microsoft Visual Studio\VC98\INCLUDE\fstream.h(161) : see declaration of 'text'
Maybe one can help me finding a solution...
Rigis KuckaertzHi,
It looks like you may not have added the occi library to the linker input in the project properties.
Something like:
Select Project –> <Name> Properties... from the menu (substitute your project name)
Expand Configuration Properties node, expand Linker node, select Input item, enter "oraocci11d.lib" for a debug build or "oraocci11.lib" for a release build.
Regards,
Mark -
OCCI - getString() fails in subsequent calls
while (rs->next())
cout << << rs->getString(1) ; //name string
How can I solve it?
Thanks in advance.Hi,
I once had such problem and I solved after reading following message thread on this same forum. Hope this helps you.
Re: getString in ocidml.cpp fails
Have fun ...
With regards,
Panneer :-) -
Parse error in OCCI header, sol8 & gcc 2.95.2
All I did was include occi.h, and set the namespaces:
#include <occi.h>
using namespace oracle::occi;
using namespace std;
... no other OCCI code
error is:
In file included from .../occi.h:48
..../occiObjects.h: in method 'oracle::occi::Ref<T>::operator
oracle::occi::RefAny() const':
occiObjects.h:509: parse error before ';'
etc.
Any help would be appreciated. Should I upgrade to gcc 3?
jdsHi,
You need Sun's compiler workshop for using OCCI. The name
mangling for gcc and CC is not the same.
rahul -
There are some common questions when we use OCCI,I just list them here,
it anyone have resolve them ,I appreciate your help if you can post your method.
1、ResultSet getString error
2、ResultSet can just use index,but how to bind column name
3、 whether gcc3.4.3 must used with oracle10.2.x.x, how to compile program with oracle10.1.x.x?Must upgrade to oracle10.2.x.x?
4、anyone can add his question(1) and (3) are related to gcc versions to use with OCCI. OCCI 10.1 and 10.2 support gcc 3.2.3 (and gcc 2.96). In addition, OCCI 10.2 supports gcc 3.4.3 (libraries are available on OTN).
2) For retreiving the column names in a ResutSet, you need to use the ResultSet::getColumnListMetaData() interface. You can implement your own solution to call ResultSet::getXXX methods by column name e.g :-
vector<MetaData> md = rs->getColumnListMetaData();
map<string, int> columns;//column names to number mapping
for (int i = 0; i < md.size(); i++) columns[md[i].getString(MetaData::ATTR_NAME)] = i;
//now "use" column names!
string ename = rs->getString(columns["ENAME"));
-Shankar -
Hello,
I've been searching through lots of threads regarding the "getString heap corruption" problem but i could not find any solution for this issue so here is a new thread.
Environment:
Instant Client 10.2.0.4, installed on C:\Oracle\instantclient-sdk-win32-10.2.0.4 and C:\Oracle\instantclient-basic-win32-10.2.0.4\
VC++ 2005 with include folder C:\Oracle\instantclient-sdk-win32-10.2.0.4\instantclient_10_2\sdk\include and lib folder C:\Oracle\instantclient-sdk-win32-10.2.0.4\instantclient_10_2\sdk\lib\msvc.
WinXP SP3 with Path environment variable having C:\Oracle\instantclient-basic-win32-10.2.0.4\ as the first entry.
My sample is compiled in Release mode and linked with oraocci10.lib.
The OCCI getString function generates a heap corruption every time she tries to fetch more then 16 bytes.
Applications running in Release mode are capable to continue the job but obviously they will crash one day.
If we use Microsoft Application Verifier an assertion is generated when this heap corruption is detected.
I wonder if there is any solution for this issue. Thanks.
Edited by: hfroliveira on Mar 9, 2010 2:36 AMRoss
I have seen problems similar to what you are describing when a certain flag in VS is not set correctly. In VS, select the application you created and go to
Properties->Configuration Properties->C/C++->Code Generation
For the argument Runtime Library set it to Multi-threaded Debug DLL (/MDd) for Debug and Multi-threaded DLL (/MD) for Release.
Lauren Foutz -
Problems with encoding and files
Hi friends pls some help my problems is the following
I have a ftp server running on linux and in my program I download files from the ftp server using class specified below.When I download the file content not all content is coming ok. For example I have a string with
Ra�l����1234%#=?[a_@ and when I read content using my methods this part is retirved ok Ra and this one is retrived wrong �����
whith characteres very stranges.
I suppose that the problem is with the encoding, then all day I tried some settings in the class new InputStreamReader.First the encoding UTF-8 because I have created the file using this encoding. Something like this:
in = new InputStreamReader(new GZIPInputStream(localFtp.get(serverFile)),"UTF-8");
but does not work
After I realized that I use the statement localFtp.ascii();
declaring that the content will be downloaded in ascii encoding so
I made this change :
in = new InputStreamReader(new GZIPInputStream(localFtp.get(serverFile)),"US-ASCII");
but still does not work
Please somebody can help me this is very urgent
Here is my code
Tkx
code:
{code}
import sun.net.ftp.FtpClient;
import java.util.ArrayList;
import java.util.Vector;
import java.io.*;
import java.util.zip.*;
* This is a basic wrapper around the sun.net.ftp.FtpClient
* class, which is an undocumented class which is included
* with Sun Java that allows you to make FTP connections
* and file transfers.
* <p>
* Program version 1.0. Author Julian Robichaux, http://www.nsftools.com
* @author Julian Robichaux ( http://www.nsftools.com )
* @author Jpuerta (modified by)
* @version 1.0
public class SunFtpWrapper extends FtpClient {
* Methods you might use from the base FtpClient class
* // set the transfer type to ascii
* public void ascii()
* // set the transfer type to binary
* public void binary()
*// change to the specified directory
* public void cd(String remoteDirectory)
* // download the specified file from the FTP server
* public TelnetInputStream get(String filename)
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Vector;
import java.util.ResourceBundle;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import com.banesco.lynx.common.SunFtpWrapper;
import com.banesco.lynx.exceptions.FtpManagerException;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
public class FtpManager extends SunFtpWrapper{
ProcessParametersHelper parametersManager=ProcessParametersHelper.newInstance();
ResourceBundle rb = ResourceBundle.getBundle("com.banesco.lynx.exceptions.lynx_exceptions");
private Logger logger =null;
public FtpManager(int i) throws FtpManagerException {
logger = Logger.getLogger(FtpManager.class);
PropertyConfigurator.configure(parametersManager.getLog4j_path());
//0 connect to source server
//1 connect to destiny server
if(i==0)
connectToSourceServer(this);
else if (i==1)
connectToDestinyServer(this);
private void connectToSourceServer(FtpManager ftp)throws FtpManagerException{
try{
ftp.openServer(parametersManager.getSourceServerInfo().getIp());
ftp.login(parametersManager.getSourceServerInfo().getUserName(), parametersManager.getSourceServerInfo ().getPassword());
catch (IOException e) {
//log error
logger.error("Ha ocurrido un error la descripcion del error es :" + e.getMessage());
throw new FtpManagerException(Integer.toString(FtpManagerException.CRITICAL),rb.getString ("error.ftpmanager.openconnection"));
private void connectToDestinyServer(FtpManager ftp)throws FtpManagerException{
try{
ftp.openServer(parametersManager.getDestinyServerInfo().getIp());
ftp.login(parametersManager.getDestinyServerInfo().getUserName(), parametersManager.getDestinyServerInfo ().getPassword());
catch (IOException e) {
//log error
logger.error("Ha ocurrido un error la descripcion del error es :" + e.getMessage());
throw new FtpManagerException(Integer.toString(FtpManagerException.CRITICAL),rb.getString ("error.ftpmanager.openconnection"));
public ArrayList downloadFileIntoMemory (String path,String serverFile, boolean isZipped) throws FtpManagerException {
int i = 0;
InputStreamReader in = null;
ArrayList response = new ArrayList();
FtpManager localFtp=null;
try{
localFtp=new FtpManager(0);
localFtp.cd(path);
//TODO modifico encoding
// moving file content from ftp server into memory
if (isZipped)
{ localFtp.binary();
in = new InputStreamReader(new GZIPInputStream(localFtp.get(serverFile)));
else
localFtp.ascii();
in = new InputStreamReader(localFtp.get(serverFile));
// moving file content from memory into arraylist
BufferedReader reader = new BufferedReader(in);
String l = null;
while ( (l = reader.readLine()) != null)
response.add(l);
catch(IOException e){
//TODO quitar esto
e.printStackTrace();
//log error
logger.error("Ha ocurrido un error la descripcion del error es :" + e.getMessage());
throw new FtpManagerException(Integer.toString(FtpManagerException.CRITICAL),rb.getString ("error.ftpmanager.downloadfile"));
catch (FtpManagerException e) {
//log error
logger.error("Ha ocurrido un error la descripcion del error es :" + e.getMessage());
throw new FtpManagerException(Integer.toString(FtpManagerException.CRITICAL),rb.getString ("error.ftpmanager.downloadfile"));
finally{
try{
localFtp.disconnect();
}catch(FtpManagerException e){
//log error
logger.error("Ha ocurrido un error la descripcion del error es :" + e.getMessage());
throw new FtpManagerException(Integer.toString(FtpManagerException.CRITICAL),rb.getString ("error.ftpmanager.closeconection"));
return response;Err.. GZIP files are not text files so why are you trying to read them using Readers?
Maybe you are looking for
-
Previous task was: Write a class "QuestionAnalyser" which has a method "turnAnswerToScore". This method takes a String parameter and returns an int. The int returned depends upon the parameter: parameter score "A" 1 "B" 2 "C" 3 other 0 Alright, here'
-
How to configure Oracle Sql Developer for 9i
Hi, We are using oracle 9i for existing application, and i am trying to connect oracle 9i through SQL developer 1.5.1, i got an error message "Unsupported Oracle Database Version". Appreciate if any body guide me in this. regards Husal.
-
What's wrong with the audio meter?
Let me start off by saying that I know the problem I am going to report is a little bit complicated, if my limited grasp of English makes it even harder to understand, please let me know. I'll elaborate on it further. At first, I was very happy with
-
Download: Scripting in a Box
<b>Scripting in a Box v0.0.1</b> /people/sap.user72/blog/2006/04/06/scripting-in-a-box-v001 Interested in PHP or Perl? Tired of fighting with getting a development environment setup and not knowing which version of what to work with? I decided to dev
-
I am trying to update my iPod touch to the new iOS, but the error message "An error has occurred while backing up this iPod (0xE800067)" and asks me if I want to continue (which will "result in the loss of all contents on this iPod"); what is the pro