十五年测试老手,长期负责WEB\APP 项目测试,目前主要负责团队管理工作。

脚本实例:Loadrunner测试数据库、SQL语句性能

上一篇 / 下一篇  2011-11-20 20:00:33 / 个人分类:loadrunner

文章来源
  • 文章来源:【转载】

此代码为Loadrunner 8 通过C API类型的Vuser 测试MySQL性能,或者测试sql语句性能的脚本。51Testing软件测试网z%caDX:N6^

这东西很少有人用,网上资料很少,一般测试B/S的很多。51Testing软件测试网R$t t1f3g} nY

view plaincopy to clipboardprint?51Testing软件测试网 W5b lB$_MJ-p C+\

xK ]u6cV7m)D0Action()  51Testing软件测试网p)DOf5Z3Dm:T
 51Testing软件测试网 Z;D3tw4fAB
int rc;   
@:i[|5J%e#pE+^0int db_connection; // 数据库连接  51Testing软件测试网h'm%W`;l W n
int query_result; // 查询结果集 MYSQL_RES  51Testing软件测试网U|D,l NP
char** result_row; // 查询的数据衕  
OJ)l JZ6[$h,I*k0   
[2N&X4Z5R!U:z0char *server = "localhost";  
e[ o{9aegm,U8j0char *user = "root";  51Testing软件测试网 P-ji2X[Hs
char *password = "123456";  
\yCgR*AP d0char *database = "test";  
3E6N/Mg] {*G0int port = 3306;  
x x,x ur.g%f }0int unix_socket = NULL;   
w l!c"Ed\1o;[0int flags = 0;   51Testing软件测试网(R A v%b0?j
   51Testing软件测试网7ZM-t8O+~b*S%|V
// 找到libmysql.dll的所在位置.  
,}l4~ }P$fq4o0rc = lr_load_dll("C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin\\libmysql.dll");  51Testing软件测试网:?^"t0Jq9P,MV9?
if (rc != 0) {  51Testing软件测试网}$b&J.I`gK#Ve7Z
    lr_error_message("Could not load libmysql.dll");  51Testing软件测试网CBg b-| @l
    lr_abort();  51Testing软件测试网~`~$Tx,Qd
 
jq*hq&Sk.Uw+H0   
&eC#_x/{`? ? Hc0// 创建MySQL对象  51Testing软件测试网 s;SJ~7L|%Ys$S-A
db_connection = mysql_init(NULL);  
ZS@ge?^"s0if (db_connection == NULL) {  
4\0^+N6} |M$B^0    lr_error_message("Insufficient memory");  
vv$P%zrM y1N0    lr_abort();  51Testing软件测试网]6kbx zxgVE
 
