Created
March 16, 2015 18:38
-
-
Save paradoja/2166f4148c33d5c71815 to your computer and use it in GitHub Desktop.
Test Java Neo4j JDBC Rest connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gdbTest; | |
import org.neo4j.jdbc.Driver; | |
import org.neo4j.jdbc.Neo4jConnection; | |
import java.sql.ResultSet; | |
import java.sql.SQLException; | |
import java.sql.Statement; | |
import java.util.Properties; | |
/** | |
* Testing JDBC Neo4j with GrapheneDB | |
* | |
*/ | |
public class App { | |
public static void main(String[] args) { | |
final Driver driver = new Driver(); | |
final String hostPort = "HOST"; | |
final Properties props = new Properties(); | |
props.put("user", "USER"); | |
props.put("password", "TOKEN"); | |
try { | |
Neo4jConnection conn = driver.connect("jdbc:neo4j://"+ hostPort, props); | |
Statement stmt = conn.createStatement(); | |
ResultSet rs = stmt.executeQuery("MATCH (n:User) RETURN n.name"); // random cypher query | |
while (rs.next()) { | |
System.out.println(rs.getString("n.name")); | |
} | |
} catch (SQLException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependencies> | |
<dependency> | |
<groupId>org.neo4j</groupId> | |
<artifactId>neo4j-jdbc</artifactId> | |
<version>2.1.4</version> | |
</dependency> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>3.8.1</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<repositories> | |
<repository> | |
<id>neo4j-public</id> | |
<url>http://m2.neo4j.org/content/groups/public</url> | |
<releases> | |
<enabled>true</enabled> | |
<checksumPolicy>warn</checksumPolicy> | |
</releases> | |
</repository> | |
</repositories> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment