default OrientDB newOrientDB() { return new OrientDB(this); }
OrientDBDocumentCollectionManagerFactory(String host, String user, String password, String storageType) { this.host = host; this.user = user; this.password = password; this.storageType = ofNullable(storageType) .map(String::toUpperCase) .map(ODatabaseType::valueOf) .orElse(ODatabaseType.PLOCAL); this.orient = new OrientDB("remote:" + host, user, password, OrientDBConfig.defaultConfig()); }
public OrientGraphFactory() { this(new OrientDB("embedded:.", OrientDBConfig.defaultConfig()), "memory_" + System.currentTimeMillis(), ODatabaseType.MEMORY, ADMIN, ADMIN); this.shouldCloseOrientDB = true; }
/** * Open a new database pool from a environment and a database name with a custom configuration, useful in case the application * access to only a database or do not manipulate databases. * * @param environment the url for an environemnt, like "embedded:/the/environment/path/" or "remote:localhost" * @param database the database for the current url. * @param user the database user for the current pool of databases. * @param password the password relative to the user * @param configuration the configuration relative to the current pool. */ public ODatabasePool(String environment, String database, String user, String password, OrientDBConfig configuration) { orientDb = new OrientDB(environment, configuration); autoclose = true; internal = orientDb.openPool(database, user, password, configuration); }
public OrientGraphFactory(String url, String user, String password) { this.user = user; this.password = password; this.labelAsClassName = true; initConnectionParameters(url); factory = new OrientDB(connectionURI, OrientDBConfig.defaultConfig()); shouldCloseOrientDB = true; }
/** * Method intended for internal usage by {@link ru.vyarus.guice.persist.orient.db.DatabaseManager}: it creates * {@link OrientDB} instance (on lifecycle start), available for injection with provider * ({@code Provider<OrientDB>}) and used by all pools and other apis in order to create connections to * configured database. * <p> * There is not much sense to use it directly, otherwise then using it in tests to delete remote database * after persistence lifecycle stop: * <pre>{@code * OrientDB db = factory.createOrientDB() * if (db.exists(factory.getDbName())) { * db.drop(factory.getDbName()) * } * db.close() * }</pre> * * @return created {@link OrientDB} instance (always new) * @see #enableAutoCreationRemoteDatabase(String, String, ODatabaseType) */ public OrientDB createOrientDB() { // perform lookup just before instance creation to simplify configuration (otherwise it might // be complicated to execute configuration before orient module creation) lookupRemoteConfig(); return isAutoCreateRemote() ? new OrientDB(getDbUrl(), serverUser, serverPassword, config) : new OrientDB(getDbUrl(), config); }
public OrientJdbcConnection(final String jdbcdDUrl, final Properties info) { this.dbUrl = jdbcdDUrl.replace("jdbc:orient:", ""); this.info = info; readOnly = false; final String username = info.getProperty("user", "admin"); final String password = info.getProperty("password", "admin"); final String serverUsername = info.getProperty("serverUser", ""); final String serverPassword = info.getProperty("serverPassword", ""); OURLConnection connUrl = OURLHelper.parseNew(dbUrl); orientDB = new OrientDB(connUrl.getType() + ":" + connUrl.getPath(), serverUsername, serverPassword, OrientDBConfig.defaultConfig()); if (!serverUsername.isEmpty() && !serverPassword.isEmpty()) { orientDB.createIfNotExists(connUrl.getDbName(), connUrl.getDbType().orElse(ODatabaseType.MEMORY)); } database = orientDB.open(connUrl.getDbName(), username, password); orientDBisPrivate = true; status = ODatabase.STATUS.OPEN; }
@Override public Connection getConnection(String username, String password) throws SQLException { if (orientDB == null) { Properties info = new Properties(this.info); info.put("user", username); info.put("password", password); final String serverUsername = info.getProperty("serverUser", ""); final String serverPassword = info.getProperty("serverPassword", ""); String orientDbUrl = dbUrl.replace("jdbc:orient:", ""); OURLConnection connUrl = OURLHelper.parseNew(orientDbUrl); OrientDBConfig settings = OrientDBConfig.builder() .addConfig(OGlobalConfiguration.DB_POOL_MIN, Integer.valueOf(info.getProperty("db.pool.min", "1"))) .addConfig(OGlobalConfiguration.DB_POOL_MAX, Integer.valueOf(info.getProperty("db.pool.max", "10"))) .build(); orientDB = new OrientDB(connUrl.getType() + ":" + connUrl.getPath(), serverUsername, serverPassword, settings); if (!serverUsername.isEmpty() && !serverPassword.isEmpty()) orientDB.createIfNotExists(connUrl.getDbName(), connUrl.getDbType().orElse(ODatabaseType.MEMORY)); pool = new ODatabasePool(orientDB, connUrl.getDbName(), username, password); } return new OrientJdbcConnection(pool.acquire(), orientDB, info); }
orient = new OrientDB("embedded:" + dbCtx, dbUser, dbPassword, null); if (orient.exists(dbCtx) && dbAutoDropIfExists) { orient.drop(dbCtx); dbCtx = dbCtx.substring(0, dbCtx.lastIndexOf("/")); orient = new OrientDB("embedded:" + dbCtx, dbUser, dbPassword, null); orient = new OrientDB("remote:" + dbCtx, serverUser, serverPassword, null); String dbName = dbCtx.substring(dbCtx.lastIndexOf("/"));
/** * Open a new database pool from a url and additional configuration, useful in case the application access to only a database or * do not manipulate databases. * * @param url the full url for a database, like "embedded:/full/path/to/database" or "remote:localhost/database" * @param user the database user for the current pool of databases. * @param password the password relative to the user * @param configuration the configuration relative to the current pool. */ public ODatabasePool(String url, String user, String password, OrientDBConfig configuration) { OURLConnection val = OURLHelper.parseNew(url); orientDb = new OrientDB(val.getType() + ":" + val.getPath(), configuration); autoclose = true; internal = orientDb.openPool(val.getDbName(), user, password, configuration); }
/** * Creates a new batch insert procedure. It's intended to be used only for a single batch cycle (begin, create..., end) * * @param iDbURL * db connection URL (plocal:/your/db/path) * @param iUserName * db user name (use admin for new db) * @param iPassword * db password (use admin for new db) */ public OGraphBatchInsertBasic(String iDbURL, String iUserName, String iPassword) { this.fullUrl = iDbURL; // The URL we receive here is a full URL, including the database, like memory:mydb or plocal:/path/do/db // To deprecate ODatabaseDocumentTx, we need to separate the "url" from the database name this.dbUrlConnection = OURLHelper.parseNew(fullUrl); this.dbType = dbUrlConnection.getDbType().orElse(ODatabaseType.MEMORY); String dbGroupUrl = dbUrlConnection.getType() + ":" + dbUrlConnection.getPath(); this.userName = iUserName; this.password = iPassword; this.orientDB = new OrientDB(dbGroupUrl, userName, password, OrientDBConfig.defaultConfig()); }
@ConsoleCommand(aliases = { "use database" }, description = "Connect to a database or a remote Server instance", onlineHelp = "Console-Command-Connect") public void connect( @ConsoleParameter(name = "url", description = "The url of the remote server or the database to connect to in the format '<mode>:<path>'") String iURL, @ConsoleParameter(name = "user", description = "User name") String iUserName, @ConsoleParameter(name = "password", description = "User password", optional = true) String iUserPassword) throws IOException { disconnect(); if (iUserPassword == null) { message("Enter password: "); final BufferedReader br = new BufferedReader(new InputStreamReader(this.in)); iUserPassword = br.readLine(); message("\n"); } currentDatabaseUserName = iUserName; currentDatabaseUserPassword = iUserPassword; urlConnection = OURLHelper.parseNew(iURL); orientDB = new OrientDB(urlConnection.getType() + ":" + urlConnection.getPath(), iUserName, iUserPassword, OrientDBConfig.defaultConfig()); if (!"".equals(urlConnection.getDbName())) { // OPEN DB message("\nConnecting to database [" + iURL + "] with user '" + iUserName + "'..."); currentDatabase = (ODatabaseDocumentInternal) orientDB.open(urlConnection.getDbName(), iUserName, iUserPassword); currentDatabaseName = currentDatabase.getName(); } message("OK"); final ODocument distribCfg = getDistributedConfiguration(); if (distribCfg != null) listServers(); }
orientDB = new OrientDB(urlConnection.getType() + ":" + urlConnection.getPath(), currentDatabaseUserName, currentDatabaseUserPassword, config.build());