【问题标题】:Error in neo4j connectivity with JavaNeo4j 与 Java 连接时出错
【发布时间】:2014-04-22 10:38:47
【问题描述】:

将上面给出的“依赖项”添加到我的 POM 文件中时,我收到以下错误消息。

依赖关系:

<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>

代码:

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"));
            }
        }

    }
}

错误:

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

【问题讨论】:

    标签: java maven jdbc graph neo4j


    【解决方案1】:

    这是 neo4j-jdbc 中的一个错误。现在已经修复了。看看这个github issue。它完全符合您的情况。

    【讨论】:

      【解决方案2】:

      您不能将 JDBC 与 Neo4J 一起使用。您的代码中对java.sql.* 的任何引用都不正确。

      查看this link 以获取有关如何通过 Java 执行 Cypher 查询的信息。您的代码执行方式在这里是错误的。

      【讨论】:

      猜你喜欢
      • 2018-12-03
      • 1970-01-01
      • 1970-01-01
      • 2021-08-06
      • 1970-01-01
      • 1970-01-01
      • 2017-05-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多