蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx

上传人:b****3 文档编号:14706378 上传时间:2022-10-24 格式:DOCX 页数:14 大小:19.04KB
下载 相关 举报
蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx_第1页
第1页 / 共14页
蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx_第2页
第2页 / 共14页
蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx_第3页
第3页 / 共14页
蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx_第4页
第4页 / 共14页
蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx

《蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx》由会员分享,可在线阅读,更多相关《蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx(14页珍藏版)》请在冰豆网上搜索。

蛤蟆笔记MySQL学习C编写MySQL程序九预处理Word文档格式.docx

#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

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科 > 文化宗教

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1