在CodeBlocks上编译C 中的Oracle数据库环境时的错误



我正在尝试开发一个两层程序,为此,我需要通过OCCI接口使用连接池将程序连接到数据库(在这种情况下为Oracle)。我已经在CodeBlocks中链接了occi.h标头文件和目录,但是当我尝试编译时,它显示此错误:

|对`oracle :: occi ::环境:: createenvironment(oracle :: occi ::环境:: mode,void*,void*()(void ,unsigned int),void*()(void ,void*,unsigned int),void()(void ,void*))'|

||未定义的引用`oracle :: occi ::环境:: terminateEnvironment(oracle :: occi :: acci ::环境*)'|

||错误:LD返回1退出状态| || ===构建失败:3错误(S),0警告(S)(0分钟,2秒)===== |

有人知道这个错误意味着什么?我不是ACE C 程序员,所以请忍受我!

这是发生错误的演示代码:

#include <iostream>
#include <occi.h>
#include <iomanip>
using namespace oracle::occi;
using namespace std;
class occipool {
  private:
   Environment* env;
   Connection* con;
  Statement* stmt;
 public:
 /**
 * Constructor for the occipool test case.
 */
  occipool() {
    env = Environment::createEnvironment(Environment::DEFAULT);
  }    // end of constructor occipool ()
 /**
* Destructor for the occipool test case.
*/
 ~occipool() {
  Environment::terminateEnvironment(env);
 }    // end of ~occipool ()
 /**
* The testing logic of the test case.
*/
 dvoid select() {
cout << "occipool - Selecting records using ConnectionPool interface"
     << endl;
const string poolUserName = "name";
const string poolPassword = "password";
const string connectString = "name";
const string username = "name";
const string passWord = "password";
unsigned int maxConn = 5;
unsigned int minConn = 3;
unsigned int incrConn = 2;
ConnectionPool* connPool = env->createConnectionPool(
    poolUserName, poolPassword, connectString, minConn, maxConn, incrConn);
try {
  if (connPool)
    cout << "SUCCESS - createConnectionPool" << endl;
  else
    cout << "FAILURE - createConnectionPool" << endl;
  con = connPool->createConnection(username, passWord);
  if (con)
    cout << "SUCCESS - createConnection" << endl;
  else
    cout << "FAILURE - createConnection" << endl;
} catch (SQLException ex) {
  cout << "Exception thrown for createConnectionPool" << endl;
  cout << "Error number: " << ex.getErrorCode() << endl;
  cout << ex.getMessage() << endl;
}
cout << "retrieving the data" << endl;
stmt = con->createStatement("SELECT ID, dept_name FROM p_worker");
ResultSet* rset = stmt->executeQuery();
while (rset->next()) {
  cout << "author_id:" << rset->getInt(1) << endl;
  cout << "author_name:" << rset->getString(2) << endl;
}
stmt->closeResultSet(rset);
con->terminateStatement(stmt);
connPool->terminateConnection(con);
env->terminateConnectionPool(connPool);
cout << "occipool - done" << endl;
}  // end of test (Connection *)
};  // end of class occipool
  int main(void) {
 string user = "name";
 string passwd = "password";
 string db = "name";
 occipool* demo = new occipool();
 demo->select();
 delete demo;
  }  // end of main ()

您是否正在与libocci.so和-libclntsh.so库链接?

是需要。

相关内容

  • 没有找到相关文章

最新更新