Class KiwiJdbc2

java.lang.Object
org.kiwiproject.beta.jdbc.KiwiJdbc2

@Beta public final class KiwiJdbc2 extends Object
JDBC utilities that may (or may not) eventually move into KiwiJdbc in kiwi.
  • 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 ResultSet
      columnLabel - the name of the array column in the ResultSet
      type - 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 ResultSet
      columnLabel - the name of the array column in the ResultSet
      type - 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

      public static double[] doubleArray(ResultSet rs, String columnLabel) throws SQLException
      Get an ARRAY column as a double array.
      Parameters:
      rs - the ResultSet
      columnLabel - 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

      public static int[] intArray(ResultSet rs, String columnLabel) throws SQLException
      Get an ARRAY column as an int array.
      Parameters:
      rs - the ResultSet
      columnLabel - 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

      public static long[] longArray(ResultSet rs, String columnLabel) throws SQLException
      Get an ARRAY column as a long array.
      Parameters:
      rs - the ResultSet
      columnLabel - 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

      public static <T> T[] array(ResultSet rs, String columnLabel, Class<T> type) throws SQLException
      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 by Array.getArray() is of a primitive type such as char[], 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 ResultSet
      columnLabel - the name of the array column in the ResultSet
      type - the data type (must be a reference type)
      Returns:
      an array of objects having 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: