Advertisement
salahzar

jdbc access via c/jni

May 17th, 2017
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <printf.h>
  2. #include <stdlib.h>
  3. #include <zconf.h>
  4. #include <sys/time.h>
  5. #include "jdbcapi.h"
  6. #include "jni.h"
  7.  
  8. int main() {
  9.     JDBC_API *api = jdbcapi_create();
  10.     bool ret = api->get_connection(api, "jdbc:h2:tcp://localhost/~/h2/test", "sa", "test");
  11.  
  12.     struct timeval tv1, tv2;
  13.     gettimeofday(&tv1, NULL);
  14.  
  15.     for (int i = 0; i < 1000000; ++i) {
  16.         bool ret2 = api->execute(api, "insert into test(id,name,field,f2) values(nextval('RESTART'),'from c','a','a')");
  17.     }
  18.     gettimeofday(&tv2, NULL);
  19.  
  20.     printf("Total time = %f seconds\n",
  21.            (double) (tv2.tv_usec - tv1.tv_usec) / 1000000 +
  22.            (double) (tv2.tv_sec - tv1.tv_sec));
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement