Java SQL ResultSet Read getEnum(ResultSet r, String columnName, Class enumType)

Here you can find the source of getEnum(ResultSet r, String columnName, Class enumType)

Description

get Enum

License

Apache License

Declaration

public static <T extends Enum<T>> T getEnum(ResultSet r, String columnName, Class<T> enumType)
            throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.ResultSet;
import java.sql.SQLException;

public class Main {
    public static <T extends Enum<T>> T getEnum(ResultSet r, String columnName, Class<T> enumType)
            throws SQLException {
        String name = r.getString(columnName);
        T val = null;
        if (name != null) {
            try {
                val = Enum.valueOf(enumType, name);
            } catch (java.lang.IllegalArgumentException e) {
                val = null;
            }/*from www .  j a  v  a  2 s . co m*/
        }
        return val;
    }
}

Related

  1. getDbDateValue(ResultSet rs, String columnName)
  2. getDebugData(ResultSet rs)
  3. getDuplicacy(ResultSet rs)
  4. getEntityMap(ResultSet rs, ResultSetMetaData rsmd)
  5. getEnum(Class enumClass, ResultSet rs, String columnName)
  6. getEnum(ResultSet rs, int index, Class type)
  7. getEnumFromResultSet(ResultSet rset, Enum field, T[] enumValues)
  8. getExpectedType(ResultSet resultSet, int columnIndex)
  9. getExplainPlan(ResultSet rs)