Example usage for java.sql Types BIGINT

List of usage examples for java.sql Types BIGINT

Introduction

In this page you can find the example usage for java.sql Types BIGINT.

Prototype

int BIGINT

To view the source code for java.sql Types BIGINT.

Click Source Link

Document

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type BIGINT.

Usage

From source file:com.splicemachine.db.impl.sql.compile.QueryTreeNode.java

/**
 * Get a ConstantNode to represent a typed null value.
 *
 * @param type Type of the null node.//from www  .j av a 2  s .  com
 * @throws StandardException Thrown on error
 * @return A ConstantNode with the specified type, and a value of null
 */
public ConstantNode getNullNode(DataTypeDescriptor type) throws StandardException {
    int constantNodeType;
    switch (type.getTypeId().getJDBCTypeId()) {
    case Types.VARCHAR:
        constantNodeType = C_NodeTypes.VARCHAR_CONSTANT_NODE;
        break;
    case Types.CHAR:
        constantNodeType = C_NodeTypes.CHAR_CONSTANT_NODE;
        break;
    case Types.TINYINT:
        constantNodeType = C_NodeTypes.TINYINT_CONSTANT_NODE;
        break;
    case Types.SMALLINT:
        constantNodeType = C_NodeTypes.SMALLINT_CONSTANT_NODE;
        break;
    case Types.INTEGER:
        constantNodeType = C_NodeTypes.INT_CONSTANT_NODE;
        break;
    case Types.BIGINT:
        constantNodeType = C_NodeTypes.LONGINT_CONSTANT_NODE;
        break;
    case Types.REAL:
        constantNodeType = C_NodeTypes.FLOAT_CONSTANT_NODE;
        break;
    case Types.DOUBLE:
        constantNodeType = C_NodeTypes.DOUBLE_CONSTANT_NODE;
        break;
    case Types.NUMERIC:
    case Types.DECIMAL:
        constantNodeType = C_NodeTypes.DECIMAL_CONSTANT_NODE;
        break;
    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
        constantNodeType = C_NodeTypes.USERTYPE_CONSTANT_NODE;
        break;
    case Types.BINARY:
        constantNodeType = C_NodeTypes.BIT_CONSTANT_NODE;
        break;
    case Types.VARBINARY:
        constantNodeType = C_NodeTypes.VARBIT_CONSTANT_NODE;
        break;
    case Types.LONGVARCHAR:
        constantNodeType = C_NodeTypes.LONGVARCHAR_CONSTANT_NODE;
        break;
    case Types.CLOB:
        constantNodeType = C_NodeTypes.CLOB_CONSTANT_NODE;
        break;
    case Types.LONGVARBINARY:
        constantNodeType = C_NodeTypes.LONGVARBIT_CONSTANT_NODE;
        break;
    case Types.BLOB:
        constantNodeType = C_NodeTypes.BLOB_CONSTANT_NODE;
        break;
    case JDBC40Translation.SQLXML:
        constantNodeType = C_NodeTypes.XML_CONSTANT_NODE;
        break;
    case Types.BOOLEAN:
        constantNodeType = C_NodeTypes.BOOLEAN_CONSTANT_NODE;
        break;
    default:
        if (type.getTypeId().userType()) {
            constantNodeType = C_NodeTypes.USERTYPE_CONSTANT_NODE;
        } else {
            throw StandardException.newException(SQLState.LANG_NONULL_DATATYPE,
                    type.getTypeId().getSQLTypeName());
        }
    }

    ConstantNode constantNode = (ConstantNode) getNodeFactory().getNode(constantNodeType, type.getTypeId(), cm);

    constantNode.setType(type.getNullabilityType(true));

    return constantNode;
}

From source file:dk.netarkivet.harvester.datamodel.HarvestDefinitionDBDAO.java

/**
 * Update an existing harvest definition with new info.
 *
 * @param hd/*from www. j ava2s  .  c  om*/
 *            An updated harvest definition
 * @see HarvestDefinitionDAO#update(HarvestDefinition)
 */
