先编译poco
然后连接库
ln -s /usr/lib/libPocoData.so.16 /usr/lib64/libPocoData.so.16
ln -s /usr/lib/libPocoDataSQLite.so.16 /usr/lib64/libPocoDataSQLite.so.16
ln -s /usr/lib/libPocoFoundation.so.16 /usr/lib64/libPocoFoundation.so.16
例子程序
-
#include <iostream>
-
#include <string>
-
#include "Poco/Data/Common.h"
-
#include "Poco/Data/SQLite/Connector.h"
-
using namespace Poco::Data;
-
using namespace std;
-
int main()
-
{
-
std::string caseno="CNO1311";
-
SQLite::Connector::registerConnector();
-
int count = 0;
-
Session ses("SQLite","/tmp/hongrui.db");
-
ses << "DROP TABLE IF EXISTS Simpsons", now;
-
ses << "CREATE TABLE IF NOT EXISTS Simpsons (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Age INTEGER(3))", now;
-
ses << "SELECT COUNT(*) FROM Simpsons ", into(count), now;
-
std::cout << "People in Simpsons " << count;
-
SQLite::Connector::unregisterConnector();
-
return 0;
-
}
编译
gcc test1.cpp -lPocoData -lPocoDataSQLite -L/usr/lib
阅读(4670) | 评论(0) | 转发(0) |