当前位置: 首页>>代码示例>>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;未经允许,请勿转载。