adding test scripts
[csql.git] / test / sqlapi / Csql / Connect / executeafterclose.c
blob56320db10a5964f759c567c66d6f087447058224
1 /*
2 close the connection and call execute,it should fail.
3 */
5 #include"common.h"
7 int main()
9 DbRetVal rv = OK;
10 AbsSqlConnection *con = createConnection();
11 rv = con->connect("root","manager");
12 if(rv !=OK) {
13 delete con;
14 return 1;
16 printf("Connection opened\n");
18 AbsSqlStatement *stmt = createStatement();
19 stmt->setConnection(con);
20 char statement[200];
21 strcpy(statement,"CREATE TABLE T1(F1 INT,F2 CHAR(20)); ");
22 int rows=0;
23 rv = stmt->prepare(statement);
24 if(rv!=OK) {
25 con->disconnect();
26 delete stmt;
27 delete con;
28 return 2;
30 printf("prepared successfully\n");
32 rv = con->disconnect();
33 if(rv!=OK) {
34 delete con;
35 return 3;
37 printf("Disconnect successfully\n");
39 rv = stmt->execute(rows);
40 if(rv == OK) {
41 printf("Test script failed \n");
42 delete stmt; return 4;
44 printf("Execute failed after closing Connection\n");
45 stmt->free();
46 printf("Test script passed\n");
47 delete stmt; delete con;
48 return 0;