public ODatabaseDocumentTxPooled(final ODatabaseDocumentPool iOwnerPool, final String iURL, final String iUserName, final String iUserPassword) { super(iURL); ownerPool = iOwnerPool; userName = iUserName; super.open(iUserName, iUserPassword); }
protected ODatabaseDocumentTx docDb() { try { ODatabaseDocumentTx db = pool.acquire(); metrics().meter(POOL_ACQUIRE_METRIC).mark(); return db; } catch (Exception e) { metrics().meter(POOL_EXHAUSTED_METRIC).mark(); LOG.error(e.getMessage(), e); return new ODatabaseDocumentTx(config.connectionString).open(config.user, config.password); } }
ODatabaseDocumentTx db = new ODatabaseDocumentTx(path); db.open("root","root"); db.command(new OCommandSQL("update <document name > set a=30 where c=3")).execute();
@Override public ODatabaseDocumentTx acquire() { String uri = connectionUri(name); ODatabaseDocumentTx db = new ExplainODatabaseDocumentTx(uri, explainLogger); db.open(SYSTEM_USER, SYSTEM_PASSWORD); return db; } };
@SuppressWarnings("resource") public void open( Properties connProperties ) throws OdaException { String url = connProperties.getProperty(DB_URI_PROPERTY);//"remote:127.0.0.1/Orienteer"; String username = userData!=null?userData.getUserName():connProperties.getProperty(DB_USER_PROPERTY);//"admin"; String password = userData!=null?userData.getPassword():connProperties.getProperty(DB_PASSWORD_PROPERTY);//"admin"; try { db = new ODatabaseDocumentTx(url).open(username, password); m_isOpen = true; } catch (Exception e) { throw new OdaException(e); } }
@Override public ODatabaseDocumentTx connect(final String name, final boolean create) { checkNotNull(name); ensureStarted(); String uri = connectionUri(name); ODatabaseDocumentTx db = new ODatabaseDocumentTx(uri); if (db.exists()) { db.open(SYSTEM_USER, SYSTEM_PASSWORD); log.debug("Opened database: {} -> {}", name, db); } else { if (create) { db.create(); log.debug("Created database: {} -> {}", name, db); // invoke created callback try { created(db, name); } catch (Exception e) { Throwables.throwIfUnchecked(e); throw new RuntimeException(e); } } else { log.debug("Database does not exist: {}", name); } } return db; }
/** * open database */ protected void initDb() { try { if (db.isClosed()) { db.open(repositoryFactory.getApplicationSettings().getSetting("orientDB.login"), repositoryFactory.getApplicationSettings().getSetting("orientDB.password")); } } catch (Exception e) { throw new RuntimeException("Could not open database.", e); } } }
/** * open database */ protected void initDb() { try { if (db.isClosed()) { db.open(repositoryFactory.getApplicationSettings().getSetting("orientDB.login"), repositoryFactory.getApplicationSettings().getSetting("orientDB.password")); } } catch (Exception e) { throw new RuntimeException("Could not open database.", e); } }
private static String remote = "remote:localhost/"; public static void main(String[] args) { String dbName = "DBname"; String path = remote + dbName; OServerAdmin serverAdmin; try { serverAdmin = new OServerAdmin(path).connect("root", "root"); if (serverAdmin.existsDatabase()) { System.out.println("Database '" + dbName + "' already exists"); ODatabaseDocumentTx db = new ODatabaseDocumentTx(path); db.open("root", "root"); Iterable<ODocument> results = db.command(new OSQLSynchQuery<ODocument>( "SELECT FROM Books WHERE 'Adventure' IN categories AND year = 1980")).execute(); for (ODocument result : results) { System.out.println("Title: " + result.field("title") + " Category: " + result.field("categories") + " Year: " + result.field("year")); } db.close(); } else { serverAdmin.createDatabase(dbName, "document", "plocal"); System.out.println("Database " + dbName + " created"); } serverAdmin.close(); } catch (IOException e) { e.printStackTrace(); } }
context.rawGraph.open(username, password);
protected void internalOpen() { if(internal == null ) { super.open(userName, password); }else { internal.activateOnCurrentThread(); internal.setStatus(STATUS.OPEN); } if (getMetadata().getSchema().countClasses() == 0) getMetadata().reload(); }
@After public void tearDown() throws Exception { new ODatabaseDocumentTx(config.connectionString).open(config.user, config.password).drop(); }
public static ODatabase openDatabase(final ODatabaseIdentifier databaseIdentifier, final OStorageRemote.CONNECTION_STRATEGY connectionStrategy) { ODatabaseDocument database = null; switch (databaseIdentifier.getMode()) { case PLOCAL: case MEMORY: database = new ODatabaseDocumentTx(databaseIdentifier.getUrl()).open("admin", "admin"); break; case REMOTE: database = new ODatabaseDocumentTx(databaseIdentifier.getUrl()); database.setProperty(OStorageRemote.PARAM_CONNECTION_STRATEGY, connectionStrategy.toString()); database.open("root", databaseIdentifier.getPassword()); break; } return database; }
@Override public void onAfterServerStartupAndActivation(OrientDbWebApplication app) throws Exception { IOrientDbSettings settings = app.getOrientDbSettings(); ODatabaseDocumentTx db = new ODatabaseDocumentTx(settings.getDBUrl()); if(!db.exists()) { db = db.create(); onDbCreated(db, settings); } if(db.isClosed()) db.open(settings.getAdminUserName(), settings.getAdminPassword()); db.getMetadata().load(); db.close(); }
@Override public void begin() { ODatabaseDocumentTx documentDatabase = init(); if (documentDatabase == null) { switch (dbType) { case DOCUMENT: documentDatabase = new ODatabaseDocumentTx(dbURL); documentDatabase.open(dbUser, dbPassword); break; case GRAPH: final OrientGraphFactory factory = new OrientGraphFactory(dbURL, dbUser, dbPassword); final OrientBaseGraph graphDatabase = tx ? factory.getTx() : factory.getNoTx(); graphDatabase.setUseLightweightEdges(useLightweightEdges); graphDatabase.setStandardElementConstraints(standardElementConstraints); documentDatabase = graphDatabase.getRawGraph(); pipeline.setGraphDatabase(graphDatabase); break; } pipeline.setDocumentDatabase(documentDatabase); } documentDatabase.declareIntent(new OIntentMassiveInsert()); }
@Override public void onAfterServerStartupAndActivation(OrientDbWebApplication app) throws Exception { IOrientDbSettings settings = app.getOrientDbSettings(); ODatabaseDocumentTx db = new ODatabaseDocumentTx(DB_MEMORY_URL); if(!db.exists()) db = db.create(); if(db.isClosed()) db.open(settings.getAdminUserName(), settings.getAdminPassword()); db.getMetadata().load(); db.close(); }
if (documentDatabase.exists() && dbAutoDropIfExists) { log(OETLProcessor.LOG_LEVELS.INFO, "Dropping existent database '%s'...", dbURL); documentDatabase.open(dbUser, dbPassword); documentDatabase.drop(); documentDatabase.open(dbUser, dbPassword); } else if (dbAutoCreate) { documentDatabase.create();
case DOCUMENT: documentDatabase = new ODatabaseDocumentTx(dbURL); documentDatabase.open(dbUser, dbPassword); break;