Use the Neo4j JDBC driver, see:

https://github.com/neo4j-contrib/neo4j-jdbc/#minimum-viable-snippet

> Am 03.02.2015 um 10:01 schrieb FERHAT Ilyes <[email protected]>:
> 
> hi all 
> i want to send a query from java to retrieve data from my graph database to 
> use it later in my program (for example: send a query to check if a node 
> exists or not, if doesn't exist then create a node. if exists. then do 
> nothing).
> the following code if for a relational database: 
> 
> in the class DataBase, i have added a methode Select :
> 
>  public static  ResultSet Select(String query) throws SQLException
>     {
>          ResultSet rs;
>          conn = DriverManager.getConnection(DB_URL,USER,PASSWORD);
>          stmt = conn.createStatement();
>          rs = stmt.executeQuery(query);                
>          return(rs);
>             
>     }
> 
> in the main classe: 
> 
>  ResultSet rs;
>             String sql = "Select id_follower from follower a , comptes b 
> where a.id_compte =" + id_principal + "and b.tweets_check=0 and 
> b.id_compte=a.id_follower ";
>              rs = DataBase.Select(sql);
> 
> the DadaBase.Select(sql) returns the data and put it in rs. i want to do the 
> sam thing but using a graph database, i have the following code but it has a 
> void type, it doesn't return anything! how should i modify that to make it 
> like the above one please:
> 
> public static void sendTransactionalCypherQuery(String query) {
>         // START SNIPPET: queryAllNodes
>         final String txUri = SERVER_ROOT_URI + "transaction/commit";
>         WebResource resource = Client.create().resource( txUri );
> 
>         String payload = "{\"statements\" : [ {\"statement\" : \"" +query + 
> "\"} ]}";
>         ClientResponse response = resource
>                 .accept( MediaType.APPLICATION_JSON )
>                 .type( MediaType.APPLICATION_JSON )
>                 .entity( payload )
>                 .post( ClientResponse.class );
>         
>         System.out.println( String.format(
>                 "POST [%s] to [%s], status code [%d], returned data: "
>                         + System.getProperty( "line.separator" ) + "%s",
>                 payload, txUri, response.getStatus(),
>                 response.getEntity( String.class ) ) );
>         
>         response.close();
>         // END SNIPPET: queryAllNodes
>     }
> 
> thanks all. 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to