在最後面加上
「CHARACTER SET utf8;」即可
「CHARACTER SET utf8;」即可
#includeusing namespace std; int main(int argc,char *argv[]) { cout<<"ttt"<<"AAA"; return 0; }
Python Exception <class 'TypeError'> 'map' object is not subscriptable:
原本以為是我什麼地方搞錯了,還跑去官網去查文件一篇一篇讀,根本....#include<iostream>
#include <stdlib.h>
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
using namespace std;
int main()
{
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
driver = get_driver_instance();
con = driver->connect("localhost", "username", "password");
con->setSchema("database");
stmt = con->createStatement();
stmt->execute("INSERT INTO children(no,fname,age) VALUE(8,'Amy',5)");
while(res->next())
{
cout << "id = "<<res->getInt("no")<<"\t";
cout << "fname = "<<res->getString("fname")<<"\t";
cout << "age = " <<res->getString(3)<<"\t";
cout <<endl;
}
|
$ mysql -u root mysql
mysql> SET password=PASSWORD('2jennifer');
|
mysql> GRANT ALL ON *.* TO [username] IDENTIFIED BY [password]
|
mysql> use myssql;
mysql> SELECT user,host,password FROM user;
|
mysql> exit;
$ mysql -u [username] -p#這裡 -p代表需要輸入密碼
|
mysql> CREATE DATABASE [資料庫名]
mysql> use [資料庫名]
|
mysql> SHOW DATABASES;
|
CREATE TABLE children(
no INT AUTO_INCREMENT NOT NULL PRIMARY KEY /*此為鍵值*/
, fname VARCHAR(30)
, age INT
)
|
mysql> SOURCE AddTable.sql;
|
mysql> SHOW TABLES FROM [database name];
|
mysql> INSERT INTO children(fname,age) VALUE("Nick",9);
mysql> INSERT INTO children(fname,age) VALUE("Jack",12);
|
mysql> SELECT * FROM children;
|
mysql> SELECT no,fname FROM children;
|
mysql> SELECT * FROM children WHERE fname='Jack';
|
mysql> SELECT * FROM children WHERE fname LIKE 'N%';
|