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
);
13 AbsSqlStatement
*dropstmt
= SqlFactory::createStatement(CSql
);
14 dropstmt
->setConnection(con
);
16 strcpy(statement
, "CREATE TABLE t1 (f1 int, f2 int, f3 char(20), primary key (f1));");
18 rv
= stmt
->prepare(statement
);
19 if (rv
!= OK
) {delete stmt
; delete con
; return -1; }
20 rv
= stmt
->execute(rows
);
21 if (rv
!= OK
) {delete stmt
; delete con
; return -1; }
25 strcpy(statement
,"INSERT INTO t1 VALUES(1234,5,'CSQL');");
26 rv
= stmt
->prepare(statement
);
27 if(rv
!=OK
) { delete stmt
; delete con
; return 4; }
29 strcpy(statement
, "DROP TABLE t1");
30 rv
= dropstmt
->prepare(statement
);
32 printf("DROP table failed\n");
33 con
->disconnect();delete stmt
; delete con
; return -1;
35 dropstmt
->execute(rows
);
38 rv
= con
->beginTrans();
39 rv
= stmt
->execute(rows
);
41 printError(rv
, "Insert failed with ret val %d", rv
);