Example usage for java.sql ResultSet wasNull

List of usage examples for java.sql ResultSet wasNull

Introduction

In this page you can find the example usage for java.sql ResultSet wasNull.

Prototype

boolean wasNull() throws SQLException;

Source Link

Document

Reports whether the last column read had a value of SQL NULL.

Usage

From source file:gsn.http.restapi.RequestHandler.java

private Double getDouble(ResultSet rs, String fieldName) throws SQLException {
    Double d = rs.getDouble(fieldName);
    if (rs.wasNull())
        return null;
    //if (o!=null) return rs.getDouble(fieldName);
    else/*from  w  w w .jav  a2  s.c  o  m*/
        return d;
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {/*from  ww  w  .  ja v  a 2  s.co  m*/
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFAccDb2LUWSchema.class, "getNullableByte", e);
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSchema.java

public static Long getNullableUInt32(ResultSet reader, int colidx) {
    try {/* ww  w  .  ja  v  a  2  s .  c  om*/
        long val = reader.getLong(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Long(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFAccDb2LUWSchema.class, "getNullableUInt32",
                e);
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSchema.java

public static Short getNullableInt16(ResultSet reader, int colidx) {
    try {//from w w  w . jav  a  2 s  .  c o  m
        short val = reader.getShort(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Short(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFAccDb2LUWSchema.class, "getNullableInt64", e);
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlSchema.java

public static Integer getNullableInt32(ResultSet reader, int colidx) {
    try {//from w w w .ja v  a2  s. c  o m
        int val = reader.getInt(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Integer(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFCrmMSSqlSchema.class, "getNullableInt32", e);
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlSchema.java

public static Integer getNullableUInt16(ResultSet reader, int colidx) {
    try {//  ww  w  .  j  a  v a  2 s.com
        int val = reader.getInt(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Integer(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFCrmMSSqlSchema.class, "getNullableUInt16", e);
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSchema.java

public static String getNullableString(ResultSet reader, int colidx) {
    try {/*from w w  w  . j  ava2  s  .c om*/
        String val = reader.getString(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (val);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFAccDb2LUWSchema.class, "getNullableString",
                e);
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlSchema.java

public static Long getNullableUInt32(ResultSet reader, int colidx) {
    try {/*from ww w . j  av a2  s  . c o  m*/
        long val = reader.getLong(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Long(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFCrmMSSqlSchema.class, "getNullableUInt32", e);
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {/*from w  w  w.  j  ava  2  s .co  m*/
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFCrmMSSqlSchema.class, "getNullableByte", e);
    }
}

From source file:com.flexive.ejb.beans.UserGroupEngineBean.java

/**
 * {@inheritDoc}/* www.j  a  v  a 2  s . co m*/
 */
@Override
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public List<UserGroup> loadAll(long mandatorId) throws FxApplicationException {
    Connection con = null;
    Statement stmt = null;
    String sql = null;
    try {

        // Obtain a database connection
        con = Database.getDbConnection();

        // Create the new workflow instance
        stmt = con.createStatement();

        //            1  2        3    4     5            6
        sql = "SELECT ID,MANDATOR,NAME,COLOR,AUTOMANDATOR,ISSYSTEM FROM " + TBL_USERGROUPS +
        // Never display the dummy NULL group
                " WHERE ID!=" + UserGroup.GROUP_NULL;
        if (mandatorId != -1)
            sql += " AND (MANDATOR=" + mandatorId + " or ID in (" + UserGroup.GROUP_EVERYONE + ","
                    + UserGroup.GROUP_OWNER + "))";
        sql += " ORDER BY MANDATOR,NAME";

        ResultSet rs = stmt.executeQuery(sql);

        // Process resultset
        final List<UserGroup> result = new ArrayList<UserGroup>();
        while (rs != null && rs.next()) {
            long autoMandator = rs.getLong(5);
            if (rs.wasNull())
                autoMandator = -1;
            result.add(new UserGroup(rs.getLong(1), rs.getLong(2), autoMandator, rs.getBoolean(6),
                    rs.getString(3), rs.getString(4)));
        }

        // Sanity check
        if (indexOfSelectableObject(result, UserGroup.GROUP_EVERYONE) == -1
                || indexOfSelectableObject(result, UserGroup.GROUP_OWNER) == -1) {
            FxLoadException le = new FxLoadException("ex.usergroup.oneOfSystemGroupsIsMissing");
            LOG.fatal(le);
            throw le;
        }

        return result;
    } catch (SQLException exc) {
        FxLoadException de = new FxLoadException(exc, "ex.usergroup.sqlError", exc.getMessage(), sql);
        LOG.error(de);
        throw de;
    } finally {
        Database.closeObjects(UserGroupEngineBean.class, con, stmt);
    }
}