Well .. I imported the project and linked in maven.. Tried this but
nothing..
Neo4jConnection connection = null;
IDataSource dataSource =
DataSourceFactory.getInstance().getDataSource();
/* for (Map.Entry<String, Object> entry : map.entrySet()) {
String string = entry.getKey();
Object object = entry.getValue();
logger.info("'" + string +"': " +"'" + object +"'");
*/ }
Map<String, Object> mappa = new HashMap<String, Object>();
try {
connection = (Neo4jConnection) dataSource.getConnection();
mappa.put("nome", "pippo");
PreparedStatement preparedStatement =
connection.prepareStatement("create (n:user{1})");
preparedStatement.setObject(1, mappa);
preparedStatement.executeUpdate();
// String query = "create (n{map})";
// connection.executeQuery(query, mappa);
} catch (DAOException ex) {
Logger.getLogger(DAONodo.class.getName()).log(Level.SEVERE,
null, ex);
} catch (SQLException ex) {
Logger.getLogger(DAONodo.class.getName()).log(Level.SEVERE,
null, ex);
}
Still got
2014-02-10 18:12:08,677 INFO org.neo4j.jdbc.Neo4jConnection - Executing
query: create (n:user{1})
with params {1={nome=pippo}}
errors-next-token = FIELD_NAME
null
errors = [{code=Neo.ClientError.Statement.ParameterMissing,
message=Expected a parameter named 1}]
feb 10, 2014 6:12:08 PM
org.pipe.java.web.netnografica.persistenza.graphdb.DAONodo doInsertNodo
Grave: null
java.sql.SQLException: Error executing query create (n:user{1})
with params {1={nome=pippo}}
at org.neo4j.jdbc.Neo4jConnection.executeQuery(Neo4jConnection.java:255)
at
org.neo4j.jdbc.Neo4jPreparedStatement.executeUpdate(Neo4jPreparedStatement.java:62)
at
org.pipe.java.web.netnografica.persistenza.graphdb.DAONodo.doInsertNodo(DAONodo.java:102)
at
org.pipe.java.web.netnografica.controllo.MyTwitterListener.onStatus(MyTwitterListener.java:58)
at twitter4j.StatusStreamImpl.onStatus(StatusStreamImpl.java:75)
at twitter4j.StatusStreamBase$1.run(StatusStreamBase.java:114)
at twitter4j.internal.async.ExecuteThread.run(DispatcherImpl.java:116)
Caused by: java.lang.RuntimeException: Error executing cypher statement(s)
[{code=Neo.ClientError.Statement.ParameterMissing, message=Expected a
parameter named 1}]
at
org.neo4j.jdbc.rest.StreamingParser.handleErrors(StreamingParser.java:229)
at org.neo4j.jdbc.rest.StreamingParser.skipTo(StreamingParser.java:206)
at org.neo4j.jdbc.rest.StreamingParser.nextResult(StreamingParser.java:95)
at org.neo4j.jdbc.rest.StreamingParser$2.hasNext(StreamingParser.java:170)
at
org.neo4j.jdbc.rest.TransactionalQueryExecutor.executeQuery(TransactionalQueryExecutor.java:163)
at org.neo4j.jdbc.Neo4jConnection.executeQuery(Neo4jConnection.java:250)
... 6 more
Pretty sure i'm doing something wrong.. but i don't know what -.-
Thank you again!
Il giorno domenica 9 febbraio 2014 17:24:39 UTC+1, Licio Mazzeo ha scritto:
>
> Hi all, i have a question. How can i create a node passing the json or a
> map into prepared statement just like the rest api docs?
>
> Map<String, Object> params = new HashMap<String, Object>();
> params.put( "props", props );
> String query = "CREATE ({props})";
> engine.execute( query, params );
>
> Now i'm thinking to do this
> connection = dataSource.getConnection();
> PreparedStatement preparedStatement = connection.prepareStatement("CREATE
> (n{?}");
> preparedStatement.setObject(0, map);
> preparedStatement.executeQuery();
>
> but its sure wrong..
>
> 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/groups/opt_out.