Vert.x JDBC - Postgres - Insert JSON into row?

462 views
Skip to first unread message

plom...@datawire.io

unread,
Nov 10, 2016, 11:46:02 AM11/10/16
to vert.x
Recent version of Postgres 9 have support for putting JSON into rows in a table. Is there any way to do this with the current Vert.x JDBC library using a prepared statement? I've tried passing a JsonObject and stringified blob to the updateWithParams call but I get this error:


2016-11-10 16:23:16.621 INFO [vert.x-worker-thread-0] i.d.m.v.r.PostgresNodesTrackerVerticle - [3ad55c2b-ea66-42b3-b245-6698b3c18e5f, http://localhost:52689/api, true, child, 2016-11-10T16:24:16.619Z, 2016-11-10T16:23:16.620Z, 7smjylu8w1, 1.0.0, {"datawire_nodeId":"3ad55c2b-ea66-42b3-b245-6698b3c18e5f"}, foo]
2016-11-10 16:23:16.631 DEBUG [vert.x-worker-thread-4] c.m.v.c.i.NewPooledConnection - com.mchange.v2.c3p0.impl.NewPooledConnection@6cd9ae7d handling a throwable.
org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of io.vertx.core.json.JsonObject. Use setObject() with an explicit Types value to specify the type to use.

Only workaround seems to be to call to_json in the actual SQL with.


Paulo Lopes

unread,
Nov 10, 2016, 2:13:06 PM11/10/16
to vert.x

plom...@datawire.io

unread,
Nov 17, 2016, 7:47:47 PM11/17/16
to vert.x
I had not! Thank you! Perhaps should be moved to the documentation? 
Reply all
Reply to author
Forward
0 new messages