[英]Error in neo4j connectivity with Java
On adding the "dependencies" given above to my POM file I got the following error message. 在将上面给出的“依赖项”添加到我的POM文件中时,出现以下错误消息。
Dependencies: 依存关系:
<dependencies>
...
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-jdbc</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>neo4j-maven</id>
<name>neo4j maven</name>
<url>http://m2.neo4j.org</url>
</repository>
</repositories>
Code : 代码:
package javaapplication2;
import java.sql.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.swing.JOptionPane;
/**
* @author Shanal
*/
public class neo {
public static void main(String[] args) throws Exception {
// Make sure Neo4j Driver is registered
Class.forName("org.neo4j.jdbc.Driver");
// Connect
Connection con = DriverManager.getConnection("jdbc:neo4j://localhost:7474/");
// Querying
try (Statement stmt = con.createStatement()) {
ResultSet rs = stmt.executeQuery("MATCH (n:User) RETURN n.name");
while (rs.next()) {
System.out.println(rs.getString("n.name"));
}
}
}
}
Error : 错误:
run:
Starting the Apache HTTP client
Executing query: MATCH (n:User) RETURN n.name
with params {}
Starting the Apache HTTP client
errors-next-token = FIELD_NAME
null
Unexpected token END_ARRAY
This was a bug in neo4j-jdbc. 这是neo4j-jdbc中的错误。 It has been fixed now.
现在已经修复。 Take a look at this github issue .
看看这个github问题 。 It matches exactly your case.
它完全符合您的情况。
You can't use JDBC with Neo4J. 您不能将JDBC与Neo4J一起使用。 Any references in your code to
java.sql.*
are incorrect. 您的代码中对
java.sql.*
任何引用都不正确。
Have a look at this link for information on how to execute Cypher queries via Java. 请查看此链接,以获取有关如何通过Java执行Cypher查询的信息。 The way your code is going about it is in the wrong direction here.
您的代码执行的方式在这里是错误的方向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.