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.cfinternet.v2_1.CFInternetSybase.CFInternetSybaseClusterTable.java

public int nextSecGroupIdGen(CFInternetAuthorization Authorization, CFInternetClusterPKey PKey) {
    final String S_ProcName = "nextSecGroupIdGen";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }//w w w. j  a  v a  2s  . com
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextSecGroupIdGen = null;
    try {
        String sql = "{ call sp_next_secgroupidgen( ?" + ", " + "?" + " ) }";
        stmtSelectNextSecGroupIdGen = cnx.prepareCall(sql);
        int argIdx = 1;
        stmtSelectNextSecGroupIdGen.registerOutParameter(argIdx++, java.sql.Types.INTEGER);
        stmtSelectNextSecGroupIdGen.setLong(argIdx++, Id);
        stmtSelectNextSecGroupIdGen.execute();
        int nextId = stmtSelectNextSecGroupIdGen.getInt(1);
        return (nextId);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSelectNextSecGroupIdGen != null) {
            try {
                stmtSelectNextSecGroupIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextSecGroupIdGen = null;
        }
    }
}

From source file:com.act.lcms.db.model.PregrowthWell.java

protected void bindInsertOrUpdateParameters(PreparedStatement stmt, Integer plateId, Integer plateRow,
        Integer plateColumn, String sourcePlate, String sourceWell, String msid, String composition,
        String note, Integer growth) throws SQLException {
    stmt.setInt(DB_FIELD.PLATE_ID.getInsertUpdateOffset(), plateId);
    stmt.setInt(DB_FIELD.PLATE_ROW.getInsertUpdateOffset(), plateRow);
    stmt.setInt(DB_FIELD.PLATE_COLUMN.getInsertUpdateOffset(), plateColumn);
    stmt.setString(DB_FIELD.SOURCE_PLATE.getInsertUpdateOffset(), sourcePlate);
    stmt.setString(DB_FIELD.SOURCE_WELL.getInsertUpdateOffset(), sourceWell);
    stmt.setString(DB_FIELD.MSID.getInsertUpdateOffset(), msid);
    stmt.setString(DB_FIELD.COMPOSITION.getInsertUpdateOffset(), composition);
    stmt.setString(DB_FIELD.NOTE.getInsertUpdateOffset(), note);
    if (growth == null) {
        stmt.setNull(DB_FIELD.GROWTH.getInsertUpdateOffset(), Types.INTEGER);
    } else {//from  w ww  . ja  va  2  s  . c om
        stmt.setInt(DB_FIELD.GROWTH.getInsertUpdateOffset(), growth);
    }
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelPopTable.java

public void createGelPop(CFGenKbAuthorization Authorization, CFGenKbGelPopBuff Buff) {
    final String S_ProcName = "createGelPop";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from www . ja  v a 2s .  c  om
    ResultSet resultSet = null;
    try {
        String ClassCode = Buff.getClassCode();
        long TenantId = Buff.getRequiredTenantId();
        long CartridgeId = Buff.getRequiredCartridgeId();
        Integer CallerId = Buff.getOptionalCallerId();
        Integer PrevId = Buff.getOptionalPrevId();
        Integer NextId = Buff.getOptionalNextId();
        String SourceText = Buff.getRequiredSourceText();
        String GoalTypeName = Buff.getRequiredGoalTypeName();
        Integer RemainderInstId = Buff.getOptionalRemainderInstId();
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerSchemaDbName() + ".sp_create_gelpop( ?, ?, ?, ?, ?, ?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                + " )";
        if (stmtCreateByPKey == null) {
            stmtCreateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtCreateByPKey.setString(argIdx++, ClassCode);
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setLong(argIdx++, CartridgeId);
        if (CallerId != null) {
            stmtCreateByPKey.setInt(argIdx++, CallerId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        if (PrevId != null) {
            stmtCreateByPKey.setInt(argIdx++, PrevId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        if (NextId != null) {
            stmtCreateByPKey.setInt(argIdx++, NextId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        stmtCreateByPKey.setString(argIdx++, SourceText);
        stmtCreateByPKey.setString(argIdx++, GoalTypeName);
        if (RemainderInstId != null) {
            stmtCreateByPKey.setInt(argIdx++, RemainderInstId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        try {
            resultSet = stmtCreateByPKey.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFGenKbGelPopBuff createdBuff = unpackGelPopResultSetToBuff(resultSet);
            if ((resultSet != null) && resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredCartridgeId(createdBuff.getRequiredCartridgeId());
            Buff.setRequiredGelInstId(createdBuff.getRequiredGelInstId());
            Buff.setOptionalCallerId(createdBuff.getOptionalCallerId());
            Buff.setOptionalPrevId(createdBuff.getOptionalPrevId());
            Buff.setOptionalNextId(createdBuff.getOptionalNextId());
            Buff.setRequiredSourceText(createdBuff.getRequiredSourceText());
            Buff.setRequiredRevision(createdBuff.getRequiredRevision());
            Buff.setRequiredGoalTypeName(createdBuff.getRequiredGoalTypeName());
            Buff.setOptionalRemainderInstId(createdBuff.getOptionalRemainderInstId());
        } 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:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelReferenceTable.java

public void createGelReference(CFGenKbAuthorization Authorization, CFGenKbGelReferenceBuff Buff) {
    final String S_ProcName = "createGelReference";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from w  ww  .  j a va2s.  c  o m*/
    ResultSet resultSet = null;
    try {
        String ClassCode = Buff.getClassCode();
        long TenantId = Buff.getRequiredTenantId();
        long CartridgeId = Buff.getRequiredCartridgeId();
        Integer CallerId = Buff.getOptionalCallerId();
        Integer PrevId = Buff.getOptionalPrevId();
        Integer NextId = Buff.getOptionalNextId();
        String SourceText = Buff.getRequiredSourceText();
        String ReferenceName = Buff.getRequiredReferenceName();
        Integer RemainderInstId = Buff.getOptionalRemainderInstId();
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerSchemaDbName() + ".sp_create_gelrefer( ?, ?, ?, ?, ?, ?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                + " )";
        if (stmtCreateByPKey == null) {
            stmtCreateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtCreateByPKey.setString(argIdx++, ClassCode);
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setLong(argIdx++, CartridgeId);
        if (CallerId != null) {
            stmtCreateByPKey.setInt(argIdx++, CallerId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        if (PrevId != null) {
            stmtCreateByPKey.setInt(argIdx++, PrevId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        if (NextId != null) {
            stmtCreateByPKey.setInt(argIdx++, NextId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        stmtCreateByPKey.setString(argIdx++, SourceText);
        stmtCreateByPKey.setString(argIdx++, ReferenceName);
        if (RemainderInstId != null) {
            stmtCreateByPKey.setInt(argIdx++, RemainderInstId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        try {
            resultSet = stmtCreateByPKey.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFGenKbGelReferenceBuff createdBuff = unpackGelReferenceResultSetToBuff(resultSet);
            if ((resultSet != null) && resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredCartridgeId(createdBuff.getRequiredCartridgeId());
            Buff.setRequiredGelInstId(createdBuff.getRequiredGelInstId());
            Buff.setOptionalCallerId(createdBuff.getOptionalCallerId());
            Buff.setOptionalPrevId(createdBuff.getOptionalPrevId());
            Buff.setOptionalNextId(createdBuff.getOptionalNextId());
            Buff.setRequiredSourceText(createdBuff.getRequiredSourceText());
            Buff.setRequiredRevision(createdBuff.getRequiredRevision());
            Buff.setRequiredReferenceName(createdBuff.getRequiredReferenceName());
            Buff.setOptionalRemainderInstId(createdBuff.getOptionalRemainderInstId());
        } 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:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelPrefixLineTable.java

public void createGelPrefixLine(CFGenKbAuthorization Authorization, CFGenKbGelPrefixLineBuff Buff) {
    final String S_ProcName = "createGelPrefixLine";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*  w ww .j  a  va 2  s  . c o  m*/
    ResultSet resultSet = null;
    try {
        String ClassCode = Buff.getClassCode();
        long TenantId = Buff.getRequiredTenantId();
        long CartridgeId = Buff.getRequiredCartridgeId();
        Integer CallerId = Buff.getOptionalCallerId();
        Integer PrevId = Buff.getOptionalPrevId();
        Integer NextId = Buff.getOptionalNextId();
        String SourceText = Buff.getRequiredSourceText();
        String PrefixName = Buff.getRequiredPrefixName();
        Integer RemainderInstId = Buff.getOptionalRemainderInstId();
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerSchemaDbName() + ".sp_create_gelprefix( ?, ?, ?, ?, ?, ?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                + " )";
        if (stmtCreateByPKey == null) {
            stmtCreateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtCreateByPKey.setString(argIdx++, ClassCode);
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setLong(argIdx++, CartridgeId);
        if (CallerId != null) {
            stmtCreateByPKey.setInt(argIdx++, CallerId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        if (PrevId != null) {
            stmtCreateByPKey.setInt(argIdx++, PrevId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        if (NextId != null) {
            stmtCreateByPKey.setInt(argIdx++, NextId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        stmtCreateByPKey.setString(argIdx++, SourceText);
        stmtCreateByPKey.setString(argIdx++, PrefixName);
        if (RemainderInstId != null) {
            stmtCreateByPKey.setInt(argIdx++, RemainderInstId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        try {
            resultSet = stmtCreateByPKey.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFGenKbGelPrefixLineBuff createdBuff = unpackGelPrefixLineResultSetToBuff(resultSet);
            if ((resultSet != null) && resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredCartridgeId(createdBuff.getRequiredCartridgeId());
            Buff.setRequiredGelInstId(createdBuff.getRequiredGelInstId());
            Buff.setOptionalCallerId(createdBuff.getOptionalCallerId());
            Buff.setOptionalPrevId(createdBuff.getOptionalPrevId());
            Buff.setOptionalNextId(createdBuff.getOptionalNextId());
            Buff.setRequiredSourceText(createdBuff.getRequiredSourceText());
            Buff.setRequiredRevision(createdBuff.getRequiredRevision());
            Buff.setRequiredPrefixName(createdBuff.getRequiredPrefixName());
            Buff.setOptionalRemainderInstId(createdBuff.getOptionalRemainderInstId());
        } 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:it.greenvulcano.gvesb.datahandling.dbo.utils.ExtendedRowSetBuilder.java

public int build(Document doc, String id, ResultSet rs, Set<Integer> keyField,
        Map<String, FieldFormatter> fieldNameToFormatter, Map<String, FieldFormatter> fieldIdToFormatter)
        throws Exception {
    if (rs == null) {
        return 0;
    }/* w ww  .ja va 2  s.  co  m*/
    int rowCounter = 0;
    Element docRoot = doc.getDocumentElement();
    ResultSetMetaData metadata = rs.getMetaData();
    buildFormatterAndNamesArray(metadata, fieldNameToFormatter, fieldIdToFormatter);

    boolean noKey = ((keyField == null) || keyField.isEmpty());
    boolean isKeyCol = false;

    boolean isNull = false;
    Element data = null;
    Element row = null;
    Element col = null;
    Text text = null;
    String textVal = null;
    String precKey = null;
    String colKey = null;
    Map<String, Element> keyCols = new TreeMap<String, Element>();
    while (rs.next()) {
        if (rowCounter % 10 == 0) {
            ThreadUtils.checkInterrupted(getClass().getSimpleName(), name, logger);
        }
        row = parser.createElementNS(doc, AbstractDBO.ROW_NAME, NS);

        parser.setAttribute(row, AbstractDBO.ID_NAME, id);
        for (int j = 1; j <= metadata.getColumnCount(); j++) {
            FieldFormatter fF = fFormatters[j];
            String colName = colNames[j];

            isKeyCol = (!noKey && keyField.contains(new Integer(j)));
            isNull = false;
            col = parser.createElementNS(doc, colName, NS);
            if (isKeyCol) {
                parser.setAttribute(col, AbstractDBO.ID_NAME, String.valueOf(j));
            }
            switch (metadata.getColumnType(j)) {
            case Types.DATE:
            case Types.TIME:
            case Types.TIMESTAMP: {
                parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.TIMESTAMP_TYPE);
                Timestamp dateVal = rs.getTimestamp(j);
                isNull = dateVal == null;
                parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull));
                if (isNull) {
                    parser.setAttribute(col, AbstractDBO.FORMAT_NAME, AbstractDBO.DEFAULT_DATE_FORMAT);
                    textVal = "";
                } else {
                    if (fF != null) {
                        parser.setAttribute(col, AbstractDBO.FORMAT_NAME, fF.getDateFormat());
                        textVal = fF.formatDate(dateVal);
                    } else {
                        parser.setAttribute(col, AbstractDBO.FORMAT_NAME, AbstractDBO.DEFAULT_DATE_FORMAT);
                        textVal = dateFormatter.format(dateVal);
                    }
                }
            }
                break;
            case Types.DOUBLE:
            case Types.FLOAT:
            case Types.REAL: {
                parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.FLOAT_TYPE);
                float numVal = rs.getFloat(j);
                parser.setAttribute(col, AbstractDBO.NULL_NAME, "false");
                if (fF != null) {
                    parser.setAttribute(col, AbstractDBO.FORMAT_NAME, fF.getNumberFormat());
                    parser.setAttribute(col, AbstractDBO.GRP_SEPARATOR_NAME, fF.getGroupSeparator());
                    parser.setAttribute(col, AbstractDBO.DEC_SEPARATOR_NAME, fF.getDecSeparator());
                    textVal = fF.formatNumber(numVal);
                } else {
                    parser.setAttribute(col, AbstractDBO.FORMAT_NAME, numberFormat);
                    parser.setAttribute(col, AbstractDBO.GRP_SEPARATOR_NAME, groupSeparator);
                    parser.setAttribute(col, AbstractDBO.DEC_SEPARATOR_NAME, decSeparator);
                    textVal = numberFormatter.format(numVal);
                }
            }
                break;
            case Types.BIGINT:
            case Types.INTEGER:
            case Types.NUMERIC:
            case Types.SMALLINT:
            case Types.TINYINT: {
                BigDecimal bigdecimal = rs.getBigDecimal(j);
                isNull = bigdecimal == null;
                parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull));
                if (isNull) {
                    if (metadata.getScale(j) > 0) {
                        parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.FLOAT_TYPE);
                    } else {
                        parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.NUMERIC_TYPE);
                    }
                    textVal = "";
                } else {
                    if (fF != null) {
                        parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.FLOAT_TYPE);
                        parser.setAttribute(col, AbstractDBO.FORMAT_NAME, fF.getNumberFormat());
                        parser.setAttribute(col, AbstractDBO.GRP_SEPARATOR_NAME, fF.getGroupSeparator());
                        parser.setAttribute(col, AbstractDBO.DEC_SEPARATOR_NAME, fF.getDecSeparator());
                        textVal = fF.formatNumber(bigdecimal);
                    } else if (metadata.getScale(j) > 0) {
                        parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.FLOAT_TYPE);
                        parser.setAttribute(col, AbstractDBO.FORMAT_NAME, numberFormat);
                        parser.setAttribute(col, AbstractDBO.GRP_SEPARATOR_NAME, groupSeparator);
                        parser.setAttribute(col, AbstractDBO.DEC_SEPARATOR_NAME, decSeparator);
                        textVal = numberFormatter.format(bigdecimal);
                    } else {
                        parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.NUMERIC_TYPE);
                        textVal = bigdecimal.toString();
                    }
                }
            }
                break;
            case Types.NCHAR:
            case Types.NVARCHAR: {
                parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.NSTRING_TYPE);
                textVal = rs.getNString(j);
                isNull = textVal == null;
                parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull));
                if (isNull) {
                    textVal = "";
                }
            }
                break;
            case Types.CHAR:
            case Types.VARCHAR: {
                parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.STRING_TYPE);
                textVal = rs.getString(j);
                isNull = textVal == null;
                parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull));
                if (isNull) {
                    textVal = "";
                }
            }
                break;
            case Types.NCLOB: {
                parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.LONG_NSTRING_TYPE);
                NClob clob = rs.getNClob(j);
                isNull = clob == null;
                parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull));
                if (isNull) {
                    textVal = "";
                } else {
                    Reader is = clob.getCharacterStream();
                    StringWriter str = new StringWriter();

                    IOUtils.copy(is, str);
                    is.close();
                    textVal = str.toString();
                }
            }
                break;
            case Types.CLOB: {
                parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.LONG_STRING_TYPE);
                Clob clob = rs.getClob(j);
                isNull = clob == null;
                parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull));
                if (isNull) {
                    textVal = "";
                } else {
                    Reader is = clob.getCharacterStream();
                    StringWriter str = new StringWriter();

                    IOUtils.copy(is, str);
                    is.close();
                    textVal = str.toString();
                }
            }
                break;
            case Types.BLOB: {
                parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.BASE64_TYPE);
                Blob blob = rs.getBlob(j);
                isNull = blob == null;
                parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull));
                if (isNull) {
                    textVal = "";
                } else {
                    InputStream is = blob.getBinaryStream();
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    IOUtils.copy(is, baos);
                    is.close();
                    try {
                        byte[] buffer = Arrays.copyOf(baos.toByteArray(), (int) blob.length());
                        textVal = Base64.getEncoder().encodeToString(buffer);
                    } catch (SQLFeatureNotSupportedException exc) {
                        textVal = Base64.getEncoder().encodeToString(baos.toByteArray());
                    }
                }
            }
                break;
            default: {
                parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.DEFAULT_TYPE);
                textVal = rs.getString(j);
                isNull = textVal == null;
                parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull));
                if (isNull) {
                    textVal = "";
                }
            }
            }
            if (textVal != null) {
                text = doc.createTextNode(textVal);
                col.appendChild(text);
            }
            if (isKeyCol) {
                if (textVal != null) {
                    if (colKey == null) {
                        colKey = textVal;
                    } else {
                        colKey += "##" + textVal;
                    }
                    keyCols.put(String.valueOf(j), col);
                }
            } else {
                row.appendChild(col);
            }
        }
        if (noKey) {
            if (data == null) {
                data = parser.createElementNS(doc, AbstractDBO.DATA_NAME, NS);
                parser.setAttribute(data, AbstractDBO.ID_NAME, id);
            }
        } else if ((colKey != null) && !colKey.equals(precKey)) {
            if (data != null) {
                docRoot.appendChild(data);
            }
            data = parser.createElementNS(doc, AbstractDBO.DATA_NAME, NS);
            parser.setAttribute(data, AbstractDBO.ID_NAME, id);
            Element key = parser.createElementNS(doc, AbstractDBO.KEY_NAME, NS);
            data.appendChild(key);
            for (Entry<String, Element> keyColsEntry : keyCols.entrySet()) {
                key.appendChild(keyColsEntry.getValue());
            }
            keyCols.clear();
            precKey = colKey;
        }
        colKey = null;
        data.appendChild(row);
        rowCounter++;
    }
    if (data != null) {
        docRoot.appendChild(data);
    }

    return rowCounter;
}

From source file:net.riezebos.thoth.configuration.persistence.dbs.DDLExecuter.java

private void initDialect(DatabaseIdiom idiom) {
    databaseIdiom = idiom;/*from   ww w  .  j  ava 2s.c  o m*/
    try {
        addTranslation("bigint", idiom.getTypeName(Types.BIGINT));
        addTranslation("binary", idiom.getTypeName(Types.BINARY));
        addTranslation("bit", idiom.getTypeName(Types.BIT));
        addTranslation("blob", idiom.getTypeName(Types.BLOB));
        addTranslation("boolean", idiom.getTypeName(Types.BOOLEAN));
        addTranslation("char", idiom.getTypeName(Types.CHAR));
        addTranslation("clob", idiom.getTypeName(Types.CLOB));
        addTranslation("date", idiom.getTypeName(Types.DATE));
        addTranslation("decimal", idiom.getTypeName(Types.DECIMAL));
        addTranslation("double", idiom.getTypeName(Types.DOUBLE));
        addTranslation("float", idiom.getTypeName(Types.FLOAT));
        addTranslation("integer", idiom.getTypeName(Types.INTEGER));
        addTranslation("longnvarchar", idiom.getTypeName(Types.LONGNVARCHAR));
        addTranslation("longvarbinary", idiom.getTypeName(Types.LONGVARBINARY));
        addTranslation("longvarchar", idiom.getTypeName(Types.LONGVARCHAR));
        addTranslation("nchar", idiom.getTypeName(Types.NCHAR));
        addTranslation("nclob", idiom.getTypeName(Types.NCLOB));
        addTranslation("numeric", idiom.getTypeName(Types.NUMERIC));
        addTranslation("nvarchar", idiom.getTypeName(Types.NVARCHAR));
        addTranslation("real", idiom.getTypeName(Types.REAL));
        addTranslation("smallint", idiom.getTypeName(Types.SMALLINT));
        addTranslation("time", idiom.getTypeName(Types.TIME));
        addTranslation("timestamp", idiom.getTypeName(Types.TIMESTAMP));
        addTranslation("tinyint", idiom.getTypeName(Types.TINYINT));
        addTranslation("varbinary", idiom.getTypeName(Types.VARBINARY));

        databaseIdiom.initDialect(translations, workarounds);
        // Ignore autogenerated ID's
        addWorkaround("generated always as identity", "");
    } catch (Exception e) {
        throw new IllegalArgumentException(e);
    }
}

From source file:ca.sqlpower.sqlobject.TestSQLColumn.java

public void testSmallConstructor() throws Exception {
    SQLColumn col = new SQLColumn(table0pk, "test_column", Types.INTEGER, 10, 30);
    assertEquals(table0pk, col.getParent());
    assertEquals("test_column", col.getName());
    assertEquals(Types.INTEGER, col.getType());
    assertEquals(10, col.getPrecision());
    assertEquals(30, col.getScale());/*  www.  j  av a 2s. co m*/
    assertEquals(1, col.getReferenceCount());
    assertEquals(1, col.getChildCount());
}

From source file:com.act.lcms.db.model.CuratedChemical.java

protected static void bindInsertOrUpdateParameters(PreparedStatement stmt, String name, String inchi,
        Double mPlusHPlusMass, Integer expectedCollisionVoltage, String referenceUrl) throws SQLException {
    stmt.setString(DB_FIELD.NAME.getInsertUpdateOffset(), name);
    stmt.setString(DB_FIELD.INCHI.getInsertUpdateOffset(), inchi);
    stmt.setDouble(DB_FIELD.MASS.getInsertUpdateOffset(), mPlusHPlusMass);
    if (expectedCollisionVoltage != null) {
        stmt.setInt(DB_FIELD.EXPECTED_COLLISION_VOLTAGE.getInsertUpdateOffset(), expectedCollisionVoltage);
    } else {// w  ww  .  j  av a 2  s .  co  m
        stmt.setNull(DB_FIELD.EXPECTED_COLLISION_VOLTAGE.getInsertUpdateOffset(), Types.INTEGER);
    }
    stmt.setString(DB_FIELD.REFERENCE_URL.getInsertUpdateOffset(), referenceUrl);
}

From source file:com.squid.core.domain.operators.ExtendedType.java

/**
 * return true if the type is a number with exact precision (that is it is NOT a real, float, double)
 * @return//from   w w w . j a va  2s .c  o m
 */
@JsonIgnore
public boolean isExactNumber() {
    switch (this.dataType) {
    case Types.BIGINT:
    case Types.INTEGER:
    case Types.SMALLINT:
    case Types.TINYINT:
    case Types.NUMERIC:
    case Types.DECIMAL:
        return true;
    default:
        return false;
    }
}