连接时用到的一些字段, POCO官方文档中也有说明
\Data\MySQL\src\SessionImpl.cpp:69
options["host"]= "localhost";
options["port"]= "3306";
options["user"]= "";
options["password"]= "";
options["db"]= "";
options["compress"]= "";
options["auto-reconnect"]= "";
//连接
std::string mysql_poco::_dbConnString = "host=xxx.17.xx.68;user=xxx;password=xxx;db=bizcnvhost;compress=true;auto-reconnect=true";
Connector::registerConnector();
_pSession = newSession(SessionFactory::instance().create(Connector::KEY,_dbConnString));
//增:
string s1 ="a1";
string s2 ="b2";
string s3 ="b3";
string s4 ="b4";
*_pSession<
//查
int count = 0;
*_pSession <
注意: use和into的用法, use用于添加数据into用于返回值
这好像似乎没什么,C接口同样可以实现,它的强处在下面:
1操作自定义结构体,例如插入一个自定义的结构体,或将返回的数据放到自定义的结构体中,
1定义你结构体,但必须重载()操作符
2特化模版类TypeHandler,并重写bindsizeextractprepare这4个静态函数,原型在poco-1.4.2p1-all\Data\include\Poco\Data\TypeHandler.h中
2操作元组
3操作map
4操作set
5操作vector
具体请参考: Poco提供的示例
Mysql 官方提供的c++库貌似有内存泄漏, 在windows 下没有,Linux 貌似就有