When I run this SQL query in pgAdmin it works. But not in the Java code, the SQL string looks like this:
UPDATE table SET col = jsonb_set(col,'{"some_key"}', '{"items":["banana"]}' ::jsonb)
In the debugger I can see that exactly same query is generated with this java code but it throws error:
final String sql = "UPDATE table SET col = jsonb_set(col,?, ? ::jsonb) ";
try {
connection = defaultDatabase.getConnection();
stmt = connection.prepareStatement(sql);
stmt.setString(1, keyName);
stmt.setString(2, keyValue);
stmt.execute();
} catch (SQLException e) {
logger.error("error:", e.getMessage());
} finally {
DbUtils.closeQuietly(connection);
DbUtils.closeQuietly(stmt);
}
Error:
ERROR: function jsonb_set(jsonb, character varying, jsonb) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 40