Example usage for java.sql Types INTEGER

List of usage examples for java.sql Types INTEGER

Introduction

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

Prototype

int INTEGER

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

Click Source Link

Document

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

Usage

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMySql.CFAccMySqlAttachmentTable.java

public void deleteAttachmentByMimeTypeIdx(CFAccAuthorization Authorization, Integer argMimeTypeId) {
    final String S_ProcName = "deleteAttachmentByMimeTypeIdx";
    ResultSet resultSet = null;/*w ww  .  j av a2 s  . co m*/
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerSchemaDbName()
                + ".sp_delete_attchmnt_by_mimetypeidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtDeleteByMimeTypeIdx == null) {
            stmtDeleteByMimeTypeIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByMimeTypeIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByMimeTypeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByMimeTypeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByMimeTypeIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByMimeTypeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argMimeTypeId != null) {
            stmtDeleteByMimeTypeIdx.setInt(argIdx++, argMimeTypeId.intValue());
        } else {
            stmtDeleteByMimeTypeIdx.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        stmtDeleteByMimeTypeIdx.executeUpdate();
    } 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.cfacc.v2_0.CFAccPgSql.CFAccPgSqlAttachmentTable.java

public void deleteAttachmentByMimeTypeIdx(CFAccAuthorization Authorization, Integer argMimeTypeId) {
    final String S_ProcName = "deleteAttachmentByMimeTypeIdx";
    ResultSet resultSet = null;/*w ww .j  a va  2 s.c om*/
    try {
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerSchemaDbName()
                + ".sp_delete_attchmnt_by_mimetypeidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag";
        if (stmtDeleteByMimeTypeIdx == null) {
            stmtDeleteByMimeTypeIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByMimeTypeIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByMimeTypeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByMimeTypeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByMimeTypeIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByMimeTypeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argMimeTypeId != null) {
            stmtDeleteByMimeTypeIdx.setInt(argIdx++, argMimeTypeId.intValue());
        } else {
            stmtDeleteByMimeTypeIdx.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        resultSet = stmtDeleteByMimeTypeIdx.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 record result set to be returned by delete, not 0 rows");
        }
    } 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.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWAttachmentTable.java

public void deleteAttachmentByMimeTypeIdx(CFAccAuthorization Authorization, Integer argMimeTypeId) {
    final String S_ProcName = "deleteAttachmentByMimeTypeIdx";
    ResultSet resultSet = null;//from w  w  w  .ja v a  2 s  .co m
    try {
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_attchmnt_by_mimetypeidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtDeleteByMimeTypeIdx == null) {
            stmtDeleteByMimeTypeIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByMimeTypeIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByMimeTypeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByMimeTypeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByMimeTypeIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByMimeTypeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argMimeTypeId != null) {
            stmtDeleteByMimeTypeIdx.setInt(argIdx++, argMimeTypeId.intValue());
        } else {
            stmtDeleteByMimeTypeIdx.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        resultSet = stmtDeleteByMimeTypeIdx.executeQuery();
        if (resultSet.next()) {
            int deleteFlag = resultSet.getInt(1);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 record result set to be returned by delete, not 0 rows");
        }
    } 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.cfcore.v2_0.CFGenKbPgSql.CFGenKbPgSqlNmTokenFormatterTable.java

public void updateNmTokenFormatter(CFGenKbAuthorization Authorization, CFGenKbNmTokenFormatterBuff Buff) {
    final String S_ProcName = "updateNmTokenFormatter";
    ResultSet resultSet = null;//from  w  w  w .  j a va 2 s.  co m
    try {
        String ClassCode = Buff.getClassCode();
        long TenantId = Buff.getRequiredTenantId();
        long CartridgeId = Buff.getRequiredCartridgeId();
        int ItemId = Buff.getRequiredItemId();
        short RuleTypeId = Buff.getRequiredRuleTypeId();
        String Name = Buff.getRequiredName();
        short ToolSetId = Buff.getRequiredToolSetId();
        Short ScopeDefId = Buff.getOptionalScopeDefId();
        short GenDefId = Buff.getRequiredGenDefId();
        Integer GelExecutableId = Buff.getOptionalGelExecutableId();
        int Revision = Buff.getRequiredRevision();
        Connection cnx = schema.getCnx();
        String sql = "select * from " + schema.getLowerSchemaDbName()
                + ".sp_update_kbnmtokenfmt( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )";
        if (stmtUpdateByPKey == null) {
            stmtUpdateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtUpdateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtUpdateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtUpdateByPKey.setString(argIdx++, ClassCode);
        stmtUpdateByPKey.setLong(argIdx++, TenantId);
        stmtUpdateByPKey.setLong(argIdx++, CartridgeId);
        stmtUpdateByPKey.setInt(argIdx++, ItemId);
        stmtUpdateByPKey.setShort(argIdx++, RuleTypeId);
        stmtUpdateByPKey.setString(argIdx++, Name);
        stmtUpdateByPKey.setShort(argIdx++, ToolSetId);
        if (ScopeDefId != null) {
            stmtUpdateByPKey.setShort(argIdx++, ScopeDefId.shortValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        stmtUpdateByPKey.setShort(argIdx++, GenDefId);
        if (GelExecutableId != null) {
            stmtUpdateByPKey.setInt(argIdx++, GelExecutableId.intValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        resultSet = stmtUpdateByPKey.executeQuery();
        if (resultSet.next()) {
            CFGenKbNmTokenFormatterBuff updatedBuff = unpackNmTokenFormatterResultSetToBuff(resultSet);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
            Buff.setRequiredRuleTypeId(updatedBuff.getRequiredRuleTypeId());
            Buff.setRequiredName(updatedBuff.getRequiredName());
            Buff.setRequiredToolSetId(updatedBuff.getRequiredToolSetId());
            Buff.setOptionalScopeDefId(updatedBuff.getOptionalScopeDefId());
            Buff.setRequiredGenDefId(updatedBuff.getRequiredGenDefId());
            Buff.setOptionalGelExecutableId(updatedBuff.getOptionalGelExecutableId());
            Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected a single-record response, " + resultSet.getRow() + " rows selected");
        }
    } 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:com.concursive.connect.web.modules.documents.dao.FileItem.java

/**
 * Description of the Method//from  www.j a  v  a2 s  .  c om
 *
 * @param db          Description of the Parameter
 * @param newFolderId Description of the Parameter
 * @throws SQLException Description of the Exception
 */
public void updateFolderId(Connection db, int newFolderId) throws SQLException {
    if (id == -1) {
        throw new SQLException("ID not specified");
    }
    PreparedStatement pst = db
            .prepareStatement("UPDATE project_files " + "SET folder_id = ? " + "WHERE item_id = ?");
    int i = 0;
    if (newFolderId > 0) {
        pst.setInt(++i, newFolderId);
    } else {
        pst.setNull(++i, java.sql.Types.INTEGER);
    }
    pst.setInt(++i, id);
    int count = pst.executeUpdate();
    pst.close();
    if (count == 1) {
        if (newFolderId > 0) {
            folderId = newFolderId;
        } else {
            folderId = -1;
        }
    }
}

From source file:helma.objectmodel.db.NodeManager.java

/**
 *  Create a new Node from a ResultSet./*  www  . j a  va2  s . c  o m*/
 */
public Node createNode(DbMapping dbm, ResultSet rs, DbColumn[] columns, int offset)
        throws SQLException, IOException, ClassNotFoundException {
    HashMap propBuffer = new HashMap();
    String id = null;
    String name = null;
    String protoName = dbm.getTypeName();
    DbMapping dbmap = dbm;

    Node node = new Node(safe);

    for (int i = 0; i < columns.length; i++) {

        int columnNumber = i + 1 + offset;

        // set prototype?
        if (columns[i].isPrototypeField()) {
            String protoId = rs.getString(columnNumber);
            protoName = dbm.getPrototypeName(protoId);

            if (protoName != null) {
                dbmap = getDbMapping(protoName);

                if (dbmap == null) {
                    // invalid prototype name!
                    app.logError("No prototype defined for prototype mapping \"" + protoName
                            + "\" - Using default prototype \"" + dbm.getTypeName() + "\".");
                    dbmap = dbm;
                    protoName = dbmap.getTypeName();
                }
            }
        }

        // set id?
        if (columns[i].isIdField()) {
            id = rs.getString(columnNumber);
            // if id == null, the object doesn't actually exist - return null
            if (id == null) {
                return null;
            }
        }

        // set name?
        if (columns[i].isNameField()) {
            name = rs.getString(columnNumber);
        }

        Property newprop = new Property(node);

        switch (columns[i].getType()) {
        case Types.BIT:
        case Types.BOOLEAN:
            newprop.setBooleanValue(rs.getBoolean(columnNumber));

            break;

        case Types.TINYINT:
        case Types.BIGINT:
        case Types.SMALLINT:
        case Types.INTEGER:
            newprop.setIntegerValue(rs.getLong(columnNumber));

            break;

        case Types.REAL:
        case Types.FLOAT:
        case Types.DOUBLE:
            newprop.setFloatValue(rs.getDouble(columnNumber));

            break;

        case Types.DECIMAL:
        case Types.NUMERIC:

            BigDecimal num = rs.getBigDecimal(columnNumber);
            if (num == null) {
                break;
            }
            if (num.scale() > 0) {
                newprop.setFloatValue(num.doubleValue());
            } else {
                newprop.setIntegerValue(num.longValue());
            }

            break;

        case Types.VARBINARY:
        case Types.BINARY:
            newprop.setJavaObjectValue(rs.getBytes(columnNumber));

            break;

        case Types.BLOB:
        case Types.LONGVARBINARY: {
            InputStream in = rs.getBinaryStream(columnNumber);
            if (in == null) {
                break;
            }
            ByteArrayOutputStream bout = new ByteArrayOutputStream();
            byte[] buffer = new byte[2048];
            int read;
            while ((read = in.read(buffer)) > -1) {
                bout.write(buffer, 0, read);
            }
            newprop.setJavaObjectValue(bout.toByteArray());
        }

            break;

        case Types.LONGVARCHAR:
            try {
                newprop.setStringValue(rs.getString(columnNumber));
            } catch (SQLException x) {
                Reader in = rs.getCharacterStream(columnNumber);
                if (in == null) {
                    newprop.setStringValue(null);
                    break;
                }
                StringBuffer out = new StringBuffer();
                char[] buffer = new char[2048];
                int read;
                while ((read = in.read(buffer)) > -1) {
                    out.append(buffer, 0, read);
                }
                newprop.setStringValue(out.toString());
            }

            break;

        case Types.CHAR:
        case Types.VARCHAR:
        case Types.OTHER:
            newprop.setStringValue(rs.getString(columnNumber));

            break;

        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            newprop.setDateValue(rs.getTimestamp(columnNumber));

            break;

        case Types.NULL:
            newprop.setStringValue(null);

            break;

        case Types.CLOB:
            Clob cl = rs.getClob(columnNumber);
            if (cl == null) {
                newprop.setStringValue(null);
                break;
            }
            char[] c = new char[(int) cl.length()];
            Reader isr = cl.getCharacterStream();
            isr.read(c);
            newprop.setStringValue(String.copyValueOf(c));
            break;

        default:
            newprop.setStringValue(rs.getString(columnNumber));

            break;
        }

        if (rs.wasNull()) {
            newprop.setStringValue(null);
        }

        propBuffer.put(columns[i].getName(), newprop);

        // mark property as clean, since it's fresh from the db
        newprop.dirty = false;
    }

    if (id == null) {
        return null;
    } else {
        Transactor tx = Transactor.getInstance();
        if (tx != null) {
            // Check if the node is already registered with the transactor -
            // it may be in the process of being DELETED, but do return the
            // new node if the old one has been marked as INVALID.
            DbKey key = new DbKey(dbmap, id);
            Node dirtyNode = tx.getDirtyNode(key);
            if (dirtyNode != null && dirtyNode.getState() != Node.INVALID) {
                return dirtyNode;
            }
        }
    }

    Hashtable propMap = new Hashtable();
    DbColumn[] columns2 = dbmap.getColumns();
    for (int i = 0; i < columns2.length; i++) {
        Relation rel = columns2[i].getRelation();
        if (rel != null && rel.isPrimitiveOrReference()) {
            Property prop = (Property) propBuffer.get(columns2[i].getName());

            if (prop == null) {
                continue;
            }

            prop.setName(rel.propName);

            // if the property is a pointer to another node, change the property type to NODE
            if (rel.isReference() && rel.usesPrimaryKey()) {
                // FIXME: References to anything other than the primary key are not supported
                prop.convertToNodeReference(rel);
            }
            propMap.put(rel.propName, prop);
        }
    }

    node.init(dbmap, id, name, protoName, propMap);
    return node;
}

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

public void deleteAttachmentByMimeTypeIdx(CFCrmAuthorization Authorization, Integer argMimeTypeId) {
    final String S_ProcName = "deleteAttachmentByMimeTypeIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//w  w  w  .j  a  v  a 2 s  .c o  m
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "exec sp_delete_attchmnt_by_mimetypeidx ?, ?, ?, ?, ?" + ", " + "?";
        if (stmtDeleteByMimeTypeIdx == null) {
            stmtDeleteByMimeTypeIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByMimeTypeIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByMimeTypeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByMimeTypeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByMimeTypeIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByMimeTypeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argMimeTypeId != null) {
            stmtDeleteByMimeTypeIdx.setInt(argIdx++, argMimeTypeId.intValue());
        } else {
            stmtDeleteByMimeTypeIdx.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        Object stuff = null;
        boolean moreResults = stmtDeleteByMimeTypeIdx.execute();
        while (stuff == null) {
            try {
                moreResults = stmtDeleteByMimeTypeIdx.getMoreResults();
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            if (moreResults) {
                try {
                    stuff = stmtDeleteByMimeTypeIdx.getResultSet();
                } catch (SQLException e) {
                }
            } else if (-1 == stmtDeleteByMimeTypeIdx.getUpdateCount()) {
                break;
            }
        }
    } 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.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelModifierTable.java

public CFGenKbGelModifierBuff[] readBuffByRemainderIdx(CFGenKbAuthorization Authorization, long TenantId,
        long CartridgeId, Integer RemainderInstId) {
    final String S_ProcName = "readBuffByRemainderIdx";
    ResultSet resultSet = null;// w w w .j a  v a 2  s .c o m
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerSchemaDbName()
                + ".sp_read_gelmodifier_by_remainderidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?"
                + " )";
        if (stmtReadBuffByRemainderIdx == null) {
            stmtReadBuffByRemainderIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByRemainderIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByRemainderIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByRemainderIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByRemainderIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByRemainderIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByRemainderIdx.setLong(argIdx++, TenantId);
        stmtReadBuffByRemainderIdx.setLong(argIdx++, CartridgeId);
        if (RemainderInstId != null) {
            stmtReadBuffByRemainderIdx.setInt(argIdx++, RemainderInstId.intValue());
        } else {
            stmtReadBuffByRemainderIdx.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        try {
            resultSet = stmtReadBuffByRemainderIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        List<CFGenKbGelModifierBuff> buffList = new LinkedList<CFGenKbGelModifierBuff>();
        while ((resultSet != null) && resultSet.next()) {
            CFGenKbGelModifierBuff buff = unpackGelModifierResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        int idx = 0;
        CFGenKbGelModifierBuff[] retBuff = new CFGenKbGelModifierBuff[buffList.size()];
        Iterator<CFGenKbGelModifierBuff> 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.cfacc.v2_0.CFAccMSSql.CFAccMSSqlAttachmentTable.java

public void deleteAttachmentByMimeTypeIdx(CFAccAuthorization Authorization, Integer argMimeTypeId) {
    final String S_ProcName = "deleteAttachmentByMimeTypeIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from   www.  j a v a2  s  .  c  om*/
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "exec sp_delete_attchmnt_by_mimetypeidx ?, ?, ?, ?, ?" + ", " + "?";
        if (stmtDeleteByMimeTypeIdx == null) {
            stmtDeleteByMimeTypeIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByMimeTypeIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByMimeTypeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByMimeTypeIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByMimeTypeIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByMimeTypeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argMimeTypeId != null) {
            stmtDeleteByMimeTypeIdx.setInt(argIdx++, argMimeTypeId.intValue());
        } else {
            stmtDeleteByMimeTypeIdx.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        Object stuff = null;
        boolean moreResults = stmtDeleteByMimeTypeIdx.execute();
        while (stuff == null) {
            try {
                moreResults = stmtDeleteByMimeTypeIdx.getMoreResults();
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            if (moreResults) {
                try {
                    stuff = stmtDeleteByMimeTypeIdx.getResultSet();
                } catch (SQLException e) {
                }
            } else if (-1 == stmtDeleteByMimeTypeIdx.getUpdateCount()) {
                break;
            }
        }
    } 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:ca.sqlpower.sqlobject.TestSQLTable.java

/**
 * This tests inheriting a column at the end of the primary key list and
 * defining the inherited column to be a primary key does indeed set the
 * column to be a member of the primary key.
 *///from  w w  w. j  av a  2  s  .  c  o m
public void testInheritDefinesPK() throws Exception {
    SQLTable t2 = new SQLTable(table.getParentDatabase(), true);
    t2.setName("Another Test Table");
    SQLColumn newcol = new SQLColumn(t2, "newcol", Types.INTEGER, 10, 0);
    t2.addColumn(newcol, 0);
    t2.addToPK(newcol);
    assertTrue("Column should start in primary key", newcol.isPrimaryKey());

    List<SQLColumn> columns = new ArrayList<SQLColumn>(table.getColumns());

    //Defining the column to be a primary key
    table.inherit(table.getPkSize(), newcol, true, TransferStyles.COPY, true);

    List<SQLColumn> newColumns = new ArrayList<SQLColumn>(table.getColumns());
    newColumns.removeAll(columns);

    assertEquals(1, newColumns.size());
    SQLColumn copyCol = newColumns.get(0);
    assertTrue(copyCol.isPrimaryKey());
}