2 create table T1 ,Insert some records in it.
3 Close the connection, Fetch should fail.
11 AbsSqlConnection
*con
= createConnection();
12 rv
= con
->connect("root","manager");
17 printf("Connection opened\n");
19 AbsSqlStatement
*stmt
= createStatement();
20 stmt
->setConnection(con
);
22 strcpy(statement
,"CREATE TABLE T1(F1 INT,F2 INT);");
24 rv
= stmt
->prepare(statement
);
31 printf("Statement Prepared\n");
33 rv
= stmt
->execute(rows
);
41 printf("Table T1 CREATED\n");
43 // insert into statement
44 strcpy(statement
,"INSERT INTO T1 VALUES(1,1);");
45 rv
= stmt
->prepare(statement
);
46 if(rv
!=OK
) { con
->disconnect(); delete stmt
; delete con
; return 4; }
47 rv
= con
->beginTrans();
48 if(rv
!=OK
) { con
->disconnect(); delete stmt
; delete con
; return 5; }
49 rv
= stmt
->execute(rows
); if(rv
!=OK
) return 6;
55 printf("One record inserted\n");
57 strcpy(statement
,"SELECT F2 FROM T1 ;");
58 rv
= stmt
->prepare(statement
);
59 if(rv
!=OK
) { con
->disconnect(); delete stmt
; delete con
; return 10; }
61 stmt
->bindField(1,&id
);
62 rv
= con
->beginTrans();
66 stmt
->close(); stmt
->free();
67 rv
= con
->disconnect(); //close the connection
70 rettype
= (char*)stmt
->fetch();
71 if(rettype
==NULL
&& rv
== OK
) {
72 printf("Fetch Failed After closing Connection,\n");
73 con
->connect("root", "manager");
74 stmt
->setConnection(con
);
75 strcpy(statement
,"DROP TABLE T1;");
76 rv
= stmt
->prepare(statement
);
77 rv
= stmt
->execute(rows
);
78 if(rv
==OK
) { printf("Table Dropped successfully\n"); }
79 stmt
->free(); delete stmt
; delete con
;
80 printf("Test script passed\n");
83 printf("Test script Failed\n");
85 delete stmt
; delete con
;