Re: [GENERAL] Inserting JSON via Java PreparedStatment

2016-03-08 Thread Adrian Klaver
On 03/07/2016 07:15 PM, Curt Huffman wrote: Thanks Rob & David! I got it to work using the following: String qry = "INSERT INTO event " + "(spotid, qid, userid, persid, , " + "evtvalue, evtdt, evtjson) " + "VALUES(?,?,?,?,?,?,?,?,?,?,to_json(?::json));"; and pStmt.setString

Re: [GENERAL] Inserting JSON via Java PreparedStatment

2016-03-08 Thread Curt Huffman
Thanks Rob & David! I got it to work using the following: String qry = "INSERT INTO event " + "(spotid, qid, userid, persid, , " + "evtvalue, evtdt, evtjson) " + "VALUES(?,?,?,?,?,?,?,?,?,?,to_json(?::json));"; and pStmt.setString (11,dtlRec.toString()); (another suggestion was to use:

Re: [GENERAL] Inserting JSON via Java PreparedStatment

2016-03-07 Thread David G. Johnston
On Mon, Mar 7, 2016 at 8:15 PM, Curt Huffman wrote: > Thanks Rob & David! > > I got it to work using the following: > > > String qry = "INSERT INTO event " > + "(spotid, qid, userid, persid, , " > + "evtvalue, evtdt, evtjson) " > +

Re: [GENERAL] Inserting JSON via Java PreparedStatment

2016-03-07 Thread rob stone
On Mon, 2016-03-07 at 09:32 -0700, David G. Johnston wrote: > > >  > > Hint: You will need to rewrite or cast the expression. > > > Take the hint, literally.  You never did show the SQL but usually the > least complex way to solve this is to indeed transfer the data as a > string/text and then

Re: [GENERAL] Inserting JSON via Java PreparedStatment

2016-03-07 Thread Adrian Klaver
On 03/07/2016 05:25 AM, Curt Huffman wrote: Hello! I’m struggling to insert a JSON object into my postgres v9.4 DB. I have defined the column called "evtjson" as type json. (not jsonb) I am trying to use a prepared statement in Java (jdk1.8) to insert a Json object (built using JEE javax.json

Re: [GENERAL] Inserting JSON via Java PreparedStatment

2016-03-07 Thread David G. Johnston
> pStmt.setString(11, dtlRec.toString()); > pStmt.setObject(11, dtlRec.toString()); > > Which produce a different error: > > Event JSON: {"New MbrID":29} > > SQLException: ERROR: column "evtjson" is of type json but expression is of > type character varying > > Hint: You will need to rewrite or

[GENERAL] Inserting JSON via Java PreparedStatment

2016-03-07 Thread Curt Huffman
Hello! I’m struggling to insert a JSON object into my postgres v9.4 DB. I have defined the column called "evtjson" as type json. (not jsonb) I am trying to use a prepared statement in Java (jdk1.8) to insert a Json object (built using JEE javax.json libraries) into the column, but I keep running