Example usage for java.sql Types SMALLINT

List of usage examples for java.sql Types SMALLINT

Introduction

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

Prototype

int SMALLINT

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

Click Source Link

Document

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

Usage

From source file:com.feedzai.commons.sql.abstraction.engine.AbstractDatabaseEngine.java

/**
 * Maps the database type to {@link DbColumnType}. If there's no mapping a {@link DbColumnType#UNMAPPED} is returned.
 *
 * @param type The SQL type from {@link java.sql.Types}.
 * @return The {@link DbColumnType}.//  w  w w.  j a  va2  s .co  m
 */
protected DbColumnType toPdbType(final int type) {
    switch (type) {
    case Types.ARRAY:
        return DbColumnType.UNMAPPED;
    case Types.BIGINT:
        return DbColumnType.LONG;
    case Types.BINARY:
        return DbColumnType.BLOB;
    case Types.BIT:
        return DbColumnType.BOOLEAN;
    case Types.BLOB:
        return DbColumnType.BLOB;
    case Types.BOOLEAN:
        return DbColumnType.BOOLEAN;
    case Types.CHAR:
        return DbColumnType.STRING;
    case Types.CLOB:
        return DbColumnType.STRING;
    case Types.DATALINK:
        return DbColumnType.UNMAPPED;
    case Types.DATE:
        return DbColumnType.UNMAPPED;
    case Types.DECIMAL:
        return DbColumnType.DOUBLE;
    case Types.DISTINCT:
        return DbColumnType.UNMAPPED;
    case Types.DOUBLE:
        return DbColumnType.DOUBLE;
    case Types.FLOAT:
        return DbColumnType.DOUBLE;
    case Types.INTEGER:
        return DbColumnType.INT;
    case Types.JAVA_OBJECT:
        return DbColumnType.BLOB;
    case Types.LONGNVARCHAR:
        return DbColumnType.STRING;
    case Types.LONGVARBINARY:
        return DbColumnType.BLOB;
    case Types.LONGVARCHAR:
        return DbColumnType.STRING;
    case Types.NCHAR:
        return DbColumnType.STRING;
    case Types.NCLOB:
        return DbColumnType.STRING;
    case Types.NULL:
        return DbColumnType.UNMAPPED;
    case Types.NUMERIC:
        return DbColumnType.DOUBLE;
    case Types.NVARCHAR:
        return DbColumnType.STRING;
    case Types.OTHER:
        return DbColumnType.UNMAPPED;
    case Types.REAL:
        return DbColumnType.DOUBLE;
    case Types.REF:
        return DbColumnType.UNMAPPED;
    case Types.ROWID:
        return DbColumnType.STRING;
    case Types.SMALLINT:
        return DbColumnType.INT;
    case Types.SQLXML:
        return DbColumnType.STRING;
    case Types.STRUCT:
        return DbColumnType.UNMAPPED;
    case Types.TIME:
        return DbColumnType.UNMAPPED;
    case Types.TIMESTAMP:
        return DbColumnType.LONG;
    case Types.TINYINT:
        return DbColumnType.INT;
    case Types.VARBINARY:
        return DbColumnType.BLOB;
    case Types.VARCHAR:
        return DbColumnType.STRING;
    default:
        return DbColumnType.UNMAPPED;
    }
}

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

/**
 *  Create a new Node from a ResultSet./*from ww  w. j a  va 2 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.cfacc.v2_0.CFAccOracle.CFAccOracleContactURLTable.java

public void deleteContactURLByProtocolIdx(CFAccAuthorization Authorization, Short argURLProtocolId) {
    final String S_ProcName = "deleteContactURLByProtocolIdx";
    ResultSet resultSet = null;//from  ww  w .  j a  v  a2  s  . c o  m
    try {
        Connection cnx = schema.getCnx();
        String sql = "begin call " + schema.getLowerSchemaDbName() + ".dl_ctcurlbyprotocolidx( ?, ?, ?, ?, ?"
                + ", " + "?" + " ); end";
        if (stmtDeleteByProtocolIdx == null) {
            stmtDeleteByProtocolIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByProtocolIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByProtocolIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByProtocolIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByProtocolIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByProtocolIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argURLProtocolId != null) {
            stmtDeleteByProtocolIdx.setShort(argIdx++, argURLProtocolId.shortValue());
        } else {
            stmtDeleteByProtocolIdx.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        int rowsUpdated = stmtDeleteByProtocolIdx.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.CFAccDb2LUW.CFAccDb2LUWAccountEntryTable.java

public CFAccAccountEntryBuff[] readBuffByDrCcyIdx(CFAccAuthorization Authorization, Short DebitCurrencyId) {
    final String S_ProcName = "readBuffByDrCcyIdx";
    ResultSet resultSet = null;//from  ww w . ja  va2 s .  c  o  m
    try {
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_read_ac_entry_by_drccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtReadBuffByDrCcyIdx == null) {
            stmtReadBuffByDrCcyIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByDrCcyIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByDrCcyIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (DebitCurrencyId != null) {
            stmtReadBuffByDrCcyIdx.setShort(argIdx++, DebitCurrencyId.shortValue());
        } else {
            stmtReadBuffByDrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        resultSet = stmtReadBuffByDrCcyIdx.executeQuery();
        List<CFAccAccountEntryBuff> buffList = new LinkedList<CFAccAccountEntryBuff>();
        while (resultSet.next()) {
            CFAccAccountEntryBuff buff = unpackAccountEntryResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        int idx = 0;
        CFAccAccountEntryBuff[] retBuff = new CFAccAccountEntryBuff[buffList.size()];
        Iterator<CFAccAccountEntryBuff> 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.cfcrm.v2_1.CFCrmMySql.CFCrmMySqlAddressTable.java

public void deleteAddressByCountryIdx(CFCrmAuthorization Authorization, Short argCountryId) {
    final String S_ProcName = "deleteAddressByCountryIdx";
    ResultSet resultSet = null;/* w w w .  java  2 s . c  o m*/
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_delete_address_by_countryidx( ?, ?, ?, ?, ?"
                + ", " + "?" + " )";
        if (stmtDeleteByCountryIdx == null) {
            stmtDeleteByCountryIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByCountryIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByCountryIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argCountryId != null) {
            stmtDeleteByCountryIdx.setShort(argIdx++, argCountryId.shortValue());
        } else {
            stmtDeleteByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        stmtDeleteByCountryIdx.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.CFAccPgSqlAccountEntryTable.java

public CFAccAccountEntryBuff[] readBuffByDrCcyIdx(CFAccAuthorization Authorization, Short DebitCurrencyId) {
    final String S_ProcName = "readBuffByDrCcyIdx";
    ResultSet resultSet = null;//from   w ww.  j  a  v  a2  s.  c  om
    try {
        Connection cnx = schema.getCnx();
        String sql = "SELECT * FROM " + schema.getLowerSchemaDbName()
                + ".sp_read_ac_entry_by_drccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtReadBuffByDrCcyIdx == null) {
            stmtReadBuffByDrCcyIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByDrCcyIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByDrCcyIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (DebitCurrencyId != null) {
            stmtReadBuffByDrCcyIdx.setShort(argIdx++, DebitCurrencyId.shortValue());
        } else {
            stmtReadBuffByDrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        resultSet = stmtReadBuffByDrCcyIdx.executeQuery();
        List<CFAccAccountEntryBuff> buffList = new LinkedList<CFAccAccountEntryBuff>();
        while (resultSet.next()) {
            CFAccAccountEntryBuff buff = unpackAccountEntryResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        int idx = 0;
        CFAccAccountEntryBuff[] retBuff = new CFAccAccountEntryBuff[buffList.size()];
        Iterator<CFAccAccountEntryBuff> 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.cfcrm.v2_0.CFCrmDb2LUW.CFCrmDb2LUWAddressTable.java

public void deleteAddressByCountryIdx(CFCrmAuthorization Authorization, Short argCountryId) {
    final String S_ProcName = "deleteAddressByCountryIdx";
    ResultSet resultSet = null;/*  w ww .j  a  v a 2 s . com*/
    try {
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_address_by_countryidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtDeleteByCountryIdx == null) {
            stmtDeleteByCountryIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByCountryIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByCountryIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argCountryId != null) {
            stmtDeleteByCountryIdx.setShort(argIdx++, argCountryId.shortValue());
        } else {
            stmtDeleteByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        resultSet = stmtDeleteByCountryIdx.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.cfcrm.v2_1.CFCrmMySql.CFCrmMySqlContactTable.java

public void deleteContactByTimezoneIdx(CFCrmAuthorization Authorization, Short argISOTimezoneId) {
    final String S_ProcName = "deleteContactByTimezoneIdx";
    ResultSet resultSet = null;/*  ww w  .ja va 2s. c o  m*/
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName()
                + ".sp_delete_contact_by_timezoneidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtDeleteByTimezoneIdx == null) {
            stmtDeleteByTimezoneIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByTimezoneIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByTimezoneIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByTimezoneIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByTimezoneIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByTimezoneIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argISOTimezoneId != null) {
            stmtDeleteByTimezoneIdx.setShort(argIdx++, argISOTimezoneId.shortValue());
        } else {
            stmtDeleteByTimezoneIdx.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        stmtDeleteByTimezoneIdx.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.CFAccMySql.CFAccMySqlAddressTable.java

public void deleteAddressByCountryIdx(CFAccAuthorization Authorization, Short argCountryId) {
    final String S_ProcName = "deleteAddressByCountryIdx";
    ResultSet resultSet = null;//w ww . j ava  2  s.  co m
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_address_by_countryidx( ?, ?, ?, ?, ?"
                + ", " + "?" + " )";
        if (stmtDeleteByCountryIdx == null) {
            stmtDeleteByCountryIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByCountryIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByCountryIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argCountryId != null) {
            stmtDeleteByCountryIdx.setShort(argIdx++, argCountryId.shortValue());
        } else {
            stmtDeleteByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        stmtDeleteByCountryIdx.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.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWContactTable.java

public void deleteContactByTimezoneIdx(CFCrmAuthorization Authorization, Short argISOTimezoneId) {
    final String S_ProcName = "deleteContactByTimezoneIdx";
    ResultSet resultSet = null;/*  w  w w.ja v a2  s.c  om*/
    try {
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_contact_by_timezoneidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtDeleteByTimezoneIdx == null) {
            stmtDeleteByTimezoneIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByTimezoneIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByTimezoneIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByTimezoneIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByTimezoneIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByTimezoneIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argISOTimezoneId != null) {
            stmtDeleteByTimezoneIdx.setShort(argIdx++, argISOTimezoneId.shortValue());
        } else {
            stmtDeleteByTimezoneIdx.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        resultSet = stmtDeleteByTimezoneIdx.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;
        }
    }
}