mysql connect c++
先前在测试mysql connect c++接口的时候运行其官方提供的例子
21.5.5.6. MySQL Connector/C++ Complete Example 2
The following code shows a complete example of how to use MySQL Connector/C++:
/* Copyright 2008 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
There are special exceptions to the terms and conditions of the GPL
as it is applied to this software. View the full text of the
exception in file EXCEPTIONS-CONNECTOR-C++ in the directory of this
software distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Standard C++ includes */
#include <stdlib.h>
#include <iostream>
/*
Include directly the different
headers from cppconn/ and mysql_driver.h + mysql_util.h
(and mysql_connection.h). This will reduce your build time!
*/
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
using namespace std;
int main(void)
{
cout << endl;
cout << "Let's have MySQL count from 10 to 1..." << endl;
try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
sql::PreparedStatement *pstmt;
/* Create a connection */
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "root", "root");
/* Connect to the
相关文档:
Windows:
1. 用系统管理员登陆系统。
2. 停止MySQL的服务。
3. 进入命令窗口(cmd),然后进入MySQL的安装目录,比如我的安装目录是c:\mysql,进入C:\mysql\bin
4. 跳过权限检查启动MySQL,
c:\mysql\bin>mysqld-nt --skip-grant-tables
5. 重新打开一个cmd窗口,进入c:\mysql\b ......
ERROR 1005 (HY000): Can't create table ' ****.frm' (errno: 150)
我是从以下几个方面解决了此问题:
1、确保参照的表和字段是存在的;
2、组成外键的字段要求被索引(主要是外键那个字段要求在其他表中是主键);
3、外键关联的两表或多表要求都是INNODB类型的表;
4、字段类型(说明)要一样`itemId` varchar( ......
修改makefile,在LIBS里面加上-lmemcached,比如原来 gcc test.c,现在 gcc test.c -lmemcached。这个库就是libmemcached提供的。
然后添加#include<libmemcached/memcached.h>,这个文件也是libmemcached提供的。
主函数里面需要添加:
memcached_st *memc;
uint32_t&nbs ......
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体" ......
导出
select field1,field2,field3 from tablename into outfile '/home/output1.csv' fields terminated by ','optionally enclosed by ''lines terminated by '\n';
导入
load data local infile '/home/output1.csv' into table tablename fields terminated by ','lines terminated by '\n'(field1,f ......