使用neo4j-jdbc驱动程序和Java连接neo4j

时间:2016-02-11 07:14:59

标签: java jdbc neo4j

我们尝试使用neo4j-jdbc驱动程序与Java连接neo4j。 我们试图应用的代码。

    try {
        Class.forName("org.neo4j.jdbc.Driver");
        // Conne

        System.out.println("GreetingServiceImpl.greetServer()");

        Connection connect =  DriverManager.getConnection("jdbc:neo4j://localhost:7474/","neo4j","password");

        Statement stmt = connect.createStatement();
        String q = "MATCH (n:Question) RETURN n LIMIT 25";

        ResultSet rs = stmt.executeQuery(q);
        while(rs.next())
        {
            System.out.println(rs.getString("n.QuesID"));
        }
    } catch (Exception e) {
        // TODO: handle exception
        System.out.println("bhalu");
        e.printStackTrace();
    }

我们正在使用neo4j-jdbc jar版本2.3.1。 但现在问题是neo4j-jdbc jar的依赖性。我们无法找到依赖jar并且它不断给出错误。

    Feb 11, 2016 12:17:06 PM org.neo4j.jdbc.Driver createDatabases
     WARNING: Embedded Neo4j support not enabled        
 org/neo4j/graphdb/GraphDatabaseService
    **com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.lang.String com.client.GreetingService.graphtheory() throws java.lang.IllegalArgumentException' threw an unexpected exception:** java.lang.NoClassDefFoundError: org/neo4j/cypherdsl/grammar/Execute
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:389)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:579)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:265)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:305)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
    at    org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:108 6)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:68)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.Server.handle(Server.java:370)
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
    at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:960)
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1021)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/neo4j/cypherdsl/grammar/Execute
    at org.neo4j.jdbc.Driver.<init>(Driver.java:63)
    at org.neo4j.jdbc.Driver.<clinit>(Driver.java:46)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:191)
    at com.server.GreetingServiceImpl.graphtheory(GreetingServiceImpl.java:32)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
    ... 30 more
**Caused by: java.lang.ClassNotFoundException: org.neo4j.cypherdsl.grammar.Execute**
    at java.lang.ClassLoader.findClass(ClassLoader.java:531)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:407)
    at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:383)
    ... 40 more

甚至下载了org / neo4j / cypherdsl / grammar / Execute jar但缺少语法包。 我们想在没有任何maven依赖的java中编写neo4j代码。那么,我们怎样才能找到依赖的罐子?

1 个答案:

答案 0 :(得分:2)

你在构建配置是什么?请尝试neo4j-jdbc的2.3.2

我不明白为什么你不想要依赖,

但是在这里你可以看到构建生成的所有jar包括你的非依赖jar:https://m2.neo4j.org/content/repositories/releases/org/neo4j/neo4j-jdbc/2.3.2/