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
相关文档:
3.3 高效率开发
这一节介绍利用单元测试实现高效率开发。单元测试可以在几个方面提高开发效率:测试驱动开发、可视编程、快速排错、和提高调试效率。
测试驱动开发
指先编写测试代码,然后再编写产品代码使测试通过,有很多相关文章和书籍介绍这方面知识,限于编幅,这里就不讲了 ......
<!--
/* 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:"\@宋体" ......
CENTOS 5的虚拟机,怎么从图形界面切换到命令行界面
1.临时切换:
ctrl+alt+1 …… ctrl+alt+6一共六个控制台。
2.永久关闭图形化:
在root下输入 vi /etc/inittab 将init:5修改为init:3
Mysql rpm包安装,不能重定位(relocatable)
rpm包安装异常,--prefix 参数不能重定位,安装到另一个目录的原 ......
Can't open the mysql.plugin table. Please run mysql_upgrade to create it
当碰到这样的错误是没有初始化mysql数据库,可以运行如下脚本就可以解决
cd /opt/mysql-5.1.46
cd scripts/
./mysql_install_db --user=mysql --datadir=/usr/local/mysql/var/
运行如下的代码就可以解决上述问题 ......