Tried again with this code but still getting exception!
public void doInsertNode(Map<String, Object> map) {
Connection connection = null;
IDataSource dataSource =
DataSourceFactory.getInstance().getDataSource();
// Map<String, Object> mappa = new HashMap<String, Object>();
try {
connection = dataSource.getConnection();
// mappa.put("map", map);
PreparedStatement preparedStatement =
connection.prepareStatement("create (n{1})");
preparedStatement.setObject(1, map);
preparedStatement.executeUpdate();
} 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);
}
}
Am i doing something wrong? this is a complete error with params to pass.
Is a json converted in hashmap.
Grave: null
java.sql.SQLException: Error executing query create (n{1})
with params {1={filter_level=medium,
retweeted_status=net.sf.ezmorph.bean.MorphDynaBean@5da25541[
{contributors=null, text=Massimiliano e Raffaele #alajmo a #IGmi14! A
lezione con @WineMktg! #foodies, geo=null, retweeted=false,
in_reply_to_screen_name=null, truncated=false, lang=it,
entities=net.sf.ezmorph.bean.MorphDynaBean@4c8b4e6d[
{symbols=[], urls=[],
hashtags=[net.sf.ezmorph.bean.MorphDynaBean@4dc9fd5d[
{text=alajmo, indices=[24, 31]}
], net.sf.ezmorph.bean.MorphDynaBean@8190c91[
{text=IGmi14, indices=[34, 41]}
], net.sf.ezmorph.bean.MorphDynaBean@248807be[
{text=foodies, indices=[68, 76]}
]], user_mentions=[net.sf.ezmorph.bean.MorphDynaBean@5eb45dae[
{id=1843767630, name=Marco Rossi, indices=[57, 66], screen_name=WineMktg,
id_str=1843767630}
]]}
], in_reply_to_status_id_str=null, id=432898472346652672, source=<a
href="http://twitter.com/download/android" rel="nofollow">Twitter for
Android</a>, in_reply_to_user_id_str=null, favorited=false,
in_reply_to_status_id=null, retweet_count=1, created_at=Mon Feb 10 15:26:53
+0000 2014, in_reply_to_user_id=null, favorite_count=0,
id_str=432898472346652672, place=null,
user=net.sf.ezmorph.bean.MorphDynaBean@13727b15[
{location=Roma, default_profile=false, profile_background_tile=true,
statuses_count=5903, lang=it, profile_link_color=FF0000,
profile_banner_url=https://pbs.twimg.com/profile_banners/1364757504/1390854107,
id=1364757504, following=null, protected=false, favourites_count=3372,
profile_text_color=0C3E53, description=.....ingegnerA, romana, #foodie e
#viaggiatrice per passione! neo #foodblogger su
http://robysushi.wordpress.com e @bigodinoit, verified=false,
contributors_enabled=false, profile_sidebar_border_color=FFFFFF,
name=RobySushi, profile_background_color=BADFCD, created_at=Fri Apr 19
16:03:53 +0000 2013, is_translation_enabled=false,
default_profile_image=false, followers_count=883,
profile_image_url_https=https://pbs.twimg.com/profile_images/378800000010050493/e74b09df91da2438a12786b65d72dc95_normal.jpeg,
geo_enabled=true,
profile_background_image_url=http://pbs.twimg.com/profile_background_images/378800000099002891/93ebfaa3c19f3ecdbe6dec7ce5bfa823.jpeg,
profile_background_image_url_https=https://pbs.twimg.com/profile_background_images/378800000099002891/93ebfaa3c19f3ecdbe6dec7ce5bfa823.jpeg,
follow_request_sent=null, url=http://robysushi.wordpress.com/,
utc_offset=7200, time_zone=Athens, notifications=null,
profile_use_background_image=true, friends_count=1546,
profile_sidebar_fill_color=FFF7CC, screen_name=robcastrichella,
id_str=1364757504,
profile_image_url=http://pbs.twimg.com/profile_images/378800000010050493/e74b09df91da2438a12786b65d72dc95_normal.jpeg,
listed_count=14, is_translator=false}
], coordinates=null}
], contributors=null, text=RT @robcastrichella: Massimiliano e Raffaele
#alajmo a #IGmi14! A lezione con @WineMktg! #foodies, geo=null,
retweeted=false, in_reply_to_screen_name=null, truncated=false, lang=it,
entities=net.sf.ezmorph.bean.MorphDynaBean@40eea9ac[
{symbols=[], urls=[],
hashtags=[net.sf.ezmorph.bean.MorphDynaBean@74c57c81[
{text=alajmo, indices=[45, 52]}
], net.sf.ezmorph.bean.MorphDynaBean@5171350b[
{text=IGmi14, indices=[55, 62]}
], net.sf.ezmorph.bean.MorphDynaBean@5f518ef2[
{text=foodies, indices=[89, 97]}
]], user_mentions=[net.sf.ezmorph.bean.MorphDynaBean@637fe2c1[
{id=1364757504, name=RobySushi, indices=[3, 19],
screen_name=robcastrichella, id_str=1364757504}
], net.sf.ezmorph.bean.MorphDynaBean@61001fef[
{id=1843767630, name=Marco Rossi, indices=[78, 87], screen_name=WineMktg,
id_str=1843767630}
]]}
], in_reply_to_status_id_str=null, id=432901867119841280,
in_reply_to_user_id_str=null, source=<a
href="http://twitter.com/download/iphone" rel="nofollow">Twitter for
iPhone</a>, favorited=false, in_reply_to_status_id=null,
in_reply_to_user_id=null, created_at=Mon Feb 10 15:40:22 +0000 2014,
retweet_count=0, favorite_count=0, id_str=432901867119841280, place=null,
user=net.sf.ezmorph.bean.MorphDynaBean@4f30b5a9[
{location=, default_profile=false, profile_background_tile=true,
statuses_count=1791, lang=en, profile_link_color=0084B4,
profile_banner_url=https://pbs.twimg.com/profile_banners/1843767630/1378725930,
id=1843767630, following=null, protected=false, favourites_count=3033,
profile_text_color=333333, description=#Mktg #Green & Creativo, #Wine &
#FoodGeek cinema Koreano&Jappo #Seriesaholic e musica #Indie from dusk
'till dawn. What a big mess...That's me! #readchetipassa, verified=false,
contributors_enabled=false, profile_sidebar_border_color=FFFFFF, name=Marco
Rossi, profile_background_color=C0DEED, created_at=Mon Sep 09 10:48:03
+0000 2013, is_translation_enabled=false, default_profile_image=false,
followers_count=528,
profile_image_url_https=https://pbs.twimg.com/profile_images/378800000433658717/400ed733754f3ffe8d09f20aac5c4225_normal.jpeg,
geo_enabled=true,
profile_background_image_url=http://pbs.twimg.com/profile_background_images/378800000070438182/244a66fb9bb88ebc4fa046b27a495e6a.jpeg,
profile_background_image_url_https=https://pbs.twimg.com/profile_background_images/378800000070438182/244a66fb9bb88ebc4fa046b27a495e6a.jpeg,
follow_request_sent=null, url=http://www.pomaio.it, utc_offset=null,
time_zone=null, notifications=null, profile_use_background_image=true,
friends_count=1020, profile_sidebar_fill_color=DDEEF6,
screen_name=WineMktg, id_str=1843767630,
profile_image_url=http://pbs.twimg.com/profile_images/378800000433658717/400ed733754f3ffe8d09f20aac5c4225_normal.jpeg,
listed_count=11, is_translator=false}
], coordinates=null}}
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:96)
at
org.pipe.java.web.netnografica.controllo.MyTwitterListener.onStatus(MyTwitterListener.java:52)
null
errors = [{code=Neo.ClientError.Statement.ParameterMissing,
message=Expected a parameter named 1}]
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
Thank you.
Il giorno lunedì 10 febbraio 2014 14:00:31 UTC+1, Michael Hunger ha scritto:
>
> I fixed it, added a test and pushed the update to github and an binary
> update to
> http://dist.neo4j.org/neo4j-jdbc/neo4j-jdbc-2.0.1-SNAPSHOT-jar-with-dependencies.jar
>
>
> please try it out and report back if it worked.
>
> Michael
>
> Am 10.02.2014 um 13:40 schrieb Licio Mazzeo <[email protected]<javascript:>>:
>
>
> > Ok, thank you Michael :)
> >
> > Licio.
> >
> > Il giorno lunedì 10 febbraio 2014 13:29:19 UTC+1, Michael Hunger ha
> scritto:
> > Ok, sorry, my fault. I thought I correctly serialized maps in the jdbc
> driver.
> >
> > So for now you'll have to go with individual fields. Sorry for that.
> >
> > I fix it soon.
> >
> > Michael
> >
> > Am 10.02.2014 um 13:02 schrieb Licio Mazzeo <[email protected]>:
> >
> >> Yes, i tried to do so .. but i got an exception..
> >>
> >> org.neo4j.jdbc.Neo4jConnection - Executing query: CREATE ({1})
> >> with params {1={filter_level=medium ... } //the json
> >> at
> org.neo4j.jdbc.Neo4jConnection.executeQuery(Neo4jConnection.java:255)
> >> at
> org.neo4j.jdbc.Neo4jPreparedStatement.executeQuery(Neo4jPreparedStatement.java:48)
>
>
> >> at
> org.pipe.java.web.netnografica.persistenza.graphdb.DAONodo.doInsertNodo(DAONodo.java:98)
>
>
> >> at
> org.pipe.java.web.netnografica.controllo.MyTwitterListener.onStatus(MyTwitterListener.java:52)
>
>
> >> 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
> >>
> >>
> >> This is my method
> >>
> >> public void doInsertNode(Map<String, Object> map) {
> >> Connection connection = null;
> >> IDataSource dataSource =
> DataSourceFactory.getInstance().getDataSource();
> >> try {
> >> connection = dataSource.getConnection();
> >> PreparedStatement preparedStatement =
> connection.prepareStatement("CREATE ({1})");
> >> preparedStatement.setObject(1, map);
> >> preparedStatement.executeQuery();
> >> } 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);
> >> }
> >> }
> >>
> >> Thanks :)
> >>
> >> Il giorno domenica 9 febbraio 2014 19:27:00 UTC+1, Michael Hunger ha
> scritto:
> >> Jdbc only allows for numeric parameters (starting at 1).
> >>
> >>> Map<String, Object> params = new HashMap<String, Object>();
> >>> params.put( "name", "a Name" );
> >>> Now i'm thinking to do this
> >>> connection = dataSource.getConnection();
> >>> PreparedStatement preparedStatement =
> connection.prepareStatement("CREATE ({1})");
> >>> preparedStatement.setObject(1, params);
> >>> preparedStatement.executeQuery();
> >>
> >> Michael
> >>
> >> Am 09.02.2014 um 17:24 schrieb Licio Mazzeo <[email protected]>:
> >>
> >>> 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.
> >>
> >>
> >> --
> >> 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.
> >
> >
> > --
> > 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] <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
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.