當前位置: 首頁>>代碼示例>>Java>>正文


Java DBAccessFactory類代碼示例

本文整理匯總了Java中iot.jcypher.database.DBAccessFactory的典型用法代碼示例。如果您正苦於以下問題:Java DBAccessFactory類的具體用法?Java DBAccessFactory怎麽用?Java DBAccessFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DBAccessFactory類屬於iot.jcypher.database包,在下文中一共展示了DBAccessFactory類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initDBConnection

import iot.jcypher.database.DBAccessFactory; //導入依賴的package包/類
/**
 * initialize connection to a Neo4j database
 */
private static void initDBConnection() {
	Properties props = new Properties();
	
	// properties for remote access and for embedded access
	// (not needed for in memory access)
	// have a look at the DBProperties interface
	// the appropriate database access class will pick the properties it needs
	props.setProperty(DBProperties.SERVER_ROOT_URI, "http://localhost:7474");
	props.setProperty(DBProperties.DATABASE_DIR, "C:/NEO4J_DBS/01");
	
	/** connect to an in memory database (no properties are required) */
	dbAccess = DBAccessFactory.createDBAccess(DBType.IN_MEMORY, props);
	
	/** connect to remote database via REST (SERVER_ROOT_URI property is needed) */
	//dbAccess = DBAccessFactory.createDBAccess(DBType.REMOTE, props);
	
	/** connect to an embedded database (DATABASE_DIR property is needed) */
	//dbAccess = DBAccessFactory.createDBAccess(DBType.EMBEDDED, props);
}
 
開發者ID:Wolfgang-Schuetzelhofer,項目名稱:jcypher_samples,代碼行數:23,代碼來源:MovieDatabase.java

示例2: before

import iot.jcypher.database.DBAccessFactory; //導入依賴的package包/類
@BeforeClass
public static void before() {
	domainName = "QTEST-DOMAIN";
	Properties props = new Properties();

	// properties for remote access and for embedded access
	// (not needed for in memory access)
	props.setProperty(DBProperties.SERVER_ROOT_URI, "http://localhost:7474");
	props.setProperty(DBProperties.DATABASE_DIR, "C:/NEO4J_DBS/01");

	dbAccess = DBAccessFactory.createDBAccess(DBType.REMOTE, props);
	// dbAccess = DBAccessFactory.createDBAccess(DBType.REMOTE, props,
	// "neo4j", "jcypher");

	List<JcError> errors = dbAccess.clearDatabase();
	assertTrue(errors.isEmpty());
}
 
開發者ID:Wolfgang-Schuetzelhofer,項目名稱:jcypher,代碼行數:18,代碼來源:GregTest.java

示例3: before

import iot.jcypher.database.DBAccessFactory; //導入依賴的package包/類
@BeforeClass
	public static void before() {
		domainName = "QTEST-DOMAIN";
		Properties props = new Properties();

		// properties for remote access and for embedded access
		// (not needed for in memory access)
		props.setProperty(DBProperties.SERVER_ROOT_URI, "http://localhost:7474");
		props.setProperty(DBProperties.DATABASE_DIR, "C:/NEO4J_DBS/01");

		dbAccess = DBAccessFactory.createDBAccess(DBType.REMOTE, props);
		// dbAccess = DBAccessFactory.createDBAccess(DBType.REMOTE, props,
		// "neo4j", "jcypher");

//		List<JcError> errors = dbAccess.clearDatabase();
//		assertTrue(errors.isEmpty());
//
//		// init db
//		Population population = new Population();
//
//		storedDomainObjects = population.createPopulation();
//		
//		IDomainAccess da = DomainAccessFactory.createDomainAccess(dbAccess, domainName);
//		errors = da.store(storedDomainObjects);
//		assertTrue(errors.isEmpty());
	}
 
開發者ID:Wolfgang-Schuetzelhofer,項目名稱:jcypher,代碼行數:27,代碼來源:GC2016Test.java

示例4: testRemoteBasicAuth

import iot.jcypher.database.DBAccessFactory; //導入依賴的package包/類
@Test
public void testRemoteBasicAuth() {
	Properties props = new Properties();
	props.setProperty(DBProperties.SERVER_ROOT_URI, "http://localhost:7474"); // not Bolt
	props.setProperty(DBProperties.DATABASE_DIR, "C:/NEO4J_DBS/01");
	DBType dbType = DBType.REMOTE;
	
	AuthToken auth = AuthTokens.basic("user", "password");
	
	IDBAccess dba = DBAccessFactory.createDBAccess(dbType, props, auth);
	String bauth = ((RemoteDBAccess)dba).getAuth();
	assertEquals("Basic dXNlcjpwYXNzd29yZA==", bauth);
	return;
}
 
開發者ID:Wolfgang-Schuetzelhofer,項目名稱:jcypher,代碼行數:15,代碼來源:DBAuthTest.java

示例5: before

import iot.jcypher.database.DBAccessFactory; //導入依賴的package包/類
@BeforeClass
	public static void before() {
		Settings.TEST_MODE = true;
		domainName = "QTEST-DOMAIN";
		Properties props = new Properties();
		
		// properties for remote access and for embedded access
		// (not needed for in memory access)
		//props.setProperty(DBProperties.SERVER_ROOT_URI, "http://localhost:7474");
		props.setProperty(DBProperties.SERVER_ROOT_URI, "bolt://localhost:7687");
		props.setProperty(DBProperties.DATABASE_DIR, "C:/NEO4J_DBS/02");
		
		dbAccess = DBAccessFactory.createDBAccess(DBType.REMOTE, props);
//		dbAccess = DBAccessFactory.createDBAccess(DBType.REMOTE, props, "neo4j", "jcypher");
		
		// init db
		Population population = new Population();
		storedDomainObjects = population.createPopulation();
		
//		List<JcError> errors = dbAccess.clearDatabase();
//		if (errors.size() > 0) {
//			printErrors(errors);
//			throw new JcResultException(errors);
//		}
//		IDomainAccess da = DomainAccessFactory.createDomainAccess(dbAccess, domainName);
//		errors = da.store(storedDomainObjects);
//		if (errors.size() > 0) {
//			printErrors(errors);
//			throw new JcResultException(errors);
//		}
	}
 
開發者ID:Wolfgang-Schuetzelhofer,項目名稱:jcypher,代碼行數:32,代碼來源:TempTest.java

示例6: executeQuery

import iot.jcypher.database.DBAccessFactory; //導入依賴的package包/類
/**
 * execute a JCypher query against a Neo4j database
 * @param query a JcQuery
 */
public static void executeQuery(JcQuery query) {
	/** initialize access to a Neo4j database.
	      You access Neo4j databases in a uniform way, no matter if you access
	      a remote database, an embedded database, or an in-memory database,
	      the only difference is in the initialization part**/
	
	// properties for remote access and for embedded access
	// (not needed for in memory access)
	// have a look at the DBProperties interface
	// the appropriate database access class will pick the properties it needs
	Properties props = new Properties();
	// for remote db access:
	props.setProperty(DBProperties.SERVER_ROOT_URI, "http://localhost:7474");
	// for embedded db access:
	props.setProperty(DBProperties.DATABASE_DIR, "C:/NEO4J_DBS/01");
	
	/** Note: An IDBAccess instance needs only to be created once for an application instance.
	     It is reused during the whole lifecycle og an application insance */
	
	// Practically you would use only one of the following three db access creation variants
	/** connect to an in memory database (no properties are required) */
	IDBAccess i_dbAccess = DBAccessFactory.createDBAccess(DBType.IN_MEMORY, props);
	
	/** connect to remote database via REST (SERVER_ROOT_URI property is needed) */
	IDBAccess r_dbAccess = DBAccessFactory.createDBAccess(DBType.REMOTE, props);
	
	/** connect to an embedded database (DATABASE_DIR property is needed) */
	IDBAccess e_dbAccess = DBAccessFactory.createDBAccess(DBType.EMBEDDED, props);
	
	/** execute the query against a Neo4j database */
	JcQueryResult result = i_dbAccess.execute(query);
	if (result.hasErrors()) {
		// do something in case of errors
	}
	
	/** You can retrieve a JsonObject containing the query result.
	      Note: With release 1.0.0 you will retrieve a more adequate result model,
	      which will provide for comfortable and easy navigation of the query result.
	 */
	JsonObject jsonResult = result.getJsonResult();
	
	/** Close the Neo4j database connection, releasing all resources.
	     This usually is done once at the lifecycle end of the application instance.
	     If you don't do it, a close is automatically performed when the jvm terminates*/
	// Practically you would only have one IDBAccess instance and hence perform only one call to close()
	i_dbAccess.close();
	r_dbAccess.close();
	e_dbAccess.close();
}
 
開發者ID:Wolfgang-Schuetzelhofer,項目名稱:jcypher_samples,代碼行數:54,代碼來源:Snippet_04.java

示例7: createDBAccess

import iot.jcypher.database.DBAccessFactory; //導入依賴的package包/類
public static IDBAccess createDBAccess() {
	return DBAccessFactory.createDBAccess(dbType, props);
}
 
開發者ID:Wolfgang-Schuetzelhofer,項目名稱:jcypher,代碼行數:4,代碼來源:DBAccessSettings.java


注:本文中的iot.jcypher.database.DBAccessFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。