Compatibility issues with Oracle OCCI and g++ 7.1

2019-08-30 18:14发布

I am trying to create a C++ application with OCCI (versions 11,12,18, all lead to the same issue explained below) using gcc 7.1.

The application below compiles and runs fine with gcc 4.8.5 unter RHEL7, but throws an error ORA-24960: the attribute OCI_ATTR_USERNAME is greater than the maximum allowable length of 255 when compiled with gcc 7.1.

This question seems to address the problem, but downgrading to a lower compiler version is no option in my case, as I need to integrate the OCCI calls into a bigger application that depends on gcc 7.1.

Here's an MCVE for simply checking the connection to the DB:

#include <string>
#include <occi.h>

using namespace oracle::occi;
using namespace std;

int main()
{
  const string url = "//server:1234/ID";
  const string username = "user";
  const string password = "password";

  Environment* env = Environment::createEnvironment();
  try {
    Connection* conn = env->createConnection(username, password, url);
    cout << "Connection to " << url << " successfully established." << endl;

    env->terminateConnection(conn);
    cout << "Connection closed." << endl;
  }
  catch (const SQLException& ex) {
    cerr << "Error: " << ex.what() << endl;
  }
  Environment::terminateEnvironment (env);
}

Has anyone made any experience with this problem and knows if there is a workaround or static OCCI libraries I can link against?

0条回答
登录 后发表回答