|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.evanmclean.evlib.sql.PostgresqlUtils
public final class PostgresqlUtils
Utilities specific to the Postgres JDBC database.
Method Summary | |
---|---|
static int |
getCurrVal(String name,
Connection conn)
Read the current value from a sequence. |
static int |
getNextVal(String name,
Connection conn)
Read the next value from a sequence. |
static Array |
intToArray(int[] arr)
Converts an array of integers to an Array object that can be used in a PreparedStatement for Postgresql to set an int4[] column. |
static Array |
intToArray(int[] arr,
String base_type_name)
Converts an array of integers to an Array object that can be used in a PreparedStatement for Postgresql. |
static Array |
stringToArray(String[] arr)
Converts an array of Strings to an Array object that can be used in a PreparedStatement for Postgresql to set an varchar[] column. |
static Array |
stringToArray(String[] arr,
String base_type_name)
Converts an array of Strings to an Array object that can be used in a PreparedStatement for Postgresql. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static int getCurrVal(String name, Connection conn) throws SQLException
name
- The name of the sequence.conn
- The database connection to use.
SQLException
public static int getNextVal(String name, Connection conn) throws SQLException
name
- The name of the sequence.conn
- The database connection to use.
SQLException
public static Array intToArray(int[] arr)
Converts an array of integers to an Array object that can be used in a PreparedStatement for Postgresql to set an int4[] column.
FYI: When reading an int array column from Postgres, you can take the Array object returned by ResultSet.getArray and get the details by the code "(int[]) arrobject.getArray()", or you could use the getResultSet method instead.
NOTE: If you are using a JDBC driver that fully implements java 1.6
Connection objects then use Connection.createArrayOf()
instead
of this function.
arr
- The array of integers.
public static Array intToArray(int[] arr, String base_type_name)
Converts an array of integers to an Array object that can be used in a PreparedStatement for Postgresql.
FYI: When reading an int array column from Postgres, you can take the Array object returned by ResultSet.getArray and get the details by the code "(int[]) arrobject.getArray()", or you could use the getResultSet method instead.
NOTE: If you are using a JDBC driver that fully implements java 1.6
Connection objects then use Connection.createArrayOf()
instead
of this function.
arr
- The array of integers.base_type_name
- The base type of the integer array column you are trying to set.
Will usually be int4, or one of the other integer types
such as integer, int, int2, int8
, smallint or bigint.
public static Array stringToArray(String[] arr)
Converts an array of Strings to an Array object that can be used in a PreparedStatement for Postgresql to set an varchar[] column.
FYI: When reading a varchar array column from Postgres, you can take the Array object returned by ResultSet.getArray and get the details by the code "(String[]) arrobject.getArray() ", or you could use the getResultSet method instead.
NOTE: If you are using a JDBC driver that fully implements java 1.6
Connection objects then use Connection.createArrayOf()
instead
of this function.
arr
- The array of Strings.
public static Array stringToArray(String[] arr, String base_type_name)
Converts an array of Strings to an Array object that can be used in a PreparedStatement for Postgresql.
FYI: When reading a varchar array column from Postgres, you can take the Array object returned by ResultSet.getArray and get the details by the code "(String[]) arrobject.getArray() ", or you could use the getResultSet method instead.
NOTE: If you are using a JDBC driver that fully implements java 1.6
Connection objects then use Connection.createArrayOf()
instead
of this function.
arr
- The array of Strings.base_type_name
- The base type of the String array column you are trying to set. Will
usually be varchar.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |