Package com.sleepycat.je.jca.ra

Examples of com.sleepycat.je.jca.ra.JEConnection


      Environment env = null;
      Transaction txn = null;
      Database db = null;
      SecondaryDatabase secDb = null;
      Cursor cursor = null;
      JEConnection dc = null;
      try {
    dc = getConnection(JE_ENV);

    env = dc.getEnvironment();
    DatabaseConfig dbConfig = new DatabaseConfig();
    SecondaryConfig secDbConfig = new SecondaryConfig();
    dbConfig.setAllowCreate(true);
    dbConfig.setTransactional(TRANSACTIONAL);
    secDbConfig.setAllowCreate(true);
    secDbConfig.setTransactional(TRANSACTIONAL);
    secDbConfig.setKeyCreator(new MyKeyCreator());

    /*
     * Use JEConnection.openDatabase() to obtain a cached Database
     * handle.  Do not call close() on Database handles obtained
     * using this method.
     */
    db = dc.openDatabase("db", dbConfig);
    secDb = dc.openSecondaryDatabase("secDb", db, secDbConfig);
    System.out.println("blort");
    cursor = db.openCursor(null, null);
    cursor.put(new DatabaseEntry(key.getBytes()),
         new DatabaseEntry(data.getBytes()));
      } finally {
    if (cursor != null) {
        cursor.close();
    }
    if (dc != null) {
        dc.close();
    }
      }
  } catch (Exception e) {
      System.err.println("Failure in put" + e);
  }
View Full Code Here


  try {
      Environment env = null;
      Transaction txn = null;
      Database db = null;
      Cursor cursor = null;
      JEConnection dc = null;
      try {
    dc = getConnection(JE_ENV);

    env = dc.getEnvironment();
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setAllowCreate(true);
    dbConfig.setTransactional(TRANSACTIONAL);

    /*
     * Use JEConnection.openDatabase() to obtain a cached Database
     * handle.  Do not call close() on Database handles obtained
     * using this method.
     */
    db = dc.openDatabase("db", dbConfig);
    cursor = db.openCursor(null, null);
    DatabaseEntry data = new DatabaseEntry();
    cursor.getSearchKey(new DatabaseEntry(key.getBytes()),
            data,
            null);
    return new String(data.getData());
      } finally {
    if (cursor != null) {
        cursor.close();
    }
    if (dc != null) {
        dc.close();
    }
      }
  } catch (Exception e) {
      System.err.println("Failure in get" + e);
      e.printStackTrace();
View Full Code Here

      envConfig.setAllowCreate(true);   
      InitialContext iniCtx = new InitialContext();
      Context enc = (Context) iniCtx.lookup("java:comp/env");
      Object ref = enc.lookup("ra/JEConnectionFactory");
      JEConnectionFactory dcf = (JEConnectionFactory) ref;
      JEConnection dc = dcf.getConnection(envDir, envConfig);
      return dc;
  } catch(Exception e) {
      System.err.println("Failure in getConnection " + e);
  }
  return null;
View Full Code Here

TOP

Related Classes of com.sleepycat.je.jca.ra.JEConnection

Copyright © 2018 www.massapicom. 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.