1 #include <SqlFactory.h>
3 int main(int argc
, char **argv
)
6 struct timeval timeout
;
7 struct timeval timeStamp
;
8 AbsSqlConnection
*con
= SqlFactory::createConnection(CSql
);
9 rv
= con
->connect("root","manager");
11 AbsSqlStatement
*stmt
= SqlFactory::createStatement(CSql
);
12 stmt
->setConnection(con
);
14 strcpy(statement
, "UPDATE t1 set f2=? where f1=?;");
15 rv
= stmt
->prepare(statement
);
16 if(rv
!=OK
) { delete stmt
; delete con
; return 4; }
17 printf("AFTER UPDATE PREPARE operation\n");
21 rv
= con
->beginTrans();
22 stmt
->setIntParam(1, 100);
23 stmt
->setIntParam(2, i
);
24 rv
= stmt
->execute(rows
);
26 printError(rv
, "Update failed with ret val %d", rv
);
31 printf("AFTER STMT FREE operation\n");
34 strcpy(statement
, "DELETE from t1 where f2=?;");
35 rv
= stmt
->prepare(statement
);
36 if(rv
!=OK
) { delete stmt
; delete con
; return 4; }
37 printf("AFTER DELETE PREPARE operation\n");
39 rv
= con
->beginTrans();
40 stmt
->setIntParam(1, 100);
41 rv
= stmt
->execute(rows
);
43 printError(rv
, "Update failed with ret val %d", rv
);
48 printf("AFTER STMT FREE operation\n");
52 strcpy(statement
, "SELECT f1 from t1 where f2=?;");
53 rv
= stmt
->prepare(statement
);
54 if(rv
!=OK
) { delete stmt
; delete con
; return 4; }
55 printf("AFTER SELECT PREPARE operation\n");
57 rv
= con
->beginTrans();
59 stmt
->bindField(1, &val
);
60 stmt
->setIntParam(1, 1);
61 rv
= stmt
->execute(rows
);
62 while (stmt
->fetch()!= NULL
)
64 printf("Tuple value %d\n", val
);
68 printf("AFTER STMT FREE operation\n");
73 printf("AFTER disconnect\n");