問題背景中立即查詢:Neo4j的插入JDBC,但不能在同一個連接
1.database is neo4j 2.3.1, driver using jdbc;
2.db connection initialized as a class member, default is auto-commit(not changed);
爲了避免重複插入,我插入之前查詢。程序停止後,發現重複。爲什麼?
代碼:
String query = "CREATE (n:LABEL {name:'jack'})";
System.out.println(query);
Statement stmt = dbConnection.createStatement();
stmt.executeUpdate(query);
stmt.close();
我認爲加入「使用準備好的語句」可以很好;) – Supamiu
嗨@Michael Hunger,謝謝。 1.你可以更具體地說「合併」,我知道是「獨特」是一種出路。 2.只是認爲api有點令人困惑,如果你只是插入一條記錄,爲什麼不能在同一個連接上查詢它(我試過,如果每個插入使用一個新的連接,可以查詢它,因此沒有重複) –