File: factory.cpp

package info (click to toggle)
simpledb 1.5-1.4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, squeeze
  • size: 888 kB
  • ctags: 238
  • sloc: cpp: 529; makefile: 127; perl: 23; sh: 9
file content (34 lines) | stat: -rw-r--r-- 1,017 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <SimpleDB/SimpleDB.h>
#include <unistd.h>
#include <memory>

int main (int argc, char* argv[])
{
  std::cerr << "START" << std::endl ;
 std::cerr << "Process Id : " << getpid() << std::endl ;
  sleep (6) ;
  // memory leak check
  long int i = 0 ;
  while (i < 1000) {
    try {
      SimpleDB::SimpleDBFactory* factory  = SimpleDB::SimpleDBFactory::Instance() ;
      std::auto_ptr<SimpleDB::Database> db = factory->getDBHandle("nightowl") ;
      
      SimpleDB::Query query = db->newQuery();
      SimpleDB::LongColumn longCol = SimpleDB::LongColumn();
      SimpleDB::Column * columns[1] = {&longCol};
      query.bind(columns, 1);
      query.execute("SELECT count(moduleId) FROM Modules");
      query.fetchRow();
      //cerr << "I: " << i << endl ;
      i++ ;
      //std::cout << "Number: " << longCol << std::endl;
      factory->Kill() ;
    }
    catch (SimpleDB::Database::Exception &exc ){
      std::cerr << exc << std::endl ;
    }
  }
  std::cerr << "FINISH" << std::endl ;
  return 0 ;
}