Class KiwiPostgres

java.lang.Object
org.kiwiproject.jdbc.postgres.KiwiPostgres

public final class KiwiPostgres extends Object
Utility functions related to Postgres DBs.
  • Field Details

  • Method Details

    • 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.