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.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlSecDeviceTable.java

protected CFCrmSecDeviceBuff unpackSecDeviceResultSetToBuff(ResultSet resultSet) throws SQLException {
    final String S_ProcName = "unpackSecDeviceResultSetToBuff";
    int idxcol = 1;
    CFCrmSecDeviceBuff buff = schema.getFactorySecDevice().newBuff();
    {/*from   ww  w.  ja va2  s .  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(CFCrmMSSqlSchema.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(CFCrmMSSqlSchema.convertTimestampString(colString));
        }
        idxcol++;
    }
    buff.setRequiredSecUserId(CFCrmMSSqlSchema.convertUuidString(resultSet.getString(idxcol)));
    idxcol++;
    buff.setRequiredDevName(resultSet.getString(idxcol));
    idxcol++;
    {
        String colVal = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setOptionalPubKey(null);
        } else {
            buff.setOptionalPubKey(colVal);
        }
    }
    idxcol++;
    buff.setRequiredRevision(resultSet.getInt(idxcol));
    return (buff);
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskDb2LUW.CFAsteriskDb2LUWSecDeviceTable.java

protected CFSecuritySecDeviceBuff unpackSecDeviceResultSetToBuff(ResultSet resultSet) throws SQLException {
    final String S_ProcName = "unpackSecDeviceResultSetToBuff";
    int idxcol = 1;
    CFSecuritySecDeviceBuff buff = schema.getFactorySecDevice().newBuff();
    {/* w w w. j av a 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(CFAsteriskDb2LUWSchema.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(CFAsteriskDb2LUWSchema.convertTimestampString(colString));
        }
        idxcol++;
    }
    buff.setRequiredSecUserId(CFAsteriskDb2LUWSchema.convertUuidString(resultSet.getString(idxcol)));
    idxcol++;
    buff.setRequiredDevName(resultSet.getString(idxcol));
    idxcol++;
    {
        String colVal = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setOptionalPubKey(null);
        } else {
            buff.setOptionalPubKey(colVal);
        }
    }
    idxcol++;

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

From source file:com.itemanalysis.jmetrik.stats.descriptives.DescriptiveAnalysis.java

public void summarize() throws SQLException {
    Statement stmt = null;/*from ww  w  .j  a  v  a2 s.  co  m*/
    ResultSet rs = null;

    DescriptiveStatistics temp = null;

    Table sqlTable = new Table(tableName.getNameForDatabase());
    SelectQuery select = new SelectQuery();
    for (VariableAttributes v : variables) {
        select.addColumn(sqlTable, v.getName().nameForDatabase());
    }
    stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    rs = stmt.executeQuery(select.toString());

    double value = Double.NaN;
    while (rs.next()) {
        for (VariableAttributes v : variables) {
            temp = data.get(v);
            if (temp == null) {
                temp = new DescriptiveStatistics();
                data.put(v, temp);
            }

            //only increment for non null doubles
            value = rs.getDouble(v.getName().nameForDatabase());
            if (!rs.wasNull()) {
                temp.addValue(value);
            }
        }
        updateProgress();
    }

    rs.close();
    stmt.close();

    for (VariableAttributes v : data.keySet()) {
        publishTable(v);
    }

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstPgSql.CFAstPgSqlSecDeviceTable.java

protected CFAstSecDeviceBuff unpackSecDeviceResultSetToBuff(ResultSet resultSet) throws SQLException {
    final String S_ProcName = "unpackSecDeviceResultSetToBuff";
    int idxcol = 1;
    CFAstSecDeviceBuff buff = schema.getFactorySecDevice().newBuff();
    {/*from   ww  w .ja  v a 2s  . c  o 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(CFAstPgSqlSchema.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(CFAstPgSqlSchema.convertTimestampString(colString));
        }
        idxcol++;
    }
    buff.setRequiredSecUserId(CFAstPgSqlSchema.convertUuidString(resultSet.getString(idxcol)));
    idxcol++;
    buff.setRequiredDevName(resultSet.getString(idxcol));
    idxcol++;
    {
        String colVal = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setOptionalPubKey(null);
        } else {
            buff.setOptionalPubKey(colVal);
        }
    }
    idxcol++;

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

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstDb2LUW.CFAstDb2LUWSecDeviceTable.java

protected CFAstSecDeviceBuff unpackSecDeviceResultSetToBuff(ResultSet resultSet) throws SQLException {
    final String S_ProcName = "unpackSecDeviceResultSetToBuff";
    int idxcol = 1;
    CFAstSecDeviceBuff buff = schema.getFactorySecDevice().newBuff();
    {/*from ww w . j  a  v a2  s  .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(CFAstDb2LUWSchema.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(CFAstDb2LUWSchema.convertTimestampString(colString));
        }
        idxcol++;
    }
    buff.setRequiredSecUserId(CFAstDb2LUWSchema.convertUuidString(resultSet.getString(idxcol)));
    idxcol++;
    buff.setRequiredDevName(resultSet.getString(idxcol));
    idxcol++;
    {
        String colVal = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setOptionalPubKey(null);
        } else {
            buff.setOptionalPubKey(colVal);
        }
    }
    idxcol++;

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

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskMSSql.CFAsteriskMSSqlSecDeviceTable.java

protected CFSecuritySecDeviceBuff unpackSecDeviceResultSetToBuff(ResultSet resultSet) throws SQLException {
    final String S_ProcName = "unpackSecDeviceResultSetToBuff";
    int idxcol = 1;
    CFSecuritySecDeviceBuff buff = schema.getFactorySecDevice().newBuff();
    {//from w  w w. j  a  va 2s .  c o 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(CFAsteriskMSSqlSchema.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(CFAsteriskMSSqlSchema.convertTimestampString(colString));
        }
        idxcol++;
    }
    buff.setRequiredSecUserId(CFAsteriskMSSqlSchema.convertUuidString(resultSet.getString(idxcol)));
    idxcol++;
    buff.setRequiredDevName(resultSet.getString(idxcol));
    idxcol++;
    {
        String colVal = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setOptionalPubKey(null);
        } else {
            buff.setOptionalPubKey(colVal);
        }
    }
    idxcol++;
    buff.setRequiredRevision(resultSet.getInt(idxcol));
    return (buff);
}

From source file:com.flexive.core.storage.genericSQL.GenericEnvironmentLoader.java

/**
 * {@inheritDoc}//w w w .  j a  v  a  2  s .c om
 */
@Override
public List<FxSelectList> loadSelectLists(Connection con, FxEnvironmentImpl environment)
        throws FxLoadException {
    PreparedStatement ps = null;
    String sql;
    List<FxSelectList> lists = new ArrayList<FxSelectList>(10);
    try {
        final Map<Long, FxString[]> translations = Database.loadFxStrings(con, TBL_STRUCT_SELECTLIST, "LABEL",
                "DESCRIPTION");
        final Map<Long, FxString[]> itemTranslations = Database.loadFxStrings(con, TBL_STRUCT_SELECTLIST_ITEM,
                "LABEL");

        //            1  2        3    4                 5               6            7            8     9             10
        sql = "SELECT ID,PARENTID,NAME,ALLOW_ITEM_CREATE,ACL_CREATE_ITEM,ACL_ITEM_NEW,DEFAULT_ITEM,BCSEP,SAMELVLSELECT,SORTENTRIES FROM "
                + TBL_STRUCT_SELECTLIST + " ORDER BY NAME";
        ps = con.prepareStatement(sql);
        ResultSet rs = ps.executeQuery();
        while (rs != null && rs.next()) {
            final long id = rs.getLong(1);
            long parent = rs.getLong(2);
            if (rs.wasNull())
                parent = -1;
            String bcSep = rs.getString(8);
            if (rs.wasNull())
                bcSep = " > ";
            boolean sameLvl = rs.getBoolean(9);
            if (rs.wasNull())
                sameLvl = false;
            boolean sort = rs.getBoolean(10);
            if (rs.wasNull())
                sort = false;
            lists.add(new FxSelectList(id, parent, rs.getString(3), getTranslation(translations, id, 0, false),
                    getTranslation(translations, id, 1, false), rs.getBoolean(4),
                    environment.getACL(rs.getLong(5)), environment.getACL(rs.getLong(6)), rs.getLong(7), bcSep,
                    sameLvl, sort));
        }
        ps.close();
        //            1  2    3   4        5    6     7          8          9           10          11      12       13
        sql = "SELECT ID,NAME,ACL,PARENTID,DATA,COLOR,CREATED_BY,CREATED_AT,MODIFIED_BY,MODIFIED_AT,DBIN_ID,DBIN_VER,DBIN_QUALITY FROM "
                + TBL_STRUCT_SELECTLIST_ITEM + " WHERE LISTID=? ORDER BY POS,ID";
        ps = con.prepareStatement(sql);
        for (FxSelectList list : lists) {
            ps.setLong(1, list.getId());
            rs = ps.executeQuery();
            int pos = 0;
            while (rs != null && rs.next()) {
                final long id = rs.getLong(1);
                long parent = rs.getLong(4);
                if (rs.wasNull())
                    parent = -1;
                new FxSelectListItem(id, rs.getString(2), environment.getACL(rs.getLong(3)), list, parent,
                        getTranslation(itemTranslations, id, 0, false), rs.getString(5), rs.getString(6),
                        rs.getLong(11), rs.getInt(12), rs.getInt(13), LifeCycleInfoImpl.load(rs, 7, 8, 9, 10),
                        pos++);
            }
        }
    } catch (SQLException exc) {
        throw new FxLoadException(LOG, exc, "ex.structure.list.load.failed", exc.getMessage());
    } finally {
        Database.closeObjects(GenericEnvironmentLoader.class, null, ps);
    }
    return lists;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseSecDeviceTable.java

protected CFSecuritySecDeviceBuff unpackSecDeviceResultSetToBuff(ResultSet resultSet) throws SQLException {
    final String S_ProcName = "unpackSecDeviceResultSetToBuff";
    int idxcol = 1;
    CFSecuritySecDeviceBuff buff = schema.getFactorySecDevice().newBuff();
    {/* ww w .  ja va  2s.  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(CFAsteriskSybaseSchema.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(CFAsteriskSybaseSchema.convertTimestampString(colString));
        }
        idxcol++;
    }
    buff.setRequiredSecUserId(CFAsteriskSybaseSchema.convertUuidString(resultSet.getString(idxcol)));
    idxcol++;
    buff.setRequiredDevName(resultSet.getString(idxcol));
    idxcol++;
    {
        String colVal = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setOptionalPubKey(null);
        } else {
            buff.setOptionalPubKey(colVal);
        }
    }
    idxcol++;
    buff.setRequiredRevision(resultSet.getInt(idxcol));
    return (buff);
}

From source file:com.itemanalysis.jmetrik.stats.ranking.RankingAnalysis.java

private ResizableDoubleArray getData() throws SQLException {
    Statement stmt = null;/*  w ww.j a v  a 2 s .  c om*/
    ResultSet rs = null;
    ResizableDoubleArray data = new ResizableDoubleArray((int) (maxProgress / 2.0));

    try {
        //connect to table to create data set to be ranked
        Table sqlTable = new Table(tableName.getNameForDatabase());
        SelectQuery select = new SelectQuery();
        select.addColumn(sqlTable, variable.getName().nameForDatabase());
        stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        rs = stmt.executeQuery(select.toString());

        String vNameDb = variable.getName().nameForDatabase();

        double x = Double.NaN;
        int dbIndex = 0;//row position index for all records in db
        while (rs.next()) {
            x = rs.getDouble(vNameDb);
            if (!rs.wasNull()) {
                if (ascending) {
                    data.addElement(x);//ascending order
                } else {
                    data.addElement(-x);//descending order
                }

            } else {
                missingIndex.add(dbIndex);
            }
            dbIndex++;
            updateProgress();
        }
        return data;
    } catch (SQLException ex) {
        throw ex;
    } finally {
        if (rs != null)
            rs.close();
        if (stmt != null)
            stmt.close();

    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSecDeviceTable.java

protected CFAstSecDeviceBuff unpackSecDeviceResultSetToBuff(ResultSet resultSet) throws SQLException {
    final String S_ProcName = "unpackSecDeviceResultSetToBuff";
    int idxcol = 1;
    CFAstSecDeviceBuff buff = schema.getFactorySecDevice().newBuff();
    {//w w w .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(CFAstSybaseSchema.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(CFAstSybaseSchema.convertTimestampString(colString));
        }
        idxcol++;
    }
    buff.setRequiredSecUserId(CFAstSybaseSchema.convertUuidString(resultSet.getString(idxcol)));
    idxcol++;
    buff.setRequiredDevName(resultSet.getString(idxcol));
    idxcol++;
    {
        String colVal = resultSet.getString(idxcol);
        if (resultSet.wasNull()) {
            buff.setOptionalPubKey(null);
        } else {
            buff.setOptionalPubKey(colVal);
        }
    }
    idxcol++;
    buff.setRequiredRevision(resultSet.getInt(idxcol));
    return (buff);
}