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:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlSchema.java

public static Integer getNullableUInt16(ResultSet reader, int colidx) {
    try {//from  ww w  . ja  v  a2s  .co  m
        int val = reader.getInt(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Integer(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFAccMSSqlSchema.class, "getNullableUInt16", e);
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlSchema.java

public static Long getNullableUInt32(ResultSet reader, int colidx) {
    try {/*from  w w  w  . j a va  2s.  co m*/
        long val = reader.getLong(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Long(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFAccMSSqlSchema.class, "getNullableUInt32", e);
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlSchema.java

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

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlSchema.java

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

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlSchema.java

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

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlSchema.java

public static BigDecimal getNullableUInt64(ResultSet reader, int colidx) {
    try {//from   w  w w.  ja  v a  2  s .c  o m
        String strval = reader.getString(colidx);
        if (reader.wasNull() || (strval == null) || (strval.length() <= 0)) {
            return (null);
        } else {
            BigDecimal retval = new BigDecimal(strval);
            return (retval);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFAccMSSqlSchema.class, "getNullableUInt64", e);
    }
}

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

/**
 * {@inheritDoc}/*from   ww  w . j  av  a  2s.co m*/
 */
@Override
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public ACL load(long id, boolean ignoreSecurity) throws FxApplicationException {
    Connection con = null;
    Statement stmt = null;
    String curSql;
    try {
        final FxEnvironment environment = CacheAdmin.getEnvironment();

        // Obtain a database connection
        con = Database.getDbConnection();
        //               1        2    3        4           5     6          7          8           9
        curSql = "SELECT MANDATOR,NAME,CAT_TYPE,DESCRIPTION,COLOR,CREATED_BY,CREATED_AT,MODIFIED_BY,MODIFIED_AT FROM "
                + TBL_ACLS + " WHERE ID=" + id;
        stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(curSql);

        if (rs == null || !rs.next())
            throw new FxNotFoundException("ex.acl.load.notFound", id);

        // Read the ACL
        long mandatorId = rs.getLong(1);
        String name = rs.getString(2);
        int cat = rs.getInt(3);
        String desc = rs.getString(4);
        if (rs.wasNull())
            desc = "";
        String color = rs.getString(5);
        if (rs.wasNull())
            color = "";
        FxString label = Database.loadFxString(con, TBL_ACLS, "LABEL", "ID=" + id);
        String sMandator = environment.getMandator(mandatorId).getName();
        ACL theACL = new ACL(id, name, label, mandatorId, sMandator, desc, color, ACLCategory.getById(cat),
                LifeCycleInfoImpl.load(rs, 6, 7, 8, 9));
        if (ignoreSecurity && mandatorId != FxContext.getUserTicket().getMandatorId())
            throw new FxNoAccessException(LOG, "ex.acl.loadFailed.foreignMandator", theACL.getName());
        // Return the ACL
        return theACL;
    } catch (SQLException exc) {
        throw new FxLoadException(LOG, "ex.acl.load.sqlError", id, exc.getMessage());
    } finally {
        Database.closeObjects(ACLEngineBean.class, con, stmt);
    }
}

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

/**
 * {@inheritDoc}/* w w  w  .  j  av  a2s . co m*/
 */
@Override
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public UserGroup load(long groupId) throws FxApplicationException {
    Connection con = null;
    Statement stmt = null;
    String sql = "SELECT MANDATOR,NAME,COLOR,AUTOMANDATOR,ISSYSTEM FROM " + TBL_USERGROUPS + " WHERE ID="
            + groupId;
    try {

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

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

        // Build statement
        ResultSet rs = stmt.executeQuery(sql);

        // Does the group exist at all?
        if (rs == null || !rs.next()) {
            FxNotFoundException nfe = new FxNotFoundException("ex.account.group.notFound.id", groupId);
            if (LOG.isInfoEnabled())
                LOG.info(nfe);
            throw nfe;
        }
        long autoMandator = rs.getLong(4);
        if (rs.wasNull())
            autoMandator = -1;
        return new UserGroup(groupId, rs.getLong(1), autoMandator, rs.getBoolean(5), rs.getString(2),
                rs.getString(3));

    } 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);
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWMimeTypeTable.java

protected CFCrmMimeTypeBuff unpackMimeTypeResultSetToBuff(ResultSet resultSet) throws SQLException {
    final String S_ProcName = "unpackMimeTypeResultSetToBuff";
    int idxcol = 1;
    CFCrmMimeTypeBuff buff = schema.getFactoryMimeType().newBuff();
    {/*  www  .  ja  va 2s  .co m*/
        String colString = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setCreatedByUserId(null);
        } else if ((colString == null) || (colString.length() <= 0)) {
            buff.setCreatedByUserId(null);
        } else {
            buff.setCreatedByUserId(UUID.fromString(colString));
        }
        idxcol++;

        colString = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setCreatedAt(null);
        } else if ((colString == null) || (colString.length() <= 0)) {
            buff.setCreatedAt(null);
        } else {
            buff.setCreatedAt(CFCrmDb2LUWSchema.convertTimestampString(colString));
        }
        idxcol++;
        colString = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setUpdatedByUserId(null);
        } else if ((colString == null) || (colString.length() <= 0)) {
            buff.setUpdatedByUserId(null);
        } else {
            buff.setUpdatedByUserId(UUID.fromString(colString));
        }
        idxcol++;

        colString = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setUpdatedAt(null);
        } else if ((colString == null) || (colString.length() <= 0)) {
            buff.setUpdatedAt(null);
        } else {
            buff.setUpdatedAt(CFCrmDb2LUWSchema.convertTimestampString(colString));
        }
        idxcol++;
    }
    buff.setRequiredMimeTypeId(resultSet.getInt(idxcol));
    idxcol++;
    buff.setRequiredName(resultSet.getString(idxcol));
    idxcol++;
    buff.setRequiredDescription(resultSet.getString(idxcol));
    idxcol++;

    buff.setRequiredRevision(resultSet.getInt(idxcol));
    return (buff);
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWServiceTypeTable.java

protected CFCrmServiceTypeBuff unpackServiceTypeResultSetToBuff(ResultSet resultSet) throws SQLException {
    final String S_ProcName = "unpackServiceTypeResultSetToBuff";
    int idxcol = 1;
    CFCrmServiceTypeBuff buff = schema.getFactoryServiceType().newBuff();
    {/*from  w  w  w  .j a v  a 2  s.com*/
        String colString = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setCreatedByUserId(null);
        } else if ((colString == null) || (colString.length() <= 0)) {
            buff.setCreatedByUserId(null);
        } else {
            buff.setCreatedByUserId(UUID.fromString(colString));
        }
        idxcol++;

        colString = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setCreatedAt(null);
        } else if ((colString == null) || (colString.length() <= 0)) {
            buff.setCreatedAt(null);
        } else {
            buff.setCreatedAt(CFCrmDb2LUWSchema.convertTimestampString(colString));
        }
        idxcol++;
        colString = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setUpdatedByUserId(null);
        } else if ((colString == null) || (colString.length() <= 0)) {
            buff.setUpdatedByUserId(null);
        } else {
            buff.setUpdatedByUserId(UUID.fromString(colString));
        }
        idxcol++;

        colString = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setUpdatedAt(null);
        } else if ((colString == null) || (colString.length() <= 0)) {
            buff.setUpdatedAt(null);
        } else {
            buff.setUpdatedAt(CFCrmDb2LUWSchema.convertTimestampString(colString));
        }
        idxcol++;
    }
    buff.setRequiredServiceTypeId(resultSet.getInt(idxcol));
    idxcol++;
    buff.setRequiredDescription(resultSet.getString(idxcol));
    idxcol++;

    buff.setRequiredRevision(resultSet.getInt(idxcol));
    return (buff);
}