本文整理匯總了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);
}