HT!n'k9e#D}0   
O'j"|)Ulc6J3`&k0// 连接到MySQL数据库  51Testing软件测试网*{#@o`n/G
rc = mysql_real_connect(db_connection, server, user, password, database, port, unix_socket, flags);  51Testing软件测试网&`i4S*o8K0uS
if (rc == NULL) {  51Testing软件测试网p0}%Mr4t2]8i
    lr_error_message("%s", mysql_error(db_connection));  51Testing软件测试网v:c~7k!x A
    mysql_close(db_connection);  51Testing软件测试网,D/lXhf'He
    lr_abort();  51Testing软件测试网h!w,X Tx5bv
 51Testing软件测试网I1J z6i/O/Go,~|v
   
7v9x8LK%@"`A\f0// 向数据库插入数据  51Testing软件测试网m^USZN @
// 此处的 {ORDER_ID} 是一个参数,简单测试时可以用一个常数代替  51Testing软件测试网"fV QsA
lr_save_string (lr_eval_string("INSERT INTO test_data (order_id) VALUES ({ORDER_ID})"),"paramInsertQuery");   51Testing软件测试网 WD9NU$s
rc = mysql_query(db_connection, lr_eval_string("{paramInsertQuery}"));  51Testing软件测试网#[ Z$aj'j.r Y4@;B
if (rc != 0) {  
$IFki4Y(M0    lr_error_message("%s", mysql_error(db_connection));  51Testing软件测试网2\+j'?I K9q]/D
    mysql_close(db_connection);  
*Wm+y'H-cm7B t(~)L0    lr_abort();  51Testing软件测试网5Uh4c^ K |
 
` `1?!y0T4o#\0   
P.`e Y4~2X,o{4U"q%O,xu0// 从数据库读取一个数据并显示  
4XQ#qR0@Y0rc = mysql_query(db_connection, "SELECT order_id FROM test_data WHERE status IS FALSE LIMIT 1");  
U&Qr8]7m}P6@RK0if (rc != 0) {  51Testing软件测试网ZqtP)qu5d
    lr_error_message("%s", mysql_error(db_connection));  
#L Q3T5~%\#?w%v#ow0    mysql_close(db_connection);  51Testing软件测试网&HA"}g:_ M0@+E-j
    lr_abort();  51Testing软件测试网^WquU3{
 
:F2UA!o A,O5h P|i0query_result = mysql_use_result(db_connection);  51Testing软件测试网O$U)k#a|QSZ9]]
if (query_result == NULL) {  
RP1PX^'NKo0    lr_error_message("%s", mysql_error(db_connection));  51Testing软件测试网D^:`8k f cec.\
    mysql_free_result(query_result);  51Testing软件测试网.V moz.\9kV`jQ
    mysql_close(db_connection);  51Testing软件测试网-p6HU$u/_ v&I
    lr_abort();  51Testing软件测试网 Nf A6cT \7T!u8j
 
O8k:|DF+A gv0// 如果结果集包含多行数据,需要多次调用 mysql_fetch_row 直到返回NULL  
(o'xG#\^5j7L5H.|0result_row = (char **)mysql_fetch_row(query_result);   
*Yc5};u:M1aC9K!P/V0if (result_row == NULL) {  51Testing软件测试网e/P*\1g6s2zB
    lr_error_message("Did not expect the result set to be empty");  
8i'U]2v5Fe5Y0    mysql_free_result(query_result);  51Testing软件测试网:VF!h@V/[.I9oeL(~H
    mysql_close(db_connection);  51Testing软件测试网u\8i'D c
    lr_abort();  
a"`JJ0i#QecR0 51Testing软件测试网7{)g+~WB5X)l"A
// 保存参数,用于删除这行数据  51Testing软件测试网.DN&}aN-Zx
lr_save_string(result_row[0], "paramOrderID");  51Testing软件测试网/_,u4{k'M hiE
lr_output_message("Order ID is: %s", lr_eval_string("{paramOrderID}"));  
5`_)[bk0mysql_free_result(query_result);  
EGxz|:P D m3v0   
eiA/w D'c ?0// 在事务里更新一行数据,需要用InnoDB引擎  51Testing软件测试网jo5i0Cd)Gi
rc = mysql_query(db_connection, "BEGIN"); //启动事务  51Testing软件测试网 Qyv"MZ:o&N
if (rc != 0) {  
}/U-dO E bM5|0    lr_error_message("%s", mysql_error(db_connection));  51Testing软件测试网;sa-x%K1K5U;J
    mysql_close(db_connection);  51Testing软件测试网 G:A1Kr!c#Y
    lr_abort();  
.o)u `\Q5R0 
(F5\@!z c^LJ,l9D0// 使用 "FOR UPDATE" 锁住要更新的数据行  51Testing软件测试网8o;m5RF];lwN0@
rc = mysql_query(db_connection, "SELECT order_id FROM test_data WHERE status IS FALSE LIMIT 1 FOR UPDATE");   
c.n*VZq!O U:G0if (rc != 0) {  
$Q'xD6?i0    lr_error_message("%s", mysql_error(db_connection));  51Testing软件测试网4{ }zL't#Y euf
    mysql_close(db_connection);  51Testing软件测试网1J \/[ r i1D2bK
    lr_abort();  
2[aNF+?R!|t0 51Testing软件测试网'R@g!KW bmz
query_result = mysql_use_result(db_connection);  
'y I:UB'F w n2@/e0if (query_result == NULL) {  
,wFY+D8E`cL8`0    lr_error_message("%s", mysql_error(db_connection));  51Testing软件测试网$Cv"m"f:t%{3u#Q d
    mysql_free_result(query_result);  
(B(A'MR@GWg6{c0    mysql_close(db_connection);  51Testing软件测试网 m?Fa~vN2\u
    lr_abort();  51Testing软件测试网O:Y+QSJzZ
 51Testing软件测试网j8H_"YhZ-`
result_row = (char **)mysql_fetch_row(query_result);   51Testing软件测试网)i:}.F7Kb1Ab
if (result_row == NULL) {  51Testing软件测试网2wF n,g;}-y ?
    lr_error_message("没有查询到结果");  51Testing软件测试网 |G%Q YS P-@
    mysql_free_result(query_result);  51Testing软件测试网)vo2u"HK m
    mysql_close(db_connection);  
8}J1m1ny^0    lr_abort();  
!Oz3w/GE lc @0 51Testing软件测试网nQCO]+H Xs7d1nv/X
lr_save_string(result_row[0], "paramOrderID");  51Testing软件测试网'QK-n Ja{
lr_output_message("Order ID is: %s", lr_eval_string("{paramOrderID}"));  
3O$}9F Y6T7w"c0mysql_free_result(query_result);  
2O g c]&Ls2@#^ \0lr_save_string(lr_eval_string("UPDATE test_data SET status=TRUE, date_used=NOW() WHERE order_id='{paramOrderID}'"),"paramUpdateQuery");  51Testing软件测试网5~ iVwK Y(^x
rc = mysql_query(db_connection, lr_eval_string("{paramUpdateQuery}"));  
O-y.W*| UdW{0if (rc != 0) {  51Testing软件测试网Us!?S4C
    lr_error_message("%s", mysql_error(db_connection));  51Testing软件测试网z#b x0FctG+p"b*@
    mysql_close(db_connection);  
SY$J3MP-Z;i.cI2N0    lr_abort();  51Testing软件测试网;gXi n V.Y)N zQ\p
 
wt?V_0rc = mysql_query(db_connection, "COMMIT"); // 提交事务  51Testing软件测试网)vrja f Bq
if (rc != 0) {  
sy5v4R6D0    lr_error_message("%s", mysql_error(db_connection));  
*D5l,lA J/K0    mysql_close(db_connection);  
P8P2o9R:L wY3b0    lr_abort();  51Testing软件测试网O:c i#|$| Pf*tX
 
]%hcVy5_X f0   
mr7o$d u`0// 再次查找数据,应该为空了,因为前面的事务更新了标志  51Testing软件测试网TK_+t)n
rc = mysql_query(db_connection, "SELECT order_id FROM test_data WHERE status IS FALSE LIMIT 1");  
a ~B`'l9GG/q0if (rc != 0) {  51Testing软件测试网*rV&W\n]l
    lr_error_message("%s", mysql_error(db_connection));  51Testing软件测试网Ud;v:v}h
    mysql_close(db_connection);  51Testing软件测试网EyZc$tE
    lr_abort();  
kZDG7l e`0 51Testing软件测试网,IY\PZ;N!I
query_result = mysql_use_result(db_connection);  
!~9hQ ^8L(b?C0if (query_result == NULL) {  51Testing软件测试网8F J,`5pH;Hp
    lr_error_message("%s", mysql_error(db_connection));  51Testing软件测试网S-e$i"cns
    mysql_free_result(query_result);  
en`XS.a!uC}m0    mysql_close(db_connection);  
J0E7}P9@m {,E#Hu0    lr_abort();  51Testing软件测试网b-@Ao3m7w
 51Testing软件测试网 B3`;Ztlh)K4}P
result_row = (char **)mysql_fetch_row(query_result);  51Testing软件测试网!Z1l(EC ~G
if (result_row == NULL) {  51Testing软件测试网)[)ueDk+Mp1]`
    lr_output_message("Result set is empty as expected");  
7qI;K%^n0    mysql_free_result(query_result);  51Testing软件测试网4d6Q;P#D$v
} else {  
J*J G/bkE1C0    lr_error_message("Did not expect the result set to contain any rows");  51Testing软件测试网mb2`LUv#N,]m
    mysql_free_result(query_result);  
G(M Y+xi.|0    mysql_close(db_connection);  51Testing软件测试网)]3i3_:De
    lr_abort();  51Testing软件测试网*H`u9J"a+p,ima
 51Testing软件测试网l#xJqxX
   
6?gyMu0// 删除数据  
eH)z$F b,^3U Mw!j0lr_save_string(lr_eval_string("DELETE FROM test_data WHERE order_id = '{paramOrderID}'"),"paramDeleteQuery");  51Testing软件测试网W;TJ d8K0^{
rc = mysql_query(db_connection, lr_eval_string("{paramDeleteQuery}"));  51Testing软件测试网3J]Io+r
if (rc != 0) {  
6E:\(x(T&v0g3@5TM/d%Cbt0    lr_error_message("%s", mysql_error(db_connection));  
ZB f"YT0    mysql_close(db_connection);  51Testing软件测试网 _vL,`$El} x$R$x#~b
    lr_abort();  51Testing软件测试网Y%z R J$Qy6Y7K
 
