COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libjackcess/test_jackcess.cpp
Go to the documentation of this file.
00001 #include <stdio.h>
00002 
00003 #include <gcj/cni.h>
00004 #include <java/lang/System.h>
00005 #include <java/io/PrintStream.h>
00006 #include <java/lang/Throwable.h>
00007 #include <JackBox.h>
00008 #include <coopy/JackTextBook.h>
00009      
00010 #define JS(x) JvNewStringLatin1(x)
00011 
00012 using namespace java::lang;
00013 using namespace com::healthmarketscience::jackcess;
00014 using namespace coopy::store;
00015 using namespace coopy::store::mdb;
00016 
00017 int main(int argc, char *argv[]) {
00018      
00019   try
00020     {
00021       JvCreateJavaVM(NULL);
00022       JvAttachCurrentThread(NULL, NULL);
00023       
00024       String *message = JvNewStringLatin1("Hello from C++");
00025       JvInitClass(&System::class$);
00026       System::out->println(message);
00027       JackBox *jack = new JackBox();
00028       if (jack) {
00029         int x = jack->hello();
00030         printf("I have %d\n", x);
00031         jack->go();
00032 
00033         Database *db = jack->create(JS("new2.mdb"));
00034         if (!db) exit(1);
00035         {
00036           TableBuilder *tbl = jack->makeTable(JS("foo"));
00037           jack->addColumn(tbl,JS("col1"),JS("string"));
00038           jack->addColumn(tbl,JS("col2"),JS("string"));
00039           jack->addTable(db,tbl);
00040         }
00041         {
00042           TableBuilder *tbl = jack->makeTable(JS("foo2"));
00043           jack->addColumn(tbl,JS("col1"),JS("string"));
00044           jack->addColumn(tbl,JS("col2"),JS("string"));
00045           jack->addTable(db,tbl);
00046         }
00047         
00048         //delete jack;
00049         jack = NULL;
00050       }
00051 
00052       JvDetachCurrentThread();
00053     }
00054   catch (Throwable *t)
00055     {
00056       System::err->println(JvNewStringLatin1("Unhandled Java exception:"));
00057       t->printStackTrace();
00058     }
00059 
00060   JackTextBook book;
00061   Property p;
00062   p.put("file","new2.mdb");
00063   book.open(p);
00064 
00065   return 0;
00066 }
00067 
00068 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines