Class KiwiJdbc2


  • @Beta
    public final class KiwiJdbc2
    extends Object
    JDBC utilities that may (or may not) eventually move into KiwiJdbc in kiwi.
    • Method Detail

      • 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:
        Array, ResultSet.getArray(String)
      • 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:
        Array, ResultSet.getArray(String)
      • 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:
        Array, ResultSet.getArray(String)
      • 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:
        Array, ResultSet.getArray(String)
      • 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, ResultSet.getArray(String)
      • array

        public static <T> T[] array​(ResultSet rs,
                                    String columnLabel,
                                    Class<T> type)
                             throws SQLException
        Get an ARRAY column as an array of th 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 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:
        Array, ResultSet.getArray(String)