蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx
- 文档编号:14706378
- 上传时间:2022-10-24
- 格式:DOCX
- 页数:14
- 大小:19.04KB
蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx
《蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx》由会员分享,可在线阅读,更多相关《蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx(14页珍藏版)》请在冰豆网上搜索。
#include<
my_global.h>
my_sys.h>
m_string.h>
/*forstrdup()*/
mysql.h>
my_getopt.h>
#ifdefHAVE_OPENSSL
enumoptions_client
{
OPT_SSL_SSL=256,
OPT_SSL_KEY,
OPT_SSL_CERT,
OPT_SSL_CA,
OPT_SSL_CAPATH,
OPT_SSL_CIPHER,
OPT_SSL_VERIFY_SERVER_CERT
};
#endif
staticchar*opt_host_name=NULL;
/*serverhost(default=localhost)*/
staticchar*opt_user_name=NULL;
/*username(default=loginname)*/
staticchar*opt_password=NULL;
/*password(default=none)*/
staticunsignedintopt_port_num=0;
/*portnumber(usebuilt-invalue)*/
staticchar*opt_socket_name=NULL;
/*socketname(usebuilt-invalue)*/
staticchar*opt_db_name=NULL;
/*databasename(default=none)*/
staticunsignedintopt_flags=0;
/*connectionflags(none)*/
sslopt-vars.h>
staticintask_password=0;
/*whethertosolicitpassword*/
staticMYSQL*conn;
/*pointertoconnectionhandler*/
staticconstchar*client_groups[]={"
client"
NULL};
staticstructmy_optionmy_opts[]=/*optioninformationstructures*/
{"
help"
'
?
'
"
Displaythishelpandexit"
NULL,NULL,NULL,
GET_NO_ARG,NO_ARG,0,0,0,0,0,0},
host"
h'
Hosttoconnectto"
(uchar**)&
opt_host_name,NULL,NULL,
GET_STR,REQUIRED_ARG,0,0,0,0,0,0},
password"
p'
Password"
opt_password,NULL,NULL,
GET_STR,OPT_ARG,0,0,0,0,0,0},
port"
P'
Portnumber"
opt_port_num,NULL,NULL,
GET_UINT,REQUIRED_ARG,0,0,0,0,0,0},
socket"
S'
Socketpath"
opt_socket_name,NULL,NULL,
user"
u'
Username"
opt_user_name,NULL,NULL,
sslopt-longopts.h>
{NULL,0,NULL,NULL,NULL,NULL,GET_NO_ARG,NO_ARG,0,0,0,0,0,0}
/*
*Printdiagnosticmessage.Ifconnisnon-NULL,printerrorinformation
*returnedbyserver.
*/
staticvoid
print_error(MYSQL*conn,char*message)
fprintf(stderr,"
%s\n"
message);
if(conn!
=NULL)
{
Error%u(%s):
%s\n"
mysql_errno(conn),mysql_sqlstate(conn),mysql_error(conn));
}
}
*Likeprint_error(),butusestatementhandlerratherthan
*connectionhandlertoaccesserrorinformation.
/*#@_PRINT_STMT_ERROR_*/
print_stmt_error(MYSQL_STMT*stmt,char*message)
if(stmt!
mysql_stmt_errno(stmt),
mysql_stmt_sqlstate(stmt),
mysql_stmt_error(stmt));
staticmy_bool
get_one_option(intoptid,conststructmy_option*opt,char*argument)
switch(optid)
case'
:
my_print_help(my_opts);
/*printhelpmessage*/
exit(0);
/*password*/
if(!
argument)/*novaluegiven;
solicititlater*/
ask_password=1;
else/*copypassword,overwriteoriginal*/
opt_password=strdup(argument);
if(opt_password==NULL)
print_error(NULL,"
couldnotallocatepasswordbuffer"
);
exit
(1);
while(*argument)
*argument++='
x'
;
ask_password=0;
break;
sslopt-case.h>
return(0);
#include"
process_prepared_statement.c"
int
main(intargc,char*argv[])
intopt_err;
MY_INIT(argv[0]);
load_defaults("
my"
client_groups,&
argc,&
argv);
if((opt_err=handle_options(&
argv,my_opts,get_one_option)))
exit(opt_err);
/*solicitpasswordifnecessary*/
if(ask_password)
opt_password=get_tty_password(NULL);
/*getdatabasenameifpresentoncommandline*/
if(argc>
0)
opt_db_name=argv[0];
--argc;
++argv;
/*initializeclientlibrary*/
if(mysql_library_init(0,NULL,NULL))
mysql_library_init()failed"
/*initializeconnectionhandler*/
conn=mysql_init(NULL);
if(conn==NULL)
mysql_init()failed(probablyoutofmemory)"
/*passSSLinformationtoclientlibrary*/
if(opt_use_ssl)
mysql_ssl_set(conn,opt_ssl_key,opt_ssl_cert,opt_ssl_ca,
opt_ssl_capath,opt_ssl_cipher);
mysql_options(conn,MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
(char*)&
opt_ssl_verify_server_cert
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 蛤蟆 笔记 MySQL 学习 编写 程序 预处理