1 /* create 't1' table with two fields f11 int, f12 char,
2 * create 3 threads and each one insert 1000 records in the table.
4 * AUTHOR : Jitendra Lenka
9 void *runInsTest(void *p
);
10 void runSelTest(void *p
);
14 DbRetVal rv
= conn
.open("root","manager");
17 printf("Error during connection %d\n",rv
);
21 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
24 printf("Auth failed\n");
28 tabDef
.addField("f11",typeInt
,0,NULL
,true);
29 tabDef
.addField("f12",typeString
,1020);
31 rv
= dbMgr
->createTable("t1",tabDef
);
34 printf("Table creation failed\n");
39 pthread_t thr
[THREADS
];
42 for(int i
=0;i
<THREADS
;i
++)
45 pthread_create(&thr
[i
],NULL
,&runInsTest
,(void*)&message
[i
]);
47 for(int i
=0;i
<THREADS
;i
++)
49 pthread_join(thr
[i
],(void**)&status
);
52 dbMgr
->dropTable("t1");
57 void* runInsTest(void *message
)
60 DbRetVal rv
= conn
.open("root","manager");
63 printf("Error during connection %d \n",rv
);
66 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
69 printf("Auth failed\n");
72 Table
*table
= dbMgr
->openTable("t1");
75 printf("Unable to open table\n");
80 char name
[1020] = "LAKSHYA";
81 table
->bindFld("f11",&id
);
82 table
->bindFld("f12",name
);
88 int val
= *(int*)message
;
89 for(i
=val
*1000; i
<(val
*1000)+1000;i
++)
91 rv
= conn
.startTransaction();
94 strcpy(name
,"LAKSHYA SOLUTIONS");
95 ret
= table
->insertTuple();
103 printf("Thread :%d Inserted :%d records.\n",val
,count
);
104 dbMgr
->closeTable(table
);