本文整理汇总了Java中org.neo4j.graphdb.Transaction.close方法的典型用法代码示例。如果您正苦于以下问题:Java Transaction.close方法的具体用法?Java Transaction.close怎么用?Java Transaction.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.graphdb.Transaction
的用法示例。
在下文中一共展示了Transaction.close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: close
import org.neo4j.graphdb.Transaction; //导入方法依赖的package包/类
/**
* Ends and closes a transaction.
*/
public void close() {
CurrentTransaction currentTransaction = transactions.removeLast();
Transaction transaction = currentTransaction.transaction;
if (currentTransaction.success) {
logger.debug("[close] Transaction success");
transaction.success();
}
else {
logger.debug("[close] Transaction failure");
transaction.failure();
}
transaction.close();
logger.debug("[close] Transaction closed");
}
示例2: main
import org.neo4j.graphdb.Transaction; //导入方法依赖的package包/类
public static void main(String[] args) {
CommandLineParser parser = new DefaultParser();
CommandLine cmd = Utils.parseCommandLine(getOptions(), args);
String graphDbPath = cmd.getOptionValue("d", Owl2Neo4jLoader.GRAPH_DB_PATH);
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(new File(graphDbPath));
String query = "MATCH (n) RETURN n ORDER BY ID(n) DESC LIMIT 30;";
Transaction tx = graphDb.beginTx();
try {
Result result = graphDb.execute(query);
while (result.hasNext()) {
Map<String, Object> row = result.next();
for (String key : result.columns()) {
Node node = (Node) row.get(key);
Object name = node.getProperty("name");
System.out.printf("%s = %s; name = %s%n", key, row.get(key), name);
}
}
tx.success();
}
catch (Exception e) {
System.err.println("Exception caught: " + e.getMessage());
e.printStackTrace();
System.exit(ERR_STATUS);
}
finally {
tx.close();
}
System.out.println("Exiting with success...");
System.exit(OK_STATUS);
}