hi all
i'm writing this code in java using a relational database:
public static int networks_followers_tweets(long id_principal, Twitter t,
int compteur_follower) throws SQLException, InterruptedException {
try {
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);
while (rs.next()) {
long id_follower = rs.getLong(1);
compteur_follower = Get_tweets(id_follower, t,
compteur_follower);
}
} catch (Exception E) {
System.out.println("Message d'erreur network_tweets");
}
return compteur_follower;
}
actually, i want to write the same code but by using a graph database!! i
tried to write the following code but i was totaly lost!! how can i send a
cypher query and then put the result in a variable in order to use it
later?!!
i tried to write the following lines but i'm not really sure:
public static int networks_followers_tweets(long id_principal, Twitter t,
int compteur_follower) throws SQLException, InterruptedException {
try {
URI rs;
String query = "match(a:FOLLOWERS), (b:COMPTES)
where(a.id_compte =" + id_principal + " AND (b.tweets_check=0) AND
(b.id_compte=a.id_follower) return a.id_follower ";
rs = DataBase.sendTransactionalCypherQuery(query);
.......
the DataBase classe is like the following:
public class DataBase {
private static final String SERVER_ROOT_URI =
"http://localhost:7474/db/data/";
public DataBase()
{
}
public static URI 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();
return response.getLocation() ;
}
}
thank you.
--
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.