Examples of DB


Examples of com.mongodb.DB

  @Singleton
  public DB getDB() {

    // MongoDB Setup
    final MongoURI mongoUri = new MongoURI(configuration.getMongoUri());
    final DB db;
    try {
      db = mongoUri.connectDB();
    } catch (UnknownHostException e) {
      throw new IllegalArgumentException("Cannot connect to MongoDB",e);
    }

    // Authenticate
    if (mongoUri.getUsername() != null && mongoUri.getPassword() != null) {
      db.authenticate(mongoUri.getUsername(), mongoUri.getPassword());
    }

    return db;

  }
View Full Code Here

Examples of com.mysql.clusterj.core.store.Db

     * @return the session
     */
    public Session getSession(Map properties) {
        ClusterConnection clusterConnection = getClusterConnectionFromPool();
        try {
            Db db = null;
            synchronized(this) {
                checkConnection(clusterConnection);
                db = clusterConnection.createDb(CLUSTER_DATABASE, CLUSTER_MAX_TRANSACTIONS);
            }
            Dictionary dictionary = db.getDictionary();
            return new SessionImpl(this, properties, db, dictionary);
        } catch (ClusterJException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new ClusterJFatalException(
View Full Code Here

Examples of com.sleepycat.db.Db

      appl = appl.substring(1);

    File helpTextFile = File.createTempFile("helptext", ".ht");
    helpTextFile.deleteOnExit();
    String helpTextFileName = helpTextFile.getAbsolutePath();
    Db helpText = new Db(null, 0);
    helpText.open(null,helpTextFileName, null, Db.DB_BTREE, Db.DB_TRUNCATE, 0644);

    File dbBaseFile = File.createTempFile("database", "db");
    dbBaseFile.deleteOnExit();
    String dbBaseFileName = dbBaseFile.getAbsolutePath();
    Db dbBase = new Db(null, 0);
    dbBase.open(null,dbBaseFileName, null, Db.DB_BTREE, Db.DB_TRUNCATE, 0644);

    File keyWordFile = File.createTempFile("keybase", "key");
    keyWordFile.deleteOnExit();
    String keyWordFileName = keyWordFile.getAbsolutePath();
    Db keyWord = new Db(null, 0);
    keyWord.open(null,keyWordFileName, null, Db.DB_BTREE, Db.DB_TRUNCATE, 0644);
    HelpKeyword helpKeyword = new HelpKeyword();

    // now input the hid.lst and store it into a hashmap
    FileReader fileReader = new FileReader(hid);
    StringBuffer strBuf = new StringBuffer();
    int n = 0;
    char[] c = new char[1024];
    while ((n = fileReader.read(c, 0, 1024)) != -1)
      strBuf.append(c, 0, n);
    String str = strBuf.toString();
    StringTokenizer strTokenizer = new StringTokenizer(str);
    while (strTokenizer.hasMoreTokens()) {
      String key = strTokenizer.nextToken();
      String data = strTokenizer.nextToken();
      hidlistTranslation.put(
        key.toUpperCase().replace(':', '_'),
        data.trim());
    }

    // lastly, initialize the indexBuilder
    if (!helpFiles.isEmpty())
      initXMLIndexBuilder();

    // here we start our loop over the hzip files.
    Iterator iter = helpFiles.iterator();
    while (iter.hasNext()) {
      // process one file
      // streamTable contains the streams in the hzip file
      //Hashtable streamTable = new Hashtable();
      Hashtable streamTable1 = new Hashtable();

      String xhpFileName = (String) iter.next();
      if (!xhpFileName.endsWith(".xhp")) {
        // only work on .xhp - files
        System.err.println(
          "ERROR: input list entry '"
            + xhpFileName
            + "' has the wrong extension (only files with extension .xhp "
            + "are accepted)");
        continue;
      }

      HelpCompiler hc =
        new HelpCompiler(
          streamTable1,
          xhpFileName,
          sourceRoot + File.separator + lang + File.separator,
          embeddStylesheet,
          module,
          lang);
      try {
        boolean success = hc.compile();
        if (!success) {
          System.err.println(
            "\nERROR: compiling help particle '"
              + xhpFileName
              + "' for language '"
              + lang
              + "' failed!");
          System.exit(1);
        }
      } catch (UnsupportedEncodingException e) {
        System.err.println(
          "\nERROR: unsupported Encoding Exception'"
            + "': "
            + e.getMessage());
        System.exit(1);
      }

      // Read the document core data
      byte[] byStr = (byte[]) streamTable1.get("document/id");
      String documentBaseId = null;
      if (byStr != null) {
        documentBaseId = new String(byStr, "UTF8");
      } else {
        System.err.println("corrupt compileroutput");
        System.exit(1);
      }

      String documentPath =
        new String(
          ((byte[]) streamTable1.get("document/path")),
          "UTF8");

      if (documentPath.startsWith("/"))
        documentPath = documentPath.substring(1);
      String documentJarfile =
        new String(
          ((byte[]) streamTable1.get("document/module")),
          "UTF8")
          + ".jar";

      byte[] byteStream = (byte[]) streamTable1.get("document/title");

      String documentTitle = null;
      if (byteStream != null)
        documentTitle = new String(byteStream, "UTF8");
      else
        documentTitle = "<notitle>";

      byte[] fileB = documentPath.getBytes("UTF8");
      byte[] jarfileB = documentJarfile.getBytes("UTF8");
      byte[] titleB = documentTitle.getBytes("UTF8");
      // add once this as its own id.
      addBookmark(dbBase, documentPath, fileB, null, jarfileB, titleB);

      if (init) {
        FileInputStream indexXSLFile =
          new FileInputStream(indexStylesheet);
        int read = 0;
        byte[] bytes = new byte[2048];
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        while ((read = indexXSLFile.read(bytes, 0, 2048)) != -1)
          baos.write(bytes, 0, read);
        createFileFromBytes("index.xsl", baos.toByteArray());

        xmlIndexBuilder.init("index");
        init = false;
      }

      // first the database *.db
      // ByteArrayInputStream bais = null;
      // ObjectInputStream ois = null;

      Object baos = streamTable1.get(appl + "/hidlist");
      if (baos == null)
        baos = streamTable1.get("default/hidlist");
      if (baos != null) {
        HashSet hidlist = (HashSet) baos;

        // now iterate over all elements of the hidlist
        Iterator hidListIter = hidlist.iterator();
        while (hidListIter.hasNext()) {
          String hid = (String) hidListIter.next();

          byte[] anchorB = null;
          int index = hid.lastIndexOf('#');
          if (index != -1) {
            anchorB = hid.substring(1 + index).getBytes("UTF8");
            hid = hid.substring(0, index);
          }
          addBookmark(dbBase, hid, fileB, anchorB, jarfileB, titleB);
        }
      }

      // now the keywords
      baos = streamTable1.get(appl + "/keywords");
      if (baos == null)
        baos = streamTable1.get("default/keywords");
      if (baos != null) {
        Hashtable anchorToLL = (Hashtable) baos;
        Enumeration enumer = anchorToLL.keys();
        String fakedHid = URLEncoder.encode(documentPath);
        while (enumer.hasMoreElements()) {
          String anchor = (String) enumer.nextElement();
          addBookmark(
            dbBase,
            documentPath,
            fileB,
            anchor.getBytes("UTF8"),
            jarfileB,
            titleB);
          String totalId = fakedHid + "#" + anchor;
          // System.err.println(hzipFileName);
          LinkedList ll = (LinkedList) anchorToLL.get(anchor);
          Iterator llIter = ll.iterator();
          while (llIter.hasNext())
            helpKeyword.insert((String) llIter.next(), totalId);
        }
      }

      // and last the helptexts
      baos = streamTable1.get(appl + "/helptexts");
      if (baos == null)
        baos = streamTable1.get("default/helptexts");
      if (baos != null) {
        Hashtable helpTextHash = (Hashtable) baos;
        Enumeration helpTextIter = helpTextHash.keys();
        while (helpTextIter.hasMoreElements()) {
          String helpTextId = (String) helpTextIter.nextElement();
          String helpTextText = (String) helpTextHash.get(helpTextId);

          String tHid =
            (String) hidlistTranslation.get(
              helpTextId.toUpperCase().replace(':', '_'));
          if (tHid != null)
            helpTextId = tHid;
          helpTextId = URLEncoder.encode(helpTextId);
          Dbt keyDbt = new Dbt(helpTextId.getBytes("UTF8"));
          Dbt textDbt = new Dbt(helpTextText.getBytes("UTF8"));
          helpText.put(null, keyDbt, textDbt, 0);
        }
      }
      // now the indexing
      // and last the helptexts
      baos = (byte[]) streamTable1.get(appl + "/text");
      if (baos == null)
        baos = (byte[]) streamTable1.get("default/text");

      if (baos != null) {
        byte[] bytes = (byte[]) baos;

        HelpURLStreamHandlerFactory.setMode(bytes);
        xmlIndexBuilder.indexDocument(
          new URL(
            "vnd.sun.star.help://"
              + module.toLowerCase()
              + "/"
              + URLEncoder.encode(documentPath)),
          "");
      }
    } // while loop over hzip files ending

    helpText.close(0);
    dbBase.close(0);
    helpKeyword.dump(keyWord);
    keyWord.close(0);
    if (!helpFiles.isEmpty())
      closeXMLIndexBuilder();

    // now copy the databases into memory, so we will be able to add it to the outputfile
    String mod = module.toLowerCase();
View Full Code Here

Examples of com.sleepycat.db.internal.Db

        throws DatabaseException {

        int createFlags = 0;

        createFlags |= xaCreate ? DbConstants.DB_XA_CREATE : 0;
        return new Db(dbenv, createFlags);
    }
View Full Code Here

Examples of com.tinygo.pdb.DB

        //System.out.println(System.getProperty("microedition.io.file.FileConnection.version"));

        WaitCanvas wc = WaitCanvas.getInstance();
        wc.setProgress(10);

        pdb = new DB();

        Timer timer = new Timer();
        timeSystem = new TimeSystem(timer);

        gobanCanvas = new GobanCanvas(display, new TileT2DPainter());
View Full Code Here

Examples of com.yahoo.ycsb.database.DB

    // create a DB
    String dbname = props.getProperty("db", DEFAULT_DB);

    ClassLoader classLoader = CommandLine.class.getClassLoader();

    DB db = null;

    try {
      Class dbclass = classLoader.loadClass(dbname);
      db = (DB) dbclass.newInstance();
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(0);
    }

    db.setProperties(props);
    try {
      db.init();
    } catch (DataStoreException e) {
      e.printStackTrace();
      System.exit(0);
    }

    System.out.println("Connected.");

    // main loop
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    for (;;) {
      // get user input
      System.out.print("> ");

      String input = null;

      try {
        input = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
      }

      if (input.compareTo("") == 0) {
        continue;
      }

      if (input.compareTo("help") == 0) {
        help();
        continue;
      }

      if (input.compareTo("quit") == 0) {
        break;
      }

      String[] tokens = input.split(" ");

      long st = System.currentTimeMillis();
      // handle commands
      if (tokens[0].compareTo("table") == 0) {
        if (tokens.length == 1) {
          System.out.println("Using table \"" + table + "\"");
        } else if (tokens.length == 2) {
          table = tokens[1];
          System.out.println("Using table \"" + table + "\"");
        } else {
          System.out.println("Error: syntax is \"table tablename\"");
        }
      } else if (tokens[0].compareTo("read") == 0) {
        if (tokens.length == 1) {
          System.out
              .println("Error: syntax is \"read keyname [field1 field2 ...]\"");
        } else {
          Set<String> fields = null;

          if (tokens.length > 2) {
            fields = new HashSet<String>();

            for (int i = 2; i < tokens.length; i++) {
              fields.add(tokens[i]);
            }
          }

          HashMap<String, String> result = new HashMap<String, String>();
          int ret = db.read(table, tokens[1], fields, result);
          System.out.println("Return code: " + ret);
          for (Map.Entry<String, String> ent : result.entrySet()) {
            System.out.println(ent.getKey() + "=" + ent.getValue());
          }
        }
      } else if (tokens[0].compareTo("scan") == 0) {
        if (tokens.length < 3) {
          System.out
              .println("Error: syntax is \"scan keyname scanlength [field1 field2 ...]\"");
        } else {
          Set<String> fields = null;

          if (tokens.length > 3) {
            fields = new HashSet<String>();

            for (int i = 3; i < tokens.length; i++) {
              fields.add(tokens[i]);
            }
          }

          Vector<HashMap<String, String>> results = new Vector<HashMap<String, String>>();
          int ret = db.scan(table, tokens[1],
              Integer.parseInt(tokens[2]), fields, results);
          System.out.println("Return code: " + ret);
          int record = 0;
          if (results.size() == 0) {
            System.out.println("0 records");
          } else {
            System.out.println("--------------------------------");
          }
          for (HashMap<String, String> result : results) {
            System.out.println("Record " + (record++));
            for (Map.Entry<String, String> ent : result.entrySet()) {
              System.out.println(ent.getKey() + "="
                  + ent.getValue());
            }
            System.out.println("--------------------------------");
          }
        }
      } else if (tokens[0].compareTo("update") == 0) {
        if (tokens.length < 3) {
          System.out
              .println("Error: syntax is \"update keyname name1=value1 [name2=value2 ...]\"");
        } else {
          HashMap<String, String> values = new HashMap<String, String>();

          for (int i = 2; i < tokens.length; i++) {
            String[] nv = tokens[i].split("=");
            values.put(nv[0], nv[1]);
          }

          int ret = db.update(table, tokens[1], values);
          System.out.println("Return code: " + ret);
        }
      } else if (tokens[0].compareTo("insert") == 0) {
        if (tokens.length < 3) {
          System.out
              .println("Error: syntax is \"insert keyname name1=value1 [name2=value2 ...]\"");
        } else {
          HashMap<String, String> values = new HashMap<String, String>();

          for (int i = 2; i < tokens.length; i++) {
            String[] nv = tokens[i].split("=");
            values.put(nv[0], nv[1]);
          }

          int ret = db.insert(table, tokens[1], values);
          System.out.println("Return code: " + ret);
        }
      } else if (tokens[0].compareTo("delete") == 0) {
        if (tokens.length != 2) {
          System.out.println("Error: syntax is \"delete keyname\"");
        } else {
          int ret = db.delete(table, tokens[1]);
          System.out.println("Return code: " + ret);
        }
      } else {
        System.out.println("Error: unknown command \"" + tokens[0] + "\"");
      }
View Full Code Here

Examples of de.chris_soft.nanoarchive.DB

   * @throws ClassNotFoundException
   */
  @Test
  public void testCreateNewDatabase() throws SQLException, ClassNotFoundException {
    FileUtils.deleteAll(new File(DB_PATH));
    DB db = new DB(DB_PATH);
    db.close();
  }
View Full Code Here

Examples of gov.nysenate.util.DB

    public static boolean bootstrap(String propertyFileName, boolean luceneReadOnly)
    {
        try
        {
            appInstance.config = new Config(propertyFileName);
            appInstance.db = new DB(appInstance.config, "mysqldb");
            appInstance.mailer = new Mailer(appInstance.config, "mailer");
            appInstance.environment = new Environment(appInstance.config, "env");
            appInstance.lucene = new Lucene(new File(appInstance.config.getValue("lucene.directory")), luceneReadOnly);
            appInstance.storage = new Storage(appInstance.environment.getStorageDirectory());
            return true;
View Full Code Here

Examples of kyotocabinet.DB

    private final static int BATCH_SIZE = 10000;
    private DB db;

    protected KyotoDataInterface(String name, String path, Class<T> objectClass, Combinator<T> combinator) {
        super(name, objectClass, combinator);
        db = new DB();
        File file = new File(new File(path), name + ".kcf");
        File parentDir = file.getParentFile();
        if (parentDir.isFile()) {
            throw new RuntimeException("Path " + parentDir.getAbsolutePath() + " is a file!");
        }
View Full Code Here

Examples of org.apache.jdbm.DB

    static public void main(String[] args) throws IOException, InterruptedException {

        long startTime = System.currentTimeMillis();
        //new File("/media/b0beb325-d9fe-4a30-9f58-77e6b15e6b7d/lost+found/large/").mkdirs();
        DB db = DBMaker.openFile("/media/b0beb325-d9fe-4a30-9f58-77e6b15e6b7d/db")
                .disableTransactions()
                .make();

        Map<Long,Integer> map = db.createTreeMap("test");
//        List<Long> test = db.createLinkedList("test");
        final double max = 1e10;

        for (Long i = 1L; i < max; i++) {
            if (i % 1e6 == 0) {
                System.out.println(i + " - " +(100D * i /max) + " %");
                //Thread.sleep(1000000);
            }
//            test.add(i);
            map.put(i,i.hashCode());
        }

        db.defrag(true);
        db.close();

        System.out.println("Finished, total time: " + (System.currentTimeMillis() - startTime) / 1000);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.