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
相关文档:
<!--
/* 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:"\@宋体" ......
php+mysql扎实个人基本功
一. 10句话
1.不要依赖register_global=ON的环境,从你刚懂得配置php运行环境甚至尚不明白register_global的ON/OFF会对自己有什么影响的那天起,就应该勇敢地把它设为OFF.
2.写程序前看看怎么用error_reporting.
3.不懂就问本身没错,但你需要在那之前查查手册。
4.当然,你需要懂得使用手 ......
(1)
外键的使用:
外键的作用,主要有两个:
一个是让数据库自己通过外键来保证数据的完整性和一致性.
如:
有表A,表B中一字段是表A某一字段的外键.当删除表A记录时,表B相应记录会作相应处理(删除/或设置外键列为NULL).但若删除表B记录,表A的记录,则不会受影响!
一个就是能够增加ER图的可读性
&nbs ......
使用临时表的好处:
使用临时表存放中间结果,加速查询,或存放临时结果.
(1)
创建临时表很容易,给正常的CREATE TABLE语句加上TEMPORARY关键字:
CREATE TEMPORARY TABLE tmp_table (
name VARCHAR(10) NOT NULL,
value INTEGER NOT NULL
)
(2)
临时表将在你连接MySQL期间存在。当你断开时,MySQL ......
(1)
存储过程是数据库服务器端的一段程序.
mysql的存储过程,只有版本是mysql5.0或以上的才有此特性.
(2)
什么时候需要用存储过程
存储过程通常是一些经常要执行的任务,这些任务往往是针对大量的记录而进行的。在服务器上执行存储过程,可以
改善应用程序的性能。这是因为:
2.1.
服务器往往具有强大的计算能力和速 ......