modified to accept host and connect to the network
[csql.git] / test / sqlnetwork / Select / selecttest8.c
blobe0e0e065c52a39433847af7a2de009fc788fce13
1 /* prepare,execute,free,prepare, second prepare should pass.
3 * Author : Jitendra Lenka
4 */
5 #include<SqlNwConnection.h>
6 #include<SqlNwStatement.h>
7 #include<SqlFactory.h>
8 //#include<Info.h>
9 int main()
11 DbRetVal rv = OK;
12 AbsSqlConnection *con = new SqlNwConnection();
13 con->setInnerConnection(NULL);
14 SqlNwConnection *conn = (SqlNwConnection *)con;
15 conn->setHost("localhost", 5678);
16 rv = con->connect("root","manager");
17 if(rv!=OK)return 1;
19 AbsSqlStatement *stmt = new SqlNwStatement();
20 stmt->setInnerStatement(NULL);
21 stmt->setConnection(con);
22 char statement[200];
24 strcpy(statement,"CREATE TABLE T1(F1 INT,F2 CHAR(20));");
25 int rows=0;
27 rv = stmt->prepare(statement);
28 if(rv!=OK) { delete stmt; delete con; return 1; }
29 printf("Prepare the Statement\n");
30 rv = stmt->execute(rows);
31 if(rv!=OK) { delete stmt; delete con; return 2; }
32 printf("Execute the Statement\n");
34 //again prepare
35 strcpy(statement,"DROP TABLE T1;");
36 rv = stmt->prepare(statement);
37 if(rv!=OK) { printf("Test script failed\n"); delete stmt; delete con; return 3; }
38 printf("Again prepare passed\n");
40 rv = stmt->execute(rows);
41 if(rv==OK)printf("Table dropped successfully\n");
42 delete stmt;
43 delete con;
44 return 0;