Poco C++ MySQl demo
#include "Poco/Exception.h"
#include "Poco/Data/Session.h"
#include "Poco/Data/Common.h"
#include "Poco/Data/BLOB.h"
#include "Poco/Data/StatementImpl.h"
#include "Poco/Data/SessionPool.h"
#include "Poco/Data/PooledSessionImpl.h"
#include "Poco/Data/MySQL/Connector.h"
#include "Poco/Data/MySQL/MySQLException.h"
#include "Poco/Data/SQLite/Connector.h"
#include "Poco/Data/SQLite/SQLiteException.h"
#include "Poco/Data/ODBC/Connector.h"
#include "Poco/Data/ODBC/ODBCException.h"
#include <iostream>
#include "Poco/Data/Common.h"
#include "Poco/Data/SessionPool.h"
#include "Poco/Thread.h"
int main()
{
try
{
Poco::Data::MySQL::Connector::registerConnector();
Poco::Data::SessionPool pool("MySQL", "user=root;password=;db=calserver;compress=true;auto-reconnect=true", 1, 4, 5);
Poco::Data::Session sess(pool.get());
if(sess.isConnected())
{
int count = 0;
sess<<"SELECT COUNT(*) FROM termstate", Poco::Data::into(count), Poco::Data::now;
std::cout << "the sum is : " << count << "recorder" <<std::endl;
}
else
{
std::cout << "*** Connected to DB"
<< "failed" <<std::endl;
}
Poco::Data::MySQL::Connector::unregisterConnector();
}
catch (Poco::Exception &ex)
{
std::cerr << ex.displayText() << std::endl;
}
return 0;
}
Makefile文件参考另外一篇博文通用Makefile模版,需要修改的为地方为:
## Customizable Section: adapt those variables to suit your program.
##==========================================================================
# The pre-processor and compiler options.
MY_CFLAGS = -I/usr/local/include/
# The linker options.
MY_LIBS = -L/usr/local/lib/ -lPocoDataMySQL -lPocoUtil
Poco C++ MySQl demo的更多相关文章
- c++ poco 使用mysql中文乱码问题
poco 是c++ 一个比较好的库,现在正在学习使用它,碰到一些问题记录在此. poco版本:poco-1.46-all ,带有数据库的支持模块 操作系统:ubuntu 1.使用poco的MySQL模 ...
- Poco 编译mysql
POCO mysql需要自己添加connecter的header和lib MySQL Client: For the MySQL connector, the MySQL client librari ...
- golang mysql demo
Go操作Mysql数据库 使用Go操作MySQL等数据库,一般有两种方式:一是使用database/sql接口,直接在代码里硬编码sql语句:二是使用gorm,即对象关系映射的方式在代码里抽象的操作数 ...
- 进一步封装poco下的mysql操作
为方便程序对mysql操作,我对poco的mysql进行了再次封装,主要是针对自己应用需要的部分. 开发工具:netbean 系统环境:centos7 poco版本: poco-1.9.0-all 主 ...
- 【MYSQL】常用命令备忘录
source 不接路径时,查找文件的路径是执行mysql命令时的路径 接路径时,使用路径+filename [root@wordpressserver mysql]# vi demo.mysql [r ...
- 14.7.1.2 MySQL创建用户句法
14.7.1.2 CREATE USER Syntax 单击此处查看原文 以下是MySQL 5.7.6及以上版本的CREATE USER句法 CREATE USER [IF NOT EXISTS] u ...
- POCO库中文编程参考指南(1)总览
POCO库中文编程参考指南(1)总览 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmail.com (# -> @) ...
- Linux Programming之MySQL
实验环境:Ubuntu13.04 在此之前有过一段使用MySQL数据库的经历,在Windows平台下使用GUI(当时是使用HeidiSQL和Workbench来管理数据库),并且有过使用Python中 ...
- php 连接mysql 主机 localhost,显示 No such file or directory
打开 php.ini文件,找到这1行 mysql.default_socket 然后将它修改为 mysql.default_socket=/path/to/mysql.sock /path/to/my ...
随机推荐
- linux下错误的捕获:errno和strerror的使用
经常在调用linux 系统api 的时候会出现一些错误,比方说使用open() write() creat()之类的函数有些时候会返回-1,也就是调用失败,这个时候往往需要知道失败的原因.这个时候使用 ...
- android studio使用中遇到的问题
旧版和新版切换会报错(点击更正, 不影响程序使用) 2.debug正常, 打包签名程序时候报错 String index out of range: -82 java.lang.StringIndex ...
- PL/SQL Developer记住用户名密码
在使用PL/SQL Developer时,为了工作方便希望PL/SQL Developer记住登录Oracle的用户名和密码: 设置方法:PL/SQL Developer ->tools-> ...
- AspNetPager控件分页使用方法
AspNetPager控件官方下载地址:http://www.webdiyer.com/aspnetpager/ 把控件加到项目中(添加自定义控件的方法),并把它拖放到页面上 <asp:Scri ...
- unity 发布web player版,网页打开报Failed to initialize player's 3D settings
开始时我装的是unity 5.0.0b1,不知道在哪找的这个版本. web player 装的什么版本也忘了. 最后卸载了web player,重新安装web player并另外安装一个unity4. ...
- pb自动注册ole控件
方法一: 1.手工注册OCX控件 将该控件随程序一起发布,然后,将此文件拷到windows\system,或者直接放在本运行目录,然后执行dos命令,run( "regsvr32 *. ...
- C# StreamReader
C#中的StreamReader()有重载的参数是encoding默认貌似是UTF-8的 当我们读取文本文件时,一般需要将其指定问default,default是gb2312.
- unix下输出重定向
> 为重定向符号 >> 重定向不覆盖原文件内容 example: 1. 标准输出重定向 echo "123" > /home/123.txt ---- 标准 ...
- 堆排序C++实现
/* * heapsort.cpp * * Created on: 2016年3月30日 * Author: Lv_Lang */ //堆排序 #include <iostream> us ...
- 关于docker容器是怎样建立新的namespace的。
最近博客收到了一封交流的私信,感谢您的关注:现在就我理解的docker建立容器时namespace的建立问题做一个 个人的回答: 一,从原理角度来讲: docker创建container,说白了就是l ...