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 ...
随机推荐
- 移动互联网公司如何将BPM流程管理变身移动化?
背景介绍 OPPO是广东欧珀移动通信有限公司的旗下品牌,成立于2004年,是一家全球性的智能终端和移动互联网公司,致力于为客户提供最先进和最精致的智能手机.高端影音设备和移动互联网产品与服务,业务覆盖 ...
- JavaScript 对象的创建
Object类型是JavaScript中使用最多的一种类型.创建Object实例的方式有多种,接下来一一列举. 1. Object构造函数 person1的friends属性修改影响了person2的 ...
- js isArray
function isArray(value) { if (typeof Array.isArray === "function") { return Array.isArray( ...
- android 在使用studio 编写百度地图中遇到APP Scode码校验失败 问题
直接用打包出来的apk查看签名,具体如下: 1) 将apk修改后缀为 .zip文件后解压: 2) 进入解压后的META-INF目录,该目录下会存在文件CERT.RSA 3) 在该目录下打开cmd,输入 ...
- 谈谈eclipse使用技巧
俗话说的好啊,“工于利启事,必先善其器”,如果说你的编程功底是一个枪法的话,那么强大的eclipse就是android战士们最好的武器. 这里,我们来总结eclipse的使用技巧,从而使我们的编程达到 ...
- fc23升级fc24及字体问题解决
1,升级fc23到最新 dnf upgrade --refresh 2,安装dnf系统升级插件 dnf install dnf-plugin-system-upgrade 3,下载fc24包,忽略无法 ...
- 数据库DDL语句书写规范
数据库DDL语句书写规范 1.SQL语句编写说明编写SQL语句应遵循统一的规范,包括大小写.空格.换行.缩进等等,只有完全一样的SQL才能在数据库中共享,从而减少硬解析. 字段类型.长度:根据数据情况 ...
- SQL Server 在数据库中查找字符串(不知道表名的情况下 查找字符串)
declare @key varchar(30)set @key = '广州' --替换为要查找的字符串DECLARE @tabName VARCHAR(40),@colName VARCHAR(40 ...
- Integrating AngularJS with RequireJS
Integrating AngularJS with RequireJS When I first started developing with AngularJS keeping my contr ...
- SQL中随机数函数rand()简介
转自:http://database.51cto.com/art/201009/224397.htm 下文将为您介绍SQL中的随机函数rand(),供您参考,如果您是才接触SQL Server的新手, ...