Java SQL ResultSet Read getEnum(Class enumClass, ResultSet rs, String columnName)

Here you can find the source of getEnum(Class enumClass, ResultSet rs, String columnName)

Description

get Enum

License

Open Source License

Declaration

public static <E extends Enum<E>> E getEnum(Class<E> enumClass, ResultSet rs, String columnName)
            throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static <E extends Enum<E>> E getEnum(Class<E> enumClass, ResultSet rs, String columnName)
            throws SQLException {
        String value = rs.getString(columnName);
        if (value == null) {
            return null;
        } else {/*from ww w.  j  av  a 2s  . c  o m*/
            return Enum.valueOf(enumClass, value);
        }
    }
}

Related

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