Package org.kiwiproject.jdbc.postgres
Class KiwiPostgres
- java.lang.Object
-
- org.kiwiproject.jdbc.postgres.KiwiPostgres
-
public class KiwiPostgres extends Object
Utility functions related to Postgres DBs.
-
-
Field Summary
Fields Modifier and Type Field Description static StringJSON_TYPEThe Postgres "json" type.static StringJSONB_TYPEThe Postgres "jsonb" type.
-
Constructor Summary
Constructors Constructor Description KiwiPostgres()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.postgresql.util.PGobjectnewJSONBObject(String jsonValue)Creates a newPGobjectof typeJSONB_TYPEwith the given JSON value.static org.postgresql.util.PGobjectnewJSONObject(String jsonValue)Creates a newPGobjectof typeJSON_TYPEwith the given JSON value.static org.postgresql.util.PGobjectnewPGobject(String type, String value)Creates a newPGobjectof the specified type and with the given value.
-
-
-
Field Detail
-
JSON_TYPE
public static final String JSON_TYPE
The Postgres "json" type.- See Also:
- Constant Field Values
-
JSONB_TYPE
public static final String JSONB_TYPE
The Postgres "jsonb" type.- See Also:
- Constant Field Values
-
-
Method Detail
-
newJSONObject
public static org.postgresql.util.PGobject newJSONObject(String jsonValue)
Creates a newPGobjectof typeJSON_TYPEwith the given JSON value.- Parameters:
jsonValue- the JSON value as aString- Returns:
- a PGobject of type
jsonwith the given JSON string value
-
newJSONBObject
public static org.postgresql.util.PGobject newJSONBObject(String jsonValue)
Creates a newPGobjectof typeJSONB_TYPEwith the given JSON value.- Parameters:
jsonValue- the JSON value as aString- Returns:
- a PGobject of type
jsonbwith the given JSON string value
-
newPGobject
public static org.postgresql.util.PGobject newPGobject(String type, String value)
Creates a newPGobjectof the specified type and with the given value.- Parameters:
type- the type of object, e.g. json or jsonbvalue- the value as a String- Returns:
- a new
PGobject - Implementation Note:
- We are catching the
SQLExceptionthrown byPGobject.setType(String)and wrapping with anIllegalStateExceptionsince this should never happen, since that specific setter method simply sets an instance field.
-
-