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:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxOracle.CFEnSyntaxOracleEnglishParseTable.java

public CFEnSyntaxEnglishParseBuff readDerivedByUNameIdx(CFEnSyntaxAuthorization Authorization, Long ScopeId,
        String Name) {//  w ww  .j  a v a2s  .  co m
    final String S_ProcName = "CFEnSyntaxOracleEnglishParseTable.readDerivedByUNameIdx() ";
    CFEnSyntaxEnglishParseBuff buff;
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }
    String classCode;
    ResultSet resultSet = null;
    CallableStatement stmtReadClassCodeByUNameIdx = null;
    try {
        Connection cnx = schema.getCnx();
        stmtReadClassCodeByUNameIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName()
                + ".rd_enparseccbyunameidx( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtReadClassCodeByUNameIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        stmtReadClassCodeByUNameIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByUNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadClassCodeByUNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadClassCodeByUNameIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadClassCodeByUNameIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (ScopeId != null) {
            stmtReadClassCodeByUNameIdx.setLong(argIdx++, ScopeId.longValue());
        } else {
            stmtReadClassCodeByUNameIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        stmtReadClassCodeByUNameIdx.setString(argIdx++, Name);
        stmtReadClassCodeByUNameIdx.execute();
        resultSet = (ResultSet) stmtReadClassCodeByUNameIdx.getObject(1);
        if (resultSet == null) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "rd_enparseccbyunameidx() did not return a result set");
        }
        try {
            if (resultSet.next()) {
                classCode = resultSet.getString(1);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
            } else {
                return (null);
            }
        } catch (SQLException e) {
            return (null);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtReadClassCodeByUNameIdx != null) {
            try {
                stmtReadClassCodeByUNameIdx.close();
            } catch (SQLException e) {
            }
            stmtReadClassCodeByUNameIdx = null;
        }
    }
    if (classCode.equals("ENPS")) {
        buff = readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENDS")) {
        buff = schema.getTableEnDiscourse().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENSN")) {
        buff = schema.getTableEnSentence().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENCL")) {
        buff = schema.getTableEnClause().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENPH")) {
        buff = schema.getTableEnPhrase().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENWD")) {
        buff = schema.getTableEnWord().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENPR")) {
        buff = schema.getTableEnPreposition().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENMP")) {
        buff = schema.getTableEnMorpheme().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENSJ")) {
        buff = schema.getTableEnSubject().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENOB")) {
        buff = schema.getTableEnObject().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENCM")) {
        buff = schema.getTableEnComplement().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENVL")) {
        buff = schema.getTableEnAdverbial().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENAD")) {
        buff = schema.getTableEnAdjective().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENTS")) {
        buff = schema.getTableEnTense().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENAX")) {
        buff = schema.getTableEnAuxiliary().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENCN")) {
        buff = schema.getTableEnConnective().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENDT")) {
        buff = schema.getTableEnDeterminer().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENHD")) {
        buff = schema.getTableEnHead().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("ENIN")) {
        buff = schema.getTableEnIntensifier().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else if (classCode.equals("EMOD")) {
        buff = schema.getTableEnModifier().readBuffByUNameIdx(Authorization, ScopeId, Name);
    } else {
        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                "Did not expect ClassCode \"" + classCode + "\"");
    }
    return (buff);
}

From source file:it.greenvulcano.gvesb.datahandling.dbo.DBOCallSP.java

/**
 * @see org.xml.sax.ContentHandler#endElement(java.lang.String,
 *      java.lang.String, java.lang.String)
 *///  w ww. j  a  v a 2  s  . c  o m
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
    if (ROW_NAME.equals(localName)) {
        if (!currCriticalError) {
            executeStatement();
        } else {
            rowDisc++;
            // aggiunta DiscardCause al dhr...
            String msg = currentXSLMessage;

            dhr.addDiscardCause(new DiscardCause(rowCounter, msg));

            resultMessage.append("Data error on row ").append(rowCounter).append(": ").append(msg);
            resultMessage.append("SQL Statement Informations:\n").append(sqlStatementInfo);
            resultMessage.append("Record parameters:\n").append(dumpCurrentRowFields());
            resultStatus = STATUS_PARTIAL;
        }
    } else if (COL_NAME.equals(localName)) {
        CallableStatement cs = (CallableStatement) sqlStatementInfo.getStatement();
        try {
            if (!outOnly) {
                colDataExpecting = false;
                String text = textBuffer.toString();
                if ((currentUUID != null) && (currentUUID.trim().length() > 0) && (text.length() == 0)) {
                    text = uuids.get(currentUUID);
                    if (text == null) {
                        text = currentUUID;
                    }
                }
                if (TIMESTAMP_TYPE.equals(currType) || DATE_TYPE.equals(currType)
                        || TIME_TYPE.equals(currType)) {
                    if (text.equals("")) {
                        if (TIMESTAMP_TYPE.equals(currType))
                            setNull(cs, Types.TIMESTAMP);
                        else if (DATE_TYPE.equals(currType))
                            setNull(cs, Types.DATE);
                        else
                            setNull(cs, Types.TIME);
                        currentRowFields.add(null);
                    } else {
                        dateFormatter.applyPattern(currDateFormat);
                        Date formattedDate = dateFormatter.parse(text);
                        if (TIMESTAMP_TYPE.equals(currType)) {
                            Timestamp ts = new Timestamp(formattedDate.getTime());
                            setTimestamp(cs, ts);
                            currentRowFields.add(ts);
                        } else if (DATE_TYPE.equals(currType)) {
                            java.sql.Date d = new java.sql.Date(formattedDate.getTime());
                            setDate(cs, d);
                            currentRowFields.add(d);
                        } else {
                            java.sql.Time t = new java.sql.Time(formattedDate.getTime());
                            setTime(cs, t);
                            currentRowFields.add(t);
                        }
                    }
                } else if (INTEGER_TYPE.equals(currType) || SMALLINT_TYPE.equals(currType)
                        || BIGINT_TYPE.equals(currType)) {
                    if (text.equals("")) {
                        if (INTEGER_TYPE.equals(currType))
                            setNull(cs, Types.INTEGER);
                        else if (SMALLINT_TYPE.equals(currType))
                            setNull(cs, Types.SMALLINT);
                        else
                            setNull(cs, Types.BIGINT);
                        currentRowFields.add(null);
                    } else {
                        if (INTEGER_TYPE.equals(currType))
                            setInt(cs, Integer.parseInt(text, 10));
                        else if (SMALLINT_TYPE.equals(currType))
                            setShort(cs, Short.parseShort(text, 10));
                        else
                            setLong(cs, Long.parseLong(text, 10));
                        currentRowFields.add(text);
                    }
                } else if (FLOAT_TYPE.equals(currType) || DOUBLE_TYPE.equals(currType)
                        || DECIMAL_TYPE.equals(currType) || NUMERIC_TYPE.equals(currType)) {
                    if (text.equals("")) {
                        if (DECIMAL_TYPE.equals(currType) || NUMERIC_TYPE.equals(currType))
                            setNull(cs, Types.NUMERIC);
                        else if (FLOAT_TYPE.equals(currType))
                            setNull(cs, Types.FLOAT);
                        else
                            setNull(cs, Types.DOUBLE);
                        currentRowFields.add(null);
                    } else {
                        DecimalFormatSymbols dfs = numberFormatter.getDecimalFormatSymbols();
                        dfs.setDecimalSeparator(currDecSeparator.charAt(0));
                        dfs.setGroupingSeparator(currGroupSeparator.charAt(0));
                        numberFormatter.setDecimalFormatSymbols(dfs);
                        numberFormatter.applyPattern(currNumberFormat);
                        boolean isBigDecimal = numberFormatter.isParseBigDecimal();
                        try {
                            numberFormatter.setParseBigDecimal(true);
                            BigDecimal formattedNumber = (BigDecimal) numberFormatter.parse(text);
                            if (DECIMAL_TYPE.equals(currType) || NUMERIC_TYPE.equals(currType)) {
                                setBigDecimal(cs, formattedNumber);
                                currentRowFields.add(formattedNumber);
                            } else if (FLOAT_TYPE.equals(currType)) {
                                setFloat(cs, formattedNumber.floatValue());
                                currentRowFields.add(formattedNumber.floatValue());
                            } else {
                                setDouble(cs, formattedNumber.doubleValue());
                                currentRowFields.add(formattedNumber.doubleValue());
                            }
                        } finally {
                            numberFormatter.setParseBigDecimal(isBigDecimal);
                        }
                    }
                } else if (LONG_STRING_TYPE.equals(currType) || LONG_NSTRING_TYPE.equals(currType)) {
                    if (text.equals("")) {
                        if (LONG_STRING_TYPE.equals(currType))
                            setNull(cs, Types.CLOB);
                        else
                            setNull(cs, Types.NCLOB);
                        currentRowFields.add(null);
                    } else {
                        if (LONG_STRING_TYPE.equals(currType)) {
                            setCharacterStream(cs, new StringReader(text));
                            currentRowFields.add(text);
                        } else {
                            setNCharacterStream(cs, new StringReader(text));
                            currentRowFields.add(text);
                        }
                    }
                } else if (BASE64_TYPE.equals(currType)) {
                    if (text.equals("")) {
                        setNull(cs, Types.BLOB);
                        currentRowFields.add(null);
                    } else {
                        byte[] data = text.getBytes();
                        data = Base64.getDecoder().decode(data);
                        ByteArrayInputStream bais = new ByteArrayInputStream(data);
                        setBinaryStream(cs, bais, data.length);
                        currentRowFields.add(text);
                    }
                } else if (BINARY_TYPE.equals(currType)) {
                    if (text.equals("")) {
                        setNull(cs, Types.BLOB);
                        currentRowFields.add(null);
                    } else {
                        byte[] data = text.getBytes();
                        ByteArrayInputStream bais = new ByteArrayInputStream(data);
                        setBinaryStream(cs, bais, data.length);
                        currentRowFields.add(text);
                    }
                } else if (BOOLEAN_TYPE.equals(currType)) {
                    if (text.equals("")) {
                        setNull(cs, Types.BOOLEAN);
                        currentRowFields.add(null);
                    } else {
                        setBoolean(cs, TextUtils.parseBoolean(text));
                        currentRowFields.add(text);
                    }
                } else if (XML_TYPE.equals(currType)) {
                    if (text.equals("")) {
                        setNull(cs, Types.SQLXML);
                        currentRowFields.add(null);
                    } else {
                        SQLXML xml = cs.getConnection().createSQLXML();
                        xml.setString(text);
                        setSQLXML(cs, xml);
                        currentRowFields.add(text);
                    }
                } else if (NSTRING_TYPE.equals(currType)) {
                    if (text.equals("")) {
                        setNull(cs, Types.NVARCHAR);
                        currentRowFields.add(null);
                    } else {
                        setNString(cs, text);
                        currentRowFields.add(text);
                    }
                } else {
                    if (text.equals("")) {
                        setNull(cs, Types.VARCHAR);
                        currentRowFields.add(null);
                    } else {
                        setString(cs, text);
                        currentRowFields.add(text);
                    }
                }
            } else {
                currentRowFields.add(currentUUID);
            }
        } catch (ParseException exc) {
            throw new SAXException(exc);
        } catch (SQLException exc) {
            OracleExceptionHandler.handleSQLException(exc);
            throw new SAXException(exc);
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlAccountTable.java

public void deleteAccountByRollupAcctIdx(CFAccAuthorization Authorization, Long argRollupTenantId,
        Long argRollupAccountId) {
    final String S_ProcName = "deleteAccountByRollupAcctIdx";
    ResultSet resultSet = null;//from w  ww. ja  v  a  2 s .  c om
    try {
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerSchemaDbName()
                + ".sp_delete_acct_by_rollupacctidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?"
                + " ) as DeletedFlag";
        if (stmtDeleteByRollupAcctIdx == null) {
            stmtDeleteByRollupAcctIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByRollupAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByRollupAcctIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByRollupAcctIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByRollupAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByRollupAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argRollupTenantId != null) {
            stmtDeleteByRollupAcctIdx.setLong(argIdx++, argRollupTenantId.longValue());
        } else {
            stmtDeleteByRollupAcctIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        if (argRollupAccountId != null) {
            stmtDeleteByRollupAcctIdx.setLong(argIdx++, argRollupAccountId.longValue());
        } else {
            stmtDeleteByRollupAcctIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        resultSet = stmtDeleteByRollupAcctIdx.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:com.draagon.meta.manager.db.driver.GenericSQLDriver.java

/**
 * Sets a specific value on a prepared statement
 *//*from  w ww .j a  va2 s  .  c  o  m*/
protected void setStatementValue(PreparedStatement s, MetaField f, int index, Object value)
        throws SQLException {
    int j = index;

    switch (f.getType()) {
    case MetaField.BOOLEAN: {
        if (value == null) {
            s.setNull(j, Types.BIT);
        } else if (value instanceof Boolean) {
            s.setBoolean(j, ((Boolean) value).booleanValue());
        } else {
            s.setBoolean(j, Boolean.valueOf(value.toString()).booleanValue());
        }
    }
        break;

    case MetaField.BYTE: {
        if (value == null) {
            s.setNull(j, Types.TINYINT);
        } else if (value instanceof Byte) {
            s.setByte(j, ((Byte) value).byteValue());
        } else {
            s.setByte(j, Byte.valueOf(value.toString()).byteValue());
        }
    }
        break;

    case MetaField.SHORT: {
        if (value == null) {
            s.setNull(j, Types.SMALLINT);
        } else if (value instanceof Short) {
            s.setShort(j, ((Short) value).shortValue());
        } else {
            s.setShort(j, Short.valueOf(value.toString()).shortValue());
        }
    }
        break;

    case MetaField.INT: {
        if (value == null) {
            s.setNull(j, Types.INTEGER);
        } else if (value instanceof Integer) {
            s.setInt(j, ((Integer) value).intValue());
        } else {
            s.setInt(j, Integer.valueOf(value.toString()).intValue());
        }
    }
        break;

    case MetaField.DATE: // NOTE DATE IS TREATED AS LONG!
    {
        if (value == null) {
            s.setNull(j, Types.TIMESTAMP);
        } else if (value instanceof java.util.Date) {
            s.setTimestamp(j, new Timestamp(((java.util.Date) value).getTime()));
        } else {
            s.setTimestamp(j, new Timestamp(Long.valueOf(value.toString()).longValue()));
        }
    }
        break;

    case MetaField.LONG: {
        if (value == null) {
            s.setNull(j, Types.BIGINT);
        } else if (value instanceof Long) {
            s.setLong(j, ((Long) value).longValue());
        } else {
            s.setLong(j, Long.valueOf(value.toString()).longValue());
        }
    }
        break;

    // WARNING:  This should not be a valid key
    case MetaField.FLOAT: {
        if (value == null) {
            s.setNull(j, Types.FLOAT);
        } else if (value instanceof Float) {
            s.setFloat(j, ((Float) value).floatValue());
        } else {
            s.setFloat(j, Float.valueOf(value.toString()).floatValue());
        }
    }
        break;

    // WARNING:  This should not be a valid key
    case MetaField.DOUBLE: {
        if (value == null) {
            s.setNull(j, Types.DOUBLE);
        } else if (value instanceof Double) {
            s.setDouble(j, ((Double) value).doubleValue());
        } else {
            s.setDouble(j, Double.valueOf(value.toString()).doubleValue());
        }
    }
        break;

    case MetaField.STRING:
        if (value == null) {
            s.setNull(j, Types.VARCHAR);
        } else {
            s.setString(j, value.toString());
        }
        break;

    case MetaField.OBJECT:
        //if ( value == null )
        //  s.setNull( j, Types.BLOB );
        //else
        s.setObject(j, value);
        break;
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWAccountTable.java

public void deleteAccountByRollupAcctIdx(CFAccAuthorization Authorization, Long argRollupTenantId,
        Long argRollupAccountId) {
    final String S_ProcName = "deleteAccountByRollupAcctIdx";
    ResultSet resultSet = null;/*  w  w  w  .  j  a v a2 s .com*/
    try {
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_acct_by_rollupacctidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?"
                + " )";
        if (stmtDeleteByRollupAcctIdx == null) {
            stmtDeleteByRollupAcctIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByRollupAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByRollupAcctIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByRollupAcctIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByRollupAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByRollupAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argRollupTenantId != null) {
            stmtDeleteByRollupAcctIdx.setLong(argIdx++, argRollupTenantId.longValue());
        } else {
            stmtDeleteByRollupAcctIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        if (argRollupAccountId != null) {
            stmtDeleteByRollupAcctIdx.setLong(argIdx++, argRollupAccountId.longValue());
        } else {
            stmtDeleteByRollupAcctIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        resultSet = stmtDeleteByRollupAcctIdx.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.cfacc.v2_0.CFAccMySql.CFAccMySqlAccountTable.java

public void deleteAccountByRollupAcctIdx(CFAccAuthorization Authorization, Long argRollupTenantId,
        Long argRollupAccountId) {
    final String S_ProcName = "deleteAccountByRollupAcctIdx";
    ResultSet resultSet = null;//from w  ww. j av a 2  s  .  com
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_acct_by_rollupacctidx( ?, ?, ?, ?, ?"
                + ", " + "?" + ", " + "?" + " )";
        if (stmtDeleteByRollupAcctIdx == null) {
            stmtDeleteByRollupAcctIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByRollupAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByRollupAcctIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByRollupAcctIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByRollupAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByRollupAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argRollupTenantId != null) {
            stmtDeleteByRollupAcctIdx.setLong(argIdx++, argRollupTenantId.longValue());
        } else {
            stmtDeleteByRollupAcctIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        if (argRollupAccountId != null) {
            stmtDeleteByRollupAcctIdx.setLong(argIdx++, argRollupAccountId.longValue());
        } else {
            stmtDeleteByRollupAcctIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        stmtDeleteByRollupAcctIdx.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: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 .jav a  2 s .c o 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:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleAccountConfigTable.java

public void updateAccountConfig(CFAccAuthorization Authorization, CFAccAccountConfigBuff Buff) {
    final String S_ProcName = "updateAccountConfig";
    ResultSet resultSet = null;//w  ww.  ja  v a  2  s .c o  m
    Connection cnx = schema.getCnx();
    CallableStatement stmtUpdateByPKey = null;
    List<CFAccAccountConfigBuff> buffList = new LinkedList<CFAccAccountConfigBuff>();
    try {
        long TenantId = Buff.getRequiredTenantId();
        short DefaultCurrencyId = Buff.getRequiredDefaultCurrencyId();
        Long CustContactListTenantId = Buff.getOptionalCustContactListTenantId();
        Long CustContactListId = Buff.getOptionalCustContactListId();
        Long EmpContactListTenantId = Buff.getOptionalEmpContactListTenantId();
        Long EmpContactListId = Buff.getOptionalEmpContactListId();
        Long VendContactListTenantId = Buff.getOptionalVendContactListTenantId();
        Long VendContactListId = Buff.getOptionalVendContactListId();
        int Revision = Buff.getRequiredRevision();
        stmtUpdateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName()
                + ".upd_acct_cfg( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "? ); end;");
        int argIdx = 1;
        stmtUpdateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, "ACFG");
        stmtUpdateByPKey.setLong(argIdx++, TenantId);
        stmtUpdateByPKey.setShort(argIdx++, DefaultCurrencyId);
        if (CustContactListTenantId != null) {
            stmtUpdateByPKey.setLong(argIdx++, CustContactListTenantId.longValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        if (CustContactListId != null) {
            stmtUpdateByPKey.setLong(argIdx++, CustContactListId.longValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        if (EmpContactListTenantId != null) {
            stmtUpdateByPKey.setLong(argIdx++, EmpContactListTenantId.longValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        if (EmpContactListId != null) {
            stmtUpdateByPKey.setLong(argIdx++, EmpContactListId.longValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        if (VendContactListTenantId != null) {
            stmtUpdateByPKey.setLong(argIdx++, VendContactListTenantId.longValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        if (VendContactListId != null) {
            stmtUpdateByPKey.setLong(argIdx++, VendContactListId.longValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        stmtUpdateByPKey.execute();
        resultSet = (ResultSet) stmtUpdateByPKey.getObject(1);
        if (resultSet != null) {
            try {
                if (resultSet.next()) {
                    CFAccAccountConfigBuff updatedBuff = unpackAccountConfigResultSetToBuff(resultSet);
                    if (resultSet.next()) {
                        resultSet.last();
                        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                                "Did not expect multi-record response, " + resultSet.getRow()
                                        + " rows selected");
                    }
                    Buff.setRequiredDefaultCurrencyId(updatedBuff.getRequiredDefaultCurrencyId());
                    Buff.setOptionalCustContactListTenantId(updatedBuff.getOptionalCustContactListTenantId());
                    Buff.setOptionalCustContactListId(updatedBuff.getOptionalCustContactListId());
                    Buff.setOptionalEmpContactListTenantId(updatedBuff.getOptionalEmpContactListTenantId());
                    Buff.setOptionalEmpContactListId(updatedBuff.getOptionalEmpContactListId());
                    Buff.setOptionalVendContactListTenantId(updatedBuff.getOptionalVendContactListTenantId());
                    Buff.setOptionalVendContactListId(updatedBuff.getOptionalVendContactListId());
                    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().newRuntimeException(getClass(), S_ProcName,
                        "upd_acct_cfg() did not return a valid result cursor");
            } finally {
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    }
                    resultSet = null;
                }
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "upd_acct_cfg() did not return a result cursor");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtUpdateByPKey != null) {
            try {
                stmtUpdateByPKey.close();
            } catch (SQLException e) {
            }
            stmtUpdateByPKey = null;
        }
    }
}

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

public void deleteAccountByRollupAcctIdx(CFAccAuthorization Authorization, Long argRollupTenantId,
        Long argRollupAccountId) {
    final String S_ProcName = "deleteAccountByRollupAcctIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from   w w w  . j  a va  2s  .co m*/
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "exec sp_delete_acct_by_rollupacctidx ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?";
        if (stmtDeleteByRollupAcctIdx == null) {
            stmtDeleteByRollupAcctIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByRollupAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByRollupAcctIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByRollupAcctIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByRollupAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByRollupAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (argRollupTenantId != null) {
            stmtDeleteByRollupAcctIdx.setLong(argIdx++, argRollupTenantId.longValue());
        } else {
            stmtDeleteByRollupAcctIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        if (argRollupAccountId != null) {
            stmtDeleteByRollupAcctIdx.setLong(argIdx++, argRollupAccountId.longValue());
        } else {
            stmtDeleteByRollupAcctIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        Object stuff = null;
        boolean moreResults = stmtDeleteByRollupAcctIdx.execute();
        while (stuff == null) {
            try {
                moreResults = stmtDeleteByRollupAcctIdx.getMoreResults();
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            if (moreResults) {
                try {
                    stuff = stmtDeleteByRollupAcctIdx.getResultSet();
                } catch (SQLException e) {
                }
            } else if (-1 == stmtDeleteByRollupAcctIdx.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.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWAccountEntryTable.java

public CFAccAccountEntryBuff[] readBuffByXfrAcctIdx(CFAccAuthorization Authorization, Long TransferTenantId,
        Long TransferAccountId) {
    final String S_ProcName = "readBuffByXfrAcctIdx";
    ResultSet resultSet = null;//w  w  w .  j ava 2  s  . c  o  m
    try {
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_read_ac_entry_by_xfracctidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?"
                + " )";
        if (stmtReadBuffByXfrAcctIdx == null) {
            stmtReadBuffByXfrAcctIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByXfrAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByXfrAcctIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByXfrAcctIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByXfrAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByXfrAcctIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        if (TransferTenantId != null) {
            stmtReadBuffByXfrAcctIdx.setLong(argIdx++, TransferTenantId.longValue());
        } else {
            stmtReadBuffByXfrAcctIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        if (TransferAccountId != null) {
            stmtReadBuffByXfrAcctIdx.setLong(argIdx++, TransferAccountId.longValue());
        } else {
            stmtReadBuffByXfrAcctIdx.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        resultSet = stmtReadBuffByXfrAcctIdx.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;
        }
    }
}