+yL;ri3pyx0   
!c0?dJ0T%XB1{#W0// 释放MySQL资源  
qk8IIV;|e0mysql_close(db_connection);  51Testing软件测试网 `)g!tws
    return 0;  
fvQW:b#bZ'wH0}
m\l4b7s.V \ } HN#G051Testing软件测试网8r6sg j7@Lm J
Action()51Testing软件测试网O){ pMV9M e
{
;\ a/J(uSG1MD"?0int rc;
|8u8`K*BC)]"T0int db_connection; // 数据库连接51Testing软件测试网$B*VLHI.]
int query_result; // 查询结果集 MYSQL_RES51Testing软件测试网#K k;nvu_B P
char** result_row; // 查询的数据衕51Testing软件测试网 Z mK(vu

0?x P1TGu8w0char *server = "localhost";51Testing软件测试网K4k*^"_.{(D
char *user = "root";
ncaK*_7\ L0char *password = "123456";
RUx@f@0char *database = "test";51Testing软件测试网n\9v}Cpcfoa
int port = 3306;
.nfcy.c+X'W0int unix_socket = NULL;
M4^@.@&c0int flags = 0;51Testing软件测试网$@]V bY[

X9RRO1H P0// 找到libmysql.dll的所在位置.51Testing软件测试网%R_c)Ix5I+JF~(} r
rc = lr_load_dll("C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin\\libmysql.dll");51Testing软件测试网(n5}7d:uW+ZA`
if (rc != 0) {
c|U,Qk]q\1K0    lr_error_message("Could not load libmysql.dll");
Ty[J)MY4UNS0    lr_abort();51Testing软件测试网4H!v*KG2r H8\2p
}51Testing软件测试网"NL4rEa.glPf
51Testing软件测试网`R_-]5v ?Q
// 创建MySQL对象51Testing软件测试网M#_ U9ii,p#p
db_connection = mysql_init(NULL);51Testing软件测试网(PGt~ a$i
if (db_connection == NULL) {
!f~JK9g5Z/n0    lr_error_message("Insufficient memory");
mhW{2U wQ0    lr_abort();
P Mdm9hVLHg0}
t ih~Z2R5J0
8`6s(X3VH/p/_]h0// 连接到MySQL数据库51Testing软件测试网 I:_3a%c*w+` aw7u
rc = mysql_real_connect(db_connection, server, user, password, database, port, unix_socket, flags);51Testing软件测试网3y:X6o/\"j!wI }
if (rc == NULL) {51Testing软件测试网6h Yv.O(EC:yE9as M
    lr_error_message("%s", mysql_error(db_connection));
I?i[M)_0    mysql_close(db_connection);
+q(A LlbwE0    lr_abort();
4qd g V/S-p/`0}
4gm8R7X'@~$e#R{ e0
WJo6IZ@ I0// 向数据库插入数据51Testing软件测试网J L'c-`3q|
// 此处的 {ORDER_ID} 是一个参数,简单测试时可以用一个常数代替
3j(N/Q+h{0lr_save_string (lr_eval_string("INSERT INTO test_data (order_id) VALUES ({ORDER_ID})"),"paramInsertQuery");
M2I!rT)Y{S'S g0rc = mysql_query(db_connection, lr_eval_string("{paramInsertQuery}"));
psQ(t:cy5oc]T0if (rc != 0) {51Testing软件测试网B.x/pc]&H!GnC(T
    lr_error_message("%s", mysql_error(db_connection));
Rv;Jt:F2F%b:\0    mysql_close(db_connection);51Testing软件测试网9ZY K p/l)Ls;cvB.Bm
    lr_abort();
dd"p Lgwe%_:BG0}51Testing软件测试网lE.}+UC&}5Z(^T!o

;OmR n8o/g0// 从数据库读取一个数据并显示51Testing软件测试网PN3K#`k$d+|
rc = mysql_query(db_connection, "SELECT order_id FROM test_data WHERE status IS FALSE LIMIT 1");51Testing软件测试网&?^f/pA @
if (rc != 0) {51Testing软件测试网4o~"rS{:m~;B
    lr_error_message("%s", mysql_error(db_connection));51Testing软件测试网 K)O Z9RgS
    mysql_close(db_connection);
~'Z r%~:kR3I0    lr_abort();51Testing软件测试网3V,y/C.raEz
}
o_upszx#b0query_result = mysql_use_result(db_connection);51Testing软件测试网(y:_/yC6p4aO
if (query_result == NULL) {51Testing软件测试网&e,dVfgG_;p_
    lr_error_message("%s", mysql_error(db_connection));
5M#MDiQWwLSN0    mysql_free_result(query_result);
{fZASS#|1W0    mysql_close(db_connection);51Testing软件测试网#Gf:Ui+Ue"V
    lr_abort();
/J2t5^tbjY/p9L0}51Testing软件测试网 v Nwz/Z7uD)k
// 如果结果集包含多行数据,需要多次调用 mysql_fetch_row 直到返回NULL
GN IS6a"S~?Sx*K0result_row = (char **)mysql_fetch_row(query_result);
i d:O4r}"] s.n!U0if (result_row == NULL) {51Testing软件测试网i:g7_1Q ])T:PL
    lr_error_message("Did not expect the result set to be empty");
o5S/g5R*kR+^tt j0    mysql_free_result(query_result);51Testing软件测试网nk/s2C uu
    mysql_close(db_connection);51Testing软件测试网7ky9Dyw$p IWS^!a
    lr_abort();
|)KXB+k+_0}51Testing软件测试网$d5XO`gR+S.]6Qc
// 保存参数,用于删除这行数据
/AX?Lb%n md r0lr_save_string(result_row[0], "paramOrderID");51Testing软件测试网4e1WuweC"C gq
lr_output_message("Order ID is: %s", lr_eval_string("{paramOrderID}"));
9|n'V?YK,I0mysql_free_result(query_result);51Testing软件测试网Or6Y0nI|.w po
51Testing软件测试网2y`,}$@.~$L0T
// 在事务里更新一行数据,需要用InnoDB引擎
p+H/oL/D5Q0rc = mysql_query(db_connection, "BEGIN"); //启动事务51Testing软件测试网"vr9Gw:L Q J1n;c8Dg
if (rc != 0) {
C }R"eWm@:r0    lr_error_message("%s", mysql_error(db_connection));51Testing软件测试网 fcw8~?4YF{,d
    mysql_close(db_connection);
F VT {3CV0B0    lr_abort();51Testing软件测试网a)X9`JU#V'H
}51Testing软件测试网T-Aob E1U
// 使用 "FOR UPDATE" 锁住要更新的数据行
5}JaZ%m&OMs0rc = mysql_query(db_connection, "SELECT order_id FROM test_data WHERE status IS FALSE LIMIT 1 FOR UPDATE");
6EB0z z([ fv%{c0if (rc != 0) {51Testing软件测试网2zF#Og^
    lr_error_message("%s", mysql_error(db_connection));51Testing软件测试网@*sm/]pY@ ~ w
    mysql_close(db_connection);
8MG]*IRH3[M+n0    lr_abort();
"sz:tx1q0}
|3m,?IVnDj@R0query_result = mysql_use_result(db_connection);51Testing软件测试网+tu;i V8WM
if (query_result == NULL) {51Testing软件测试网?7d4O9X#k5{-uW}'x
    lr_error_message("%s", mysql_error(db_connection));
0Gg9P8P qcJ2o U7B'mw0    mysql_free_result(query_result);51Testing软件测试网f%iFuueq7w?2{@
    mysql_close(db_connection);51Testing软件测试网 MZIP#H$| J5AJ$E
    lr_abort();
-L!b!^IO0p'O"L9[_ D0}
,odBG9j [0a0result_row = (char **)mysql_fetch_row(query_result);51Testing软件测试网M4Wtz:pvr t a
if (result_row == NULL) {
h5qT.d:P h4gB0    lr_error_message("没有查询到结果");51Testing软件测试网G\t5{;CQ.fu
    mysql_free_result(query_result);
x7G*Fy%G$e Xn0    mysql_close(db_connection);
/ihMB _*oh0    lr_abort();51Testing软件测试网w)y"Wd(fPW
}
MtTW @^'b0lr_save_string(result_row[0], "paramOrderID");51Testing软件测试网w)s^qG\
lr_output_message("Order ID is: %s", lr_eval_string("{paramOrderID}"));
gu y2i P(L D8kJ0mysql_free_result(query_result);
/X{/qJV0lr_save_string(lr_eval_string("UPDATE test_data SET status=TRUE, date_used=NOW() WHERE order_id='{paramOrderID}'"),"paramUpdateQuery");51Testing软件测试网:F3VlMoW0?}
rc = mysql_query(db_connection, lr_eval_string("{paramUpdateQuery}"));51Testing软件测试网#Wu)s9q$t H2}_
if (rc != 0) {51Testing软件测试网5W{ji{
    lr_error_message("%s", mysql_error(db_connection));
;h)s&y%WV'@0    mysql_close(db_connection);51Testing软件测试网`.V-Dyk&b'K
    lr_abort();51Testing软件测试网*ipiF[4RV0W
}
3@!|b#HN5M0rc = mysql_query(db_connection, "COMMIT"); // 提交事务51Testing软件测试网oKcrU/X^ L*F\U/D
if (rc != 0) {51Testing软件测试网8HMpa+dZ%W+I*H[
    lr_error_message("%s", mysql_error(db_connection));51Testing软件测试网7Hf C1qD#`re
    mysql_close(db_connection);51Testing软件测试网B&XN.E1fL@k.D~"_
    lr_abort();51Testing软件测试网K {4|,pB/Z'd
}51Testing软件测试网-T ?,c0t,@!i;g

.\?j_ K]"^0// 再次查找数据,应该为空了,因为前面的事务更新了标志51Testing软件测试网&c Py(j o"D)a)z|`
rc = mysql_query(db_connection, "SELECT order_id FROM test_data WHERE status IS FALSE LIMIT 1");51Testing软件测试网2pY6Q.Q0s1Q"H0u/A
if (rc != 0) {
+f9eJ4DN0    lr_error_message("%s", mysql_error(db_connection));
u,RY(Z7fIq2w/Q0    mysql_close(db_connection);51Testing软件测试网"kU"_._ \j}
    lr_abort();
[w~6Jv;vx0}51Testing软件测试网_ cl_5Ic
query_result = mysql_use_result(db_connection);51Testing软件测试网P0s`%L|]
if (query_result == NULL) {
-G`GNLBf(s0    lr_error_message("%s", mysql_error(db_connection));
5\? Q ^-o.M1_:],R0    mysql_free_result(query_result);51Testing软件测试网.f0[gf(yr
    mysql_close(db_connection);
iH*q{@r4N0    lr_abort();51Testing软件测试网!Z)|5^7v)p(m
}51Testing软件测试网}Y0h]0[`2[
result_row = (char **)mysql_fetch_row(query_result);
8h ?*r1vH3r V0if (result_row == NULL) {51Testing软件测试网8Y_WT\$T|$_8j(v
    lr_output_message("Result set is empty as expected");
v"DAxhi0    mysql_free_result(query_result);51Testing软件测试网:Z7~:\p5f~)I
} else {
9EAw|l0    lr_error_message("Did not expect the result set to contain any rows");
yQ-Ub\5i%b8? [G0    mysql_free_result(query_result);51Testing软件测试网r/[)j&Te3S,p
    mysql_close(db_connection);
/p(Ed!sr tp A0    lr_abort();51Testing软件测试网 Z eG.s [0z5s_
}51Testing软件测试网`J:cw8s!_lK)r6\

m;iw5t1F3HQ$FU0// 删除数据
dE'n/hn!FM)} Ao:U0lr_save_string(lr_eval_string("DELETE FROM test_data WHERE order_id = '{paramOrderID}'"),"paramDeleteQuery");
:u-M&R$|I(k(A)o)T9I0rc = mysql_query(db_connection, lr_eval_string("{paramDeleteQuery}"));
H5K@:@7j'M}0if (rc != 0) {51Testing软件测试网h_,g.mjpMu$W
    lr_error_message("%s", mysql_error(db_connection));
\0PVO+JF7s0    mysql_close(db_connection);51Testing软件测试网 Ze$`(Of y?W
    lr_abort();
5C%~ r:D"Q*s0}
:x'e~6]h0
9R%Y8b'L)[;l8jg0// 释放MySQL资源51Testing软件测试网P de/DvZ+Z;Y
mysql_close(db_connection);51Testing软件测试网-? B/I"m.IyV2O#TU
return 0;51Testing软件测试网*W$T3[#uW-E
}51Testing软件测试网'E$k&PI8xW8on*S



TAG: LoadRunner loadrunner Loadrunner 脚本实例

edisonzhang的个人空间 引用 删除 edisonzhang   /   2012-01-10 14:36:57
有个问题请教下
char *server = "localhost";  
char *user = "root";  
char *password = "123456";  
char *database = "test";  
int port = 3306;  
int unix_socket = NULL;   
int flags = 0;  
数据库用户名密码 怎么 参数化啊
好像不参数化,虚拟用户只有一个是成功的其他都是不成功
edisonzhang的个人空间 引用 删除 edisonzhang   /   2012-01-10 14:35:33
3
xql00163com的个人空间 引用 删除 xql00163com   /   2011-11-21 10:33:04
虽然目前没有用到,不过谢谢分享先收藏了!
 

评分:0

我来说两句

Open Toolbar