当前位置: 首页>>代码示例>>Java>>正文


Java Driver.session方法代码示例

本文整理汇总了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();
}
 
开发者ID:neo4j,项目名称:neo4j-example-auth-plugins,代码行数:23,代码来源:MyAuthPluginIT.java

示例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);
}
 
开发者ID:PlatformLab,项目名称:ldbc-snb-impls,代码行数:27,代码来源:Neo4jDb.java

示例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();
}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:8,代码来源:BoltNeo4jConnector.java


注:本文中的org.neo4j.driver.v1.Driver.session方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。