本文整理汇总了Java中org.neo4j.driver.v1.Driver.session方法的典型用法代码示例。如果您正苦于以下问题:Java Driver.session方法的具体用法?Java Driver.session怎么用?Java Driver.session使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.driver.v1.Driver
的用法示例。
在下文中一共展示了Driver.session方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldAuthenticateAndAuthorizeKalleMoraeusAsAdmin
import org.neo4j.driver.v1.Driver; //导入方法依赖的package包/类
@Test
public void shouldAuthenticateAndAuthorizeKalleMoraeusAsAdmin() throws Exception
{
Driver driver = GraphDatabase.driver( server.boltURI(), AuthTokens.basic( "moraeus", "suearom" ) );
Session session = driver.session();
session.run( "CREATE (a:Person {name:'Kalle Moraeus', title:'Riksspelman'})" );
StatementResult result =
session.run( "MATCH (a:Person) WHERE a.name = 'Kalle Moraeus' RETURN a.name AS name, a.title AS title" );
assertTrue( result.hasNext() );
while ( result.hasNext() )
{
Record record = result.next();
assertThat( record.get( "name" ).asString(), equalTo( "Kalle Moraeus" ) );
assertThat( record.get( "title" ).asString(), equalTo( "Riksspelman" ) );
System.out.println( record.get( "title" ).asString() + " " + record.get( "name" ).asString() );
}
session.close();
driver.close();
}
示例2: executeOperation
import org.neo4j.driver.v1.Driver; //导入方法依赖的package包/类
@Override
public void executeOperation(LdbcUpdate3AddCommentLike operation,
DbConnectionState dbConnectionState,
ResultReporter reporter) throws DbException {
Driver driver = ((Neo4jDbConnectionState) dbConnectionState).getDriver();
try (Session session = driver.session(AccessMode.WRITE)) {
try (Transaction tx = session.beginTransaction()) {
String statement =
" MATCH (p:Person {id:{personId}}),"
+ " (m:Comment {id:{commentId}})"
+ " CREATE (p)-[:LIKES {creationDate:{creationDate}}]->(m)";
Value parameters = parameters(
"personId", String.valueOf(operation.personId()),
"commentId", String.valueOf(operation.commentId()),
"creationDate", operation.creationDate().getTime());
tx.run(statement, parameters);
tx.success();
tx.close();
}
}
reporter.report(0, LdbcNoResult.INSTANCE, operation);
}
示例3: init
import org.neo4j.driver.v1.Driver; //导入方法依赖的package包/类
public void init(Neo4jSyncConfManager configuration)
{
log.info("configure neo4j connection to {}, user {}",configuration.getNeo4jHostname(),configuration.getNeo4jUsername());
Driver driver = GraphDatabase.driver("bolt://"+configuration.getNeo4jHostname(),
AuthTokens.basic(configuration.getNeo4jUsername(), configuration.getNeo4jPassword()));
session = driver.session();
}