public synchronized void update(HarvestDefinition hd) {
    ArgumentNotValid.checkNotNull(hd, "HarvestDefinition hd");
    if (hd.getOid() == null || !exists(hd.getOid())) {
        final String message = "Cannot update non-existing " + "harvestdefinition '" + hd.getName() + "'";
        log.debug(message);
        throw new PermissionDenied(message);
    }
    HarvestDefinition preHD = null;
    if (hd instanceof FullHarvest) {
        preHD = ((FullHarvest) hd).getPreviousHarvestDefinition();
    }

    Connection c = HarvestDBConnection.get();
    PreparedStatement s = null;
    try {
        c.setAutoCommit(false);
        s = c.prepareStatement("UPDATE harvestdefinitions SET " + "name = ?, " + "comments = ?, "
                + "numevents = ?, " + "submitted = ?," + "isactive = ?," + "edition = ?, audience = ? "
                + "WHERE harvest_id = ? AND edition = ?");
        DBUtils.setName(s, 1, hd, Constants.MAX_NAME_SIZE);
        DBUtils.setComments(s, 2, hd, Constants.MAX_COMMENT_SIZE);
        s.setInt(3, hd.getNumEvents());
        s.setTimestamp(4, new Timestamp(hd.getSubmissionDate().getTime()));
        s.setBoolean(5, hd.getActive());
        long nextEdition = hd.getEdition() + 1;
        s.setLong(6, nextEdition);
        s.setString(7, hd.getAudience());
        s.setLong(8, hd.getOid());
        s.setLong(9, hd.getEdition());

        int rows = s.executeUpdate();
        // Since the HD exists, no rows indicates bad edition
        if (rows == 0) {
            String message = "Somebody else must have updated " + hd + " since edition " + hd.getEdition()
                    + ", not updating";
            log.debug(message);
            throw new PermissionDenied(message);
        }
        s.close();
        if (hd instanceof FullHarvest) {
            FullHarvest fh = (FullHarvest) hd;
            s = c.prepareStatement(
                    "UPDATE fullharvests SET " + "previoushd = ?, " + "maxobjects = ?, " + "maxbytes = ?, "
                            + "maxjobrunningtime = ?, " + "isindexready = ? " + "WHERE harvest_id = ?");
            if (preHD != null) {
                s.setLong(1, preHD.getOid());
            } else {
                s.setNull(1, Types.BIGINT);
            }
            s.setLong(2, fh.getMaxCountObjects());
            s.setLong(3, fh.getMaxBytes());
            s.setLong(4, fh.getMaxJobRunningTime());
            s.setBoolean(5, fh.getIndexReady());
            s.setLong(6, fh.getOid());

            rows = s.executeUpdate();
            log.debug(rows + " fullharvests records updated");
        } else if (hd instanceof PartialHarvest) {
            PartialHarvest ph = (PartialHarvest) hd;
            s = c.prepareStatement(
                    "UPDATE partialharvests SET " + "schedule_id = " + "    (SELECT schedule_id FROM schedules "
                            + "WHERE schedules.name = ?), " + "nextdate = ? " + "WHERE harvest_id = ?");
            s.setString(1, ph.getSchedule().getName());
            DBUtils.setDateMaybeNull(s, 2, ph.getNextDate());
            s.setLong(3, ph.getOid());
            rows = s.executeUpdate();
            log.debug(rows + " partialharvests records updated");
            s.close();
            // FIXME The updates to harvest_configs table should be done
            // in method removeDomainConfiguration(), and not here.
            // The following deletes ALL harvest_configs entries for
            // this PartialHarvest, and creates the entries for the
            // PartialHarvest again!!
            createHarvestConfigsEntries(c, ph, ph.getOid());
        } else {
            String message = "Harvest definition " + hd + " has unknown class " + hd.getClass();
            log.warn(message);
            throw new ArgumentNotValid(message);
        }
        saveExtendedFieldValues(c, hd);

        c.commit();
        hd.setEdition(nextEdition);
    } catch (SQLException e) {
        throw new IOFailure("SQL error while updating harvest definition " + hd + "\n"
                + ExceptionUtils.getSQLExceptionCause(e), e);
    } finally {
        DBUtils.closeStatementIfOpen(s);
        DBUtils.rollbackIfNeeded(c, "updating", hd);
        HarvestDBConnection.release(c);
    }
}

From source file:com.google.visualization.datasource.util.SqlDataSourceHelper.java

/**
 * Converts the given SQL type to a value type.
 *
 * @param sqlType The sql type to be converted.
 *
 * @return The value type that fits the given sql type.
 *///  w  ww .  j a v  a  2 s . c om
private static ValueType sqlTypeToValueType(int sqlType) {
    ValueType valueType;
    switch (sqlType) {
    case Types.BOOLEAN:
    case Types.BIT: {
        valueType = ValueType.BOOLEAN;
        break;
    }
    case Types.CHAR:
    case Types.VARCHAR:
        valueType = ValueType.TEXT;
        break;
    case Types.INTEGER:
    case Types.SMALLINT:
    case Types.BIGINT:
    case Types.TINYINT:
    case Types.REAL:
    case Types.NUMERIC:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.DECIMAL:
        valueType = ValueType.NUMBER;
        break;
    case Types.DATE:
        valueType = ValueType.DATE;
        break;
    case Types.TIME:
        valueType = ValueType.TIMEOFDAY;
        break;
    case Types.TIMESTAMP:
        valueType = ValueType.DATETIME;
        break;
    default:
        valueType = ValueType.TEXT;
        break;
    }
    return valueType;
}

From source file:CSVWriter.java

private String getColumnValue(ResultSet rs, int colType, int colIndex) throws SQLException, IOException {

    String value = "";

    switch (colType) {
    case Types.BIT:
    case Types.JAVA_OBJECT:
        value = handleObject(rs.getObject(colIndex));
        break;//from w  w  w .ja v a2  s  .co m
    case Types.BOOLEAN:
        boolean b = rs.getBoolean(colIndex);
        value = Boolean.valueOf(b).toString();
        break;
    case NCLOB: // todo : use rs.getNClob
    case Types.CLOB:
        Clob c = rs.getClob(colIndex);
        if (c != null) {
            value = read(c);
        }
        break;
    case Types.BIGINT:
        value = handleLong(rs, colIndex);
        break;
    case Types.DECIMAL:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.REAL:
    case Types.NUMERIC:
        value = handleBigDecimal(rs.getBigDecimal(colIndex));
        break;
    case Types.INTEGER:
    case Types.TINYINT:
    case Types.SMALLINT:
        value = handleInteger(rs, colIndex);
        break;
    case Types.DATE:
        value = handleDate(rs, colIndex);
        break;
    case Types.TIME:
        value = handleTime(rs.getTime(colIndex));
        break;
    case Types.TIMESTAMP:
        value = handleTimestamp(rs.getTimestamp(colIndex));
        break;
    case NVARCHAR: // todo : use rs.getNString
    case NCHAR: // todo : use rs.getNString
    case LONGNVARCHAR: // todo : use rs.getNString
    case Types.LONGVARCHAR:
    case Types.VARCHAR:
    case Types.CHAR:
        value = rs.getString(colIndex);
        break;
    default:
        value = "";
    }

    if (value == null) {
        value = "";
    }

    return value;

}

From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMySql.CFEnSyntaxMySqlEnHeadTable.java

public CFEnSyntaxEnHeadBuff[] readBuffByScopeIdx(CFEnSyntaxAuthorization Authorization, Long ScopeId) {
    final String S_ProcName = "readBuffByScopeIdx";
    ResultSet resultSet = null;/*  w  w w.ja  va  2  s. c  o  m*/
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_enhead_by_scopeidx( ?, ?, ?, ?, ?"
                + ", " + "?" + " )";
        if (stmtReadBuffByScopeIdx == null) {
            stmtReadBuffByScopeIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByScopeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByScopeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (ScopeId != null) {
            stmtReadBuffByScopeIdx.setLong(argIdx++, ScopeId.longValue());
        } else {
            stmtReadBuffByScopeIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        try {
            resultSet = stmtReadBuffByScopeIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        List<CFEnSyntaxEnHeadBuff> buffList = new LinkedList<CFEnSyntaxEnHeadBuff>();
        while ((resultSet != null) && resultSet.next()) {
            CFEnSyntaxEnHeadBuff buff = unpackEnHeadResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        int idx = 0;
        CFEnSyntaxEnHeadBuff[] retBuff = new CFEnSyntaxEnHeadBuff[buffList.size()];
        Iterator<CFEnSyntaxEnHeadBuff> iter = buffList.iterator();
        while (iter.hasNext()) {
            retBuff[idx++] = iter.next();
        }
        return (retBuff);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMySql.CFEnSyntaxMySqlEnWordTable.java

public CFEnSyntaxEnWordBuff[] readBuffByScopeIdx(CFEnSyntaxAuthorization Authorization, Long ScopeId) {
    final String S_ProcName = "readBuffByScopeIdx";
    ResultSet resultSet = null;//from   w  w w  . ja v  a2s .  c om
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_enword_by_scopeidx( ?, ?, ?, ?, ?"
                + ", " + "?" + " )";
        if (stmtReadBuffByScopeIdx == null) {
            stmtReadBuffByScopeIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByScopeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByScopeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (ScopeId != null) {
            stmtReadBuffByScopeIdx.setLong(argIdx++, ScopeId.longValue());
        } else {
            stmtReadBuffByScopeIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        try {
            resultSet = stmtReadBuffByScopeIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        List<CFEnSyntaxEnWordBuff> buffList = new LinkedList<CFEnSyntaxEnWordBuff>();
        while ((resultSet != null) && resultSet.next()) {
            CFEnSyntaxEnWordBuff buff = unpackEnWordResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        int idx = 0;
        CFEnSyntaxEnWordBuff[] retBuff = new CFEnSyntaxEnWordBuff[buffList.size()];
        Iterator<CFEnSyntaxEnWordBuff> iter = buffList.iterator();
        while (iter.hasNext()) {
            retBuff[idx++] = iter.next();
        }
        return (retBuff);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMySql.CFEnSyntaxMySqlEnTenseTable.java

public CFEnSyntaxEnTenseBuff[] readBuffByScopeIdx(CFEnSyntaxAuthorization Authorization, Long ScopeId) {
    final String S_ProcName = "readBuffByScopeIdx";
    ResultSet resultSet = null;/* w  w w.ja  va 2 s .  co m*/
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_entense_by_scopeidx( ?, ?, ?, ?, ?"
                + ", " + "?" + " )";
        if (stmtReadBuffByScopeIdx == null) {
            stmtReadBuffByScopeIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByScopeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByScopeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (ScopeId != null) {
            stmtReadBuffByScopeIdx.setLong(argIdx++, ScopeId.longValue());
        } else {
            stmtReadBuffByScopeIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        try {
            resultSet = stmtReadBuffByScopeIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        List<CFEnSyntaxEnTenseBuff> buffList = new LinkedList<CFEnSyntaxEnTenseBuff>();
        while ((resultSet != null) && resultSet.next()) {
            CFEnSyntaxEnTenseBuff buff = unpackEnTenseResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        int idx = 0;
        CFEnSyntaxEnTenseBuff[] retBuff = new CFEnSyntaxEnTenseBuff[buffList.size()];
        Iterator<CFEnSyntaxEnTenseBuff> iter = buffList.iterator();
        while (iter.hasNext()) {
            retBuff[idx++] = iter.next();
        }
        return (retBuff);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMySql.CFEnSyntaxMySqlEnObjectTable.java

public CFEnSyntaxEnObjectBuff[] readBuffByScopeIdx(CFEnSyntaxAuthorization Authorization, Long ScopeId) {
    final String S_ProcName = "readBuffByScopeIdx";
    ResultSet resultSet = null;//from   www  . j a  va2s  .com
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_enobj_by_scopeidx( ?, ?, ?, ?, ?"
                + ", " + "?" + " )";
        if (stmtReadBuffByScopeIdx == null) {
            stmtReadBuffByScopeIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByScopeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByScopeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (ScopeId != null) {
            stmtReadBuffByScopeIdx.setLong(argIdx++, ScopeId.longValue());
        } else {
            stmtReadBuffByScopeIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        try {
            resultSet = stmtReadBuffByScopeIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        List<CFEnSyntaxEnObjectBuff> buffList = new LinkedList<CFEnSyntaxEnObjectBuff>();
        while ((resultSet != null) && resultSet.next()) {
            CFEnSyntaxEnObjectBuff buff = unpackEnObjectResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        int idx = 0;
        CFEnSyntaxEnObjectBuff[] retBuff = new CFEnSyntaxEnObjectBuff[buffList.size()];
        Iterator<CFEnSyntaxEnObjectBuff> iter = buffList.iterator();
        while (iter.hasNext()) {
            retBuff[idx++] = iter.next();
        }
        return (retBuff);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMySql.CFEnSyntaxMySqlEnClauseTable.java

public CFEnSyntaxEnClauseBuff[] readBuffByScopeIdx(CFEnSyntaxAuthorization Authorization, Long ScopeId) {
    final String S_ProcName = "readBuffByScopeIdx";
    ResultSet resultSet = null;//from   w  w  w  .  j a v  a  2  s .co  m
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_enclause_by_scopeidx( ?, ?, ?, ?, ?"
                + ", " + "?" + " )";
        if (stmtReadBuffByScopeIdx == null) {
            stmtReadBuffByScopeIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByScopeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByScopeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (ScopeId != null) {
            stmtReadBuffByScopeIdx.setLong(argIdx++, ScopeId.longValue());
        } else {
            stmtReadBuffByScopeIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        try {
            resultSet = stmtReadBuffByScopeIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        List<CFEnSyntaxEnClauseBuff> buffList = new LinkedList<CFEnSyntaxEnClauseBuff>();
        while ((resultSet != null) && resultSet.next()) {
            CFEnSyntaxEnClauseBuff buff = unpackEnClauseResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        int idx = 0;
        CFEnSyntaxEnClauseBuff[] retBuff = new CFEnSyntaxEnClauseBuff[buffList.size()];
        Iterator<CFEnSyntaxEnClauseBuff> iter = buffList.iterator();
        while (iter.hasNext()) {
            retBuff[idx++] = iter.next();
        }
        return (retBuff);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMySql.CFEnSyntaxMySqlEnPhraseTable.java

public CFEnSyntaxEnPhraseBuff[] readBuffByScopeIdx(CFEnSyntaxAuthorization Authorization, Long ScopeId) {
    final String S_ProcName = "readBuffByScopeIdx";
    ResultSet resultSet = null;/*  w ww  .j  a  v  a2s  .  c  om*/
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_enphrase_by_scopeidx( ?, ?, ?, ?, ?"
                + ", " + "?" + " )";
        if (stmtReadBuffByScopeIdx == null) {
            stmtReadBuffByScopeIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByScopeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByScopeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByScopeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (ScopeId != null) {
            stmtReadBuffByScopeIdx.setLong(argIdx++, ScopeId.longValue());
        } else {
            stmtReadBuffByScopeIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        try {
            resultSet = stmtReadBuffByScopeIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        List<CFEnSyntaxEnPhraseBuff> buffList = new LinkedList<CFEnSyntaxEnPhraseBuff>();
        while ((resultSet != null) && resultSet.next()) {
            CFEnSyntaxEnPhraseBuff buff = unpackEnPhraseResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        int idx = 0;
        CFEnSyntaxEnPhraseBuff[] retBuff = new CFEnSyntaxEnPhraseBuff[buffList.size()];
        Iterator<CFEnSyntaxEnPhraseBuff> iter = buffList.iterator();
        while (iter.hasNext()) {
            retBuff[idx++] = iter.next();
        }
        return (retBuff);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}