corrected to accept hostname and connect to network
[csql.git] / test / sqlnetwork / Connect / conntest4.c
blobd7a365e6f8c53ad936f992614112eaef6fd9fa6a
1 // close the connection and call execute,it should fail.
3 // Author : Jitendra Lenka
5 #include<SqlNwConnection.h>
6 #include<SqlNwStatement.h>
7 #include<SqlFactory.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;
18 printf("Connection opened\n");
20 AbsSqlStatement *stmt = new SqlNwStatement();
21 stmt->setInnerStatement(NULL);
22 stmt->setConnection(con);
23 char statement[200];
24 strcpy(statement,"CREATE TABLE T1(F1 INT,F2 CHAR(20)); ");
26 int rows=0;
27 rv = stmt->prepare(statement);
28 if(rv!=OK) { delete stmt; delete con; return 2; }
29 printf("prepared successfully\n");
31 rv = con->disconnect();
32 if(rv!=OK)return 3;
33 printf("Disconnect successfully\n");
35 rv = stmt->execute(rows);
36 if(rv == OK) { printf("Test script failed \n"); delete stmt; return 4; }
37 printf("Test script passed\n");
38 delete stmt;
39 delete con;
40 return 0;