Class JdbcValueHandler<T>

    • Field Detail

      • module

        public static final String module
    • Constructor Detail

      • JdbcValueHandler

        protected JdbcValueHandler​(int sqlType)
    • Method Detail

      • getInstance

        public static JdbcValueHandler<?> getInstance​(String javaType,
                                                      String sqlType)
        Returns the JdbcValueHandler that corresponds to a field type.
        Parameters:
        javaType - The Java type specified in fieldtype*.xml
        sqlType - The SQL type specified in fieldtype*.xml
        Returns:
        A JdbcValueHandler instance
      • parseSqlType

        protected static String parseSqlType​(String sqlType)
      • castAndSetValue

        protected abstract void castAndSetValue​(PreparedStatement ps,
                                                int parameterIndex,
                                                T obj)
                                         throws SQLException
        Sets a value in a PreparedStatement. The obj argument is converted to the correct data type. Subclasses override this method to cast obj to the correct data type and call the appropriate PreparedStatement.setXxx method.
        Parameters:
        ps -
        parameterIndex -
        obj -
        Throws:
        SQLException
      • getSqlType

        public int getSqlType()
        Returns the SQL type for this handler.
        Returns:
        return the SQL type
        See Also:
        java.sql.Types
      • getValue

        public abstract T getValue​(ResultSet rs,
                                   int columnIndex)
                            throws SQLException
        Returns a value from a ResultSet. The returned object is converted to the Java data type specified in the fieldtype file.
        Parameters:
        rs - the ResultSet object
        columnIndex - the column index
        Returns:
        get value from result set
        Throws:
        SQLException
      • newInstance

        protected abstract JdbcValueHandler<T> newInstance​(int sqlType)
        Returns a new instance of the object - initialized with the specified SQL type.
        Parameters:
        sqlType - the sql type
        Returns:
        returns a new instance
      • getJavaClass

        public abstract Class<T> getJavaClass()
      • setValue

        public void setValue​(PreparedStatement ps,
                             int parameterIndex,
                             T obj)
                      throws SQLException
        Sets a value in a PreparedStatement. The obj argument is converted to the correct data type.
        Parameters:
        ps -
        parameterIndex -
        obj -
        Throws:
        SQLException