简体   繁体   中英

Visual studio 2010 reporting “Access violation” for Oracle OCCI 11g when creating connection

When I tried to create a connection with Oracle OCCI 11g on Microsoft Visual Studio 2010, I got below error:

Unhandled exception at 0x005a79c9 in OracleOCCI.exe: 0xC0000005: Access violation reading location 0x316c6561.

My code is very simple as below:

class DMLDemo
{
private:

    Environment *env;
    Connection *conn;
    Statement *stmt;

public:

    DMLDemo (string user, string passwd, string db)
    {
        env = Environment::createEnvironment (Environment::DEFAULT);
        if(env==nullptr)
            cout << "Failure";


            try
            {
                conn = env->createConnection (user, passwd, db);
        }
            catch (exception* e)
            {
                cout << "Error";
            }


    }

    ~DMLDemo ()
    {
        env->terminateConnection (conn);
        Environment::terminateEnvironment (env);
    }

};


int _tmain(int argc, _TCHAR* argv[])
{
    //01. Test Simple Connection
    try
    {
        DMLDemo demo("scott","Michael1","");
    }
    catch (exception* e)
    {
        cout << e->what();

    }

    getche();


    return 0;
}

I googled for some answers, seems that something is wrong with the compatibility between oracle dll version and the VC version.

Anyone who has a solution for this? Or just change to VS 2005?

I have been building VS08 and VS10 interfaces to the Oracle 11g( 11.2.0) 32 bit database. I found that a number of the sites providing occi11x.dlls, including my own Oracle installation, delivered in the V9 directory, were not compatible with the VS08 console app. Finally, I had to have the tested 'gold' binaries delivered to me from another location in the company. Once the x86 'gold' dll was installed in the console launch directory, the very same code functioned properly.

I am searching for the same suitability in VS10 occi11x.dlls. As yet I haven't found it. I am getting similar faults following the Environment creation. Some dlls allow me to make a connection but fault when I try to do a ResultSet->next(), others won't allow me even to do the executeQuery(). I think Oracle is remiss in not managing this properly.

The 'broken' VS08 dlls sometimes had the correct dates and file size as the 'gold' dlls. Perhaps an internal search of the dlls will discover which ones are workable.

http://www.oracle.com/technetwork/database/occidownloads-083553.html is the site that oracle uses to supply various occi dlls to match to Visual Studio. Perhaps their VS12 version is actually more compatible with the Oracle12c database.

Okay, finally I installed VS 2008 and the code works out all right. Seems that the Oracle DLL compiled in 2008 would not work in VS2010.

Maybe someday, Oracle can publish its VS2010 Dlls...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM