我正在尝试开发一个双层程序,为此,我需要使用连接池通过OCCI
接口将我的程序连接到数据库(在本例中为Oracle)。我已经在CodeBlocks中链接了occi.h
头文件和目录,但是当我尝试编译时,它显示了这个错误:
|未定义引用`oracle :: occi :: Environment :: createEnvironment(oracle :: occi :: Environment :: Mode,void *,void *()(void ,unsigned int) ,void *()(void ,void *,unsigned int),void()(void ,void *))'|
||未定义的引用`oracle :: occi :: Environment :: terminateEnvironment(oracle :: occi :: Environment *)'|
||错误:ld返回1退出状态| || ===构建失败:3个错误,0个警告(0分钟,2秒(秒))=== |
有谁知道这个错误意味着什么?我不是王牌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 ()
答案 0 :(得分:0)
您是否使用libocci.so和-libclntsh.so库进行链接?
它的需要。