[英]Connection to Neo4j with jdbc No suitable driver found for jdbc:neo4j:bolt://localhost:7687
I am trying to connect to Neo4j with Talend and I get the error "No suitable driver found for jdbc:neo4j:bolt://localhost:7687" in the subject line.我正在尝试使用 Talend 连接到 Neo4j,但在主题行中出现错误“没有为 jdbc:neo4j:bolt://localhost:7687 找到合适的驱动程序”。 I also get it when I try to connect with a console java application I wrote.当我尝试连接我编写的控制台 java 应用程序时,我也得到了它。 Code below.代码如下。
I am using a jar file I got from https://jar-download.com/artifact-search/neo4j-jdbc Is this the most relighable place to get the jar file from or is there a better jar file out there. I am using a jar file I got from https://jar-download.com/artifact-search/neo4j-jdbc Is this the most relighable place to get the jar file from or is there a better jar file out there.
The java code on the console application compiles without error so the jar file is not corrupt.控制台应用程序上的 java 代码编译没有错误,因此 jar 文件没有损坏。
/**
* Sample connection to Neo4j using jdbc
* compiled with command javac -cp "neo4j-jdbc-4.0.4.jar" ConnectToNeo4j.java
* executed with command java ConnectToNeo4j
* output
java.sql.SQLException: No suitable driver found for jdbc:neo4j:bolt://localhost:7687
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:706)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229)
at ConnectToNeo4j.main(ConnectToNeo4j.java:25)
**/
import java.net.URI;
import java.sql.*;
import org.neo4j.jdbc.*;
import org.neo4j.jdbc.Neo4jDriver;
class ConnectToNeo4j {
public static void main(String[] args) {
String query = "MATCH (n:User) RETURN n.name LIMIT 25";
try {
// My passsword isn't passsword !
Connection con = DriverManager.getConnection("jdbc:neo4j:bolt://localhost:7687", "neo4j", "password");
try (PreparedStatement stmt = con.prepareStatement(query)) {
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
System.out.println("Found: "+rs.getString("u.name"));
}
} catch (Exception e) { e.printStackTrace(); }
} catch (Exception e) { e.printStackTrace(); }
con.close();
} catch (Exception e) { e.printStackTrace(); }
}
}
According to the official documentation,根据官方文档,
For the all-in-one module supporting both Bolt and HTTP, you can simply use:对于同时支持 Bolt 和 HTTP 的一体化模块,您可以简单地使用:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-jdbc-driver</artifactId>
<version>{neo4j-jdbc-version}</version>
</dependency>
Jar if NOT using Maven: https://repo1.maven.org/maven2/org/neo4j/neo4j-jdbc-driver/4.0.4/ Jar if NOT using Maven: https://repo1.maven.org/maven2/org/neo4j/neo4j-jdbc-driver/4.0.4/
If you want only one of the protocols, you can depend on its module:如果您只需要其中一种协议,则可以依赖其模块:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-jdbc-bolt</artifactId>
<version>{neo4j-jdbc-version}</version>
</dependency>
or
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-jdbc-http</artifactId>
<version>{neo4j-jdbc-version}</version>
</dependency>
https://neo4j-contrib.github.io/neo4j-jdbc/ https://neo4j-contrib.github.io/neo4j-jdbc/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.