Package org.kiwiproject.beta.jdbc
Class KiwiJdbc2
java.lang.Object
org.kiwiproject.beta.jdbc.KiwiJdbc2
JDBC utilities that may (or may not) eventually move into
KiwiJdbc in
kiwi.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T[]Get an ARRAY column as an array of the specified reference type.static <T> List<T>arrayAsList(ResultSet rs, String columnLabel, Class<T> type) Get an ARRAY column as a List of the specified type.static <T> Set<T>arrayAsSet(ResultSet rs, String columnLabel, Class<T> type) Get an ARRAY column as a Set of the specified type.static double[]doubleArray(ResultSet rs, String columnLabel) Get an ARRAY column as a double array.static int[]Get an ARRAY column as an int array.static long[]Get an ARRAY column as a long array.
-
Method Details
-
arrayAsList
public static <T> List<T> arrayAsList(ResultSet rs, String columnLabel, Class<T> type) throws SQLException Get an ARRAY column as a List of the specified type.- Type Parameters:
T- type parameter for the data type- Parameters:
rs- the ResultSetcolumnLabel- the name of the array column in the ResultSettype- the data type- Returns:
- a list containing the values from the array, or an empty list if the database value is null or empty
- Throws:
SQLException- if a database error occurred, e.g. the column doesn't exist- See Also:
-
arrayAsSet
public static <T> Set<T> arrayAsSet(ResultSet rs, String columnLabel, Class<T> type) throws SQLException Get an ARRAY column as a Set of the specified type.- Type Parameters:
T- type parameter for the data type- Parameters:
rs- the ResultSetcolumnLabel- the name of the array column in the ResultSettype- the data type- Returns:
- a set containing the values from the array, or an empty set if the database value is null or empty
- Throws:
SQLException- if a database error occurred, e.g. the column doesn't exist- See Also:
-
doubleArray
Get an ARRAY column as a double array.- Parameters:
rs- the ResultSetcolumnLabel- the name of the array column in the ResultSet- Returns:
- an array of double containing the values from the array, or an empty array if the database value is null or empty
- Throws:
SQLException- if a database error occurred, e.g. the column doesn't exist- See Also:
-
intArray
Get an ARRAY column as an int array.- Parameters:
rs- the ResultSetcolumnLabel- the name of the array column in the ResultSet- Returns:
- an array of int containing the values from the array, or an empty array if the database value is null or empty
- Throws:
SQLException- if a database error occurred, e.g. the column doesn't exist- See Also:
-
longArray
Get an ARRAY column as a long array.- Parameters:
rs- the ResultSetcolumnLabel- the name of the array column in the ResultSet- Returns:
- an array of long containing the values from the array, or an empty array if the database value is null or empty
- Throws:
SQLException- if a database error occurred, e.g. the column doesn't exist- See Also:
-
array
Get an ARRAY column as an array of the specified reference type.If the target type is a primitive double, int, or long, you can specify the wrapper type, or you can instead use one of the specialized primitive methods, e.g.
doubleArray(ResultSet, String). Note that if the array returned byArray.getArray()is of a primitive type such aschar[], then this method must convert that array to an array of wrapper objects which adds additional overhead. In those cases, using the specialized primitive methods will result in better performance (for the supported primitive types).- Type Parameters:
T- type parameter for the data type- Parameters:
rs- the ResultSetcolumnLabel- the name of the array column in the ResultSettype- the data type (must be a reference type)- Returns:
- an array of objects of type T containing the values from the array, or an empty array if the database value is null or empty
- Throws:
SQLException- if a database error occurred, e.g. the column doesn't exist- See Also:
-