Class KiwiPostgres


  • public class KiwiPostgres
    extends Object
    Utility functions related to Postgres DBs.
    • Constructor Detail

      • KiwiPostgres

        public KiwiPostgres()
    • Method Detail

      • newJSONObject

        public static org.postgresql.util.PGobject newJSONObject​(String jsonValue)
        Creates a new PGobject of type JSON_TYPE with the given JSON value.
        Parameters:
        jsonValue - the JSON value as a String
        Returns:
        a PGobject of type json with the given JSON string value
      • newJSONBObject

        public static org.postgresql.util.PGobject newJSONBObject​(String jsonValue)
        Creates a new PGobject of type JSONB_TYPE with the given JSON value.
        Parameters:
        jsonValue - the JSON value as a String
        Returns:
        a PGobject of type jsonb with the given JSON string value
      • newPGobject

        public static org.postgresql.util.PGobject newPGobject​(String type,
                                                               String value)
        Creates a new PGobject of the specified type and with the given value.
        Parameters:
        type - the type of object, e.g. json or jsonb
        value - the value as a String
        Returns:
        a new PGobject
        Implementation Note:
        We are catching the SQLException thrown by PGobject.setType(String) and wrapping with an IllegalStateException since this should never happen, since that specific setter method simply sets an instance field.