Java SQL ResultSet Boolean Read getBooleanOrNull(ResultSet rs, String column)

Here you can find the source of getBooleanOrNull(ResultSet rs, String column)

Description

get Boolean Or Null

License

Apache License

Declaration

public static Boolean getBooleanOrNull(ResultSet rs, String column) 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 Boolean getBooleanOrNull(ResultSet rs, String column) throws SQLException {
        boolean bVal = rs.getBoolean(column);
        //hack alert => getBoolean doesn't alway set the wasNull properly http://bugs.mysql.com/bug.php?id=17450
        if (!bVal && rs.wasNull()) {
            return null;
        }/*from   w ww . ja va2 s. c o  m*/
        return new Boolean(bVal);
    }
}

Related

  1. getBoolean(ResultSet rs, String colName)
  2. getBoolean(ResultSet rs, String columnLabel)
  3. getBoolean(ResultSet rs, String columnName)
  4. getBoolean(ResultSet rs, String name)
  5. getBooleanFromResultSet(ResultSet rset, String field)
  6. getBooleanSuppressSQLException(final ResultSet rs, final String columnLabel)
  7. getBooleanValue(ResultSet resultSet, int columnIndex)