Java SQL ResultSet Read getEnum(ResultSet rs, int index, Class type)

Here you can find the source of getEnum(ResultSet rs, int index, Class type)

Description

get Enum

License

Open Source License

Declaration

public static <T extends Enum<T>> T getEnum(ResultSet rs, int index, Class<T> type) 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 <T extends Enum<T>> T getEnum(ResultSet rs, int index, Class<T> type) throws SQLException {
        int value = rs.getInt(index);
        for (T t : type.getEnumConstants()) {
            if (t.ordinal() == value)
                return t;
        }/*from w  w w.  j ava 2 s.  c  o m*/
        return null;
    }
}

Related

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