1 #include<AbsSqlStatement.h>
4 #define ITERATIONS 10000
8 AbsSqlConnection
*con
= SqlFactory::createConnection(CSqlGateway
);
9 rv
= con
->connect("root", "manager");
10 if (rv
!= OK
) return 1;
11 AbsSqlStatement
*stmt
= SqlFactory::createStatement(CSqlGateway
);
12 stmt
->setConnection(con
);
18 strcpy(statement, "INSERT INTO t1 (f1, f2) VALUES (?, ?);");
19 rv = stmt->prepare(statement);
20 if (rv != OK) {delete stmt; delete con; return -1; }
21 for (int i = 0 ; i < ITERATIONS ; i++)
23 rv = con->beginTrans();
26 stmt->setIntParam(1, id1);
27 stmt->setIntParam(2, id1);
28 rv = stmt->execute(rows);
37 /*strcpy(statement, "UPDATE t1 set f2=? where f1=?;");
38 rv = stmt->prepare(statement);
39 if (rv != OK) {delete stmt; delete con; return -1; }
41 for (int i = 0 ; i < ITERATIONS ; i++)
43 rv = con->beginTrans();
45 stmt->setIntParam(2, i);
46 stmt->setIntParam(1, newVal);
47 rv = stmt->execute(rows);
48 if (rv != OK && rows !=1) break;
56 strcpy(statement
, "DELETE FROM t1 where f1=?;");
57 rv
= stmt
->prepare(statement
);
58 if (rv
!= OK
) {delete stmt
; delete con
; return -1; }
59 stmt
->bindField(1, &id1
);
61 for (int i
= 0 ; i
< ITERATIONS
; i
++)
63 rv
= con
->beginTrans();
65 stmt
->setIntParam(1, i
+100000);
66 rv
= stmt
->execute(rows
);
67 if (rv
!= OK
&& rows
!= 1) break;