Example usage for java.sql Types NUMERIC

List of usage examples for java.sql Types NUMERIC

Introduction

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

Prototype

int NUMERIC

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

Click Source Link

Document

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

Usage

From source file:org.hxzon.util.db.springjdbc.StatementCreatorUtils.java

private static void setValue(PreparedStatement ps, int paramIndex, int sqlType, String typeName, Integer scale,
        Object inValue) throws SQLException {

    if (inValue instanceof SqlTypeValue) {
        ((SqlTypeValue) inValue).setTypeValue(ps, paramIndex, sqlType, typeName);
    } else if (inValue instanceof SqlValue) {
        ((SqlValue) inValue).setValue(ps, paramIndex);
    } else if (sqlType == Types.VARCHAR || sqlType == Types.LONGVARCHAR
            || (sqlType == Types.CLOB && isStringValue(inValue.getClass()))) {
        ps.setString(paramIndex, inValue.toString());
    } else if (sqlType == Types.DECIMAL || sqlType == Types.NUMERIC) {
        if (inValue instanceof BigDecimal) {
            ps.setBigDecimal(paramIndex, (BigDecimal) inValue);
        } else if (scale != null) {
            ps.setObject(paramIndex, inValue, sqlType, scale);
        } else {//  w w w  .  j  a  v  a2s .c om
            ps.setObject(paramIndex, inValue, sqlType);
        }
    } else if (sqlType == Types.DATE) {
        if (inValue instanceof java.util.Date) {
            if (inValue instanceof java.sql.Date) {
                ps.setDate(paramIndex, (java.sql.Date) inValue);
            } else {
                ps.setDate(paramIndex, new java.sql.Date(((java.util.Date) inValue).getTime()));
            }
        } else if (inValue instanceof Calendar) {
            Calendar cal = (Calendar) inValue;
            ps.setDate(paramIndex, new java.sql.Date(cal.getTime().getTime()), cal);
        } else {
            ps.setObject(paramIndex, inValue, Types.DATE);
        }
    } else if (sqlType == Types.TIME) {
        if (inValue instanceof java.util.Date) {
            if (inValue instanceof java.sql.Time) {
                ps.setTime(paramIndex, (java.sql.Time) inValue);
            } else {
                ps.setTime(paramIndex, new java.sql.Time(((java.util.Date) inValue).getTime()));
            }
        } else if (inValue instanceof Calendar) {
            Calendar cal = (Calendar) inValue;
            ps.setTime(paramIndex, new java.sql.Time(cal.getTime().getTime()), cal);
        } else {
            ps.setObject(paramIndex, inValue, Types.TIME);
        }
    } else if (sqlType == Types.TIMESTAMP) {
        if (inValue instanceof java.util.Date) {
            if (inValue instanceof java.sql.Timestamp) {
                ps.setTimestamp(paramIndex, (java.sql.Timestamp) inValue);
            } else {
                ps.setTimestamp(paramIndex, new java.sql.Timestamp(((java.util.Date) inValue).getTime()));
            }
        } else if (inValue instanceof Calendar) {
            Calendar cal = (Calendar) inValue;
            ps.setTimestamp(paramIndex, new java.sql.Timestamp(cal.getTime().getTime()), cal);
        } else {
            ps.setObject(paramIndex, inValue, Types.TIMESTAMP);
        }
    } else if (sqlType == SqlTypeValue.TYPE_UNKNOWN) {
        if (isStringValue(inValue.getClass())) {
            ps.setString(paramIndex, inValue.toString());
        } else if (isDateValue(inValue.getClass())) {
            ps.setTimestamp(paramIndex, new java.sql.Timestamp(((java.util.Date) inValue).getTime()));
        } else if (inValue instanceof Calendar) {
            Calendar cal = (Calendar) inValue;
            ps.setTimestamp(paramIndex, new java.sql.Timestamp(cal.getTime().getTime()), cal);
        } else {
            // Fall back to generic setObject call without SQL type specified.
            ps.setObject(paramIndex, inValue);
        }
    } else {
        // Fall back to generic setObject call with SQL type specified.
        ps.setObject(paramIndex, inValue, sqlType);
    }
}

From source file:com.tesora.dve.db.NativeType.java

public boolean isDecimalType() {
    return dataType == Types.DECIMAL || dataType == Types.NUMERIC;
}

From source file:jeeves.resources.dbms.Dbms.java

private Element buildElement(ResultSet rs, int col, String name, int type, Hashtable<String, String> formats)
        throws SQLException {
    String value = null;// w  w w . j  a v  a2  s  .c om

    switch (type) {
    case Types.DATE:
        Date date = rs.getDate(col + 1);
        if (date == null)
            value = null;
        else {
            String format = formats.get(name);
            SimpleDateFormat df = (format == null) ? new SimpleDateFormat(DEFAULT_DATE_FORMAT)
                    : new SimpleDateFormat(format);
            value = df.format(date);
        }
        break;

    case Types.TIME:
        Time time = rs.getTime(col + 1);
        if (time == null)
            value = null;
        else {
            String format = formats.get(name);
            SimpleDateFormat df = (format == null) ? new SimpleDateFormat(DEFAULT_TIME_FORMAT)
                    : new SimpleDateFormat(format);
            value = df.format(time);
        }
        break;

    case Types.TIMESTAMP:
        Timestamp timestamp = rs.getTimestamp(col + 1);
        if (timestamp == null)
            value = null;
        else {
            String format = formats.get(name);
            SimpleDateFormat df = (format == null) ? new SimpleDateFormat(DEFAULT_TIMESTAMP_FORMAT)
                    : new SimpleDateFormat(format);
            value = df.format(timestamp);
        }
        break;

    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
    case Types.BIGINT:
        long l = rs.getLong(col + 1);
        if (rs.wasNull())
            value = null;
        else {
            String format = formats.get(name);
            if (format == null)
                value = l + "";
            else {
                DecimalFormat df = new DecimalFormat(format);
                value = df.format(l);
            }
        }
        break;

    case Types.DECIMAL:
    case Types.FLOAT:
    case Types.DOUBLE:
    case Types.REAL:
    case Types.NUMERIC:
        double n = rs.getDouble(col + 1);

        if (rs.wasNull())
            value = null;
        else {
            String format = formats.get(name);

            if (format == null) {
                value = n + "";

                // --- this fix is mandatory for oracle
                // --- that shit returns integers like xxx.0

                if (value.endsWith(".0"))
                    value = value.substring(0, value.length() - 2);
            } else {
                DecimalFormat df = new DecimalFormat(format);
                value = df.format(n);
            }
        }
        break;

    default:
        value = rs.getString(col + 1);
        if (value != null) {
            value = stripIllegalChars(value);
        }

        break;
    }
    return new Element(name).setText(value);
}

From source file:org.jumpmind.db.alter.ModelComparator.java

/**
 * Compares the two columns and returns the changes necessary to create the
 * second column from the first one./* w w  w  .j ava2s.  co  m*/
 * 
 * @param sourceTable
 *            The source table which contains the source column
 * @param sourceColumn
 *            The source column
 * @param targetTable
 *            The target table which contains the target column
 * @param targetColumn
 *            The target column
 * @return The changes
 */
public List<TableChange> compareColumns(Table sourceTable, Column sourceColumn, Table targetTable,
        Column targetColumn) {
    ArrayList<TableChange> changes = new ArrayList<TableChange>();

    int actualTypeCode = sourceColumn.getMappedTypeCode();
    int desiredTypeCode = targetColumn.getMappedTypeCode();
    boolean sizeMatters = platformInfo.hasSize(targetColumn.getMappedTypeCode());
    boolean scaleMatters = platformInfo.hasPrecisionAndScale(targetColumn.getMappedTypeCode());

    boolean compatible = (actualTypeCode == Types.NUMERIC || actualTypeCode == Types.DECIMAL)
            && (desiredTypeCode == Types.INTEGER || desiredTypeCode == Types.BIGINT);

    if (sourceColumn.isAutoIncrement() && targetColumn.isAutoIncrement()
            && (desiredTypeCode == Types.NUMERIC || desiredTypeCode == Types.DECIMAL)
            && (actualTypeCode == Types.INTEGER || actualTypeCode == Types.BIGINT)) {
        compatible = true;

        // This is the rare case where size doesnt matter!
        sizeMatters = false;
        scaleMatters = false;
    }

    if (!compatible && targetColumn.getMappedTypeCode() != sourceColumn.getMappedTypeCode() && platformInfo
            .getTargetJdbcType(targetColumn.getMappedTypeCode()) != sourceColumn.getMappedTypeCode()) {
        log.debug("The {} column on the {} table changed type codes from {} to {} ",
                new Object[] { sourceColumn.getName(), sourceTable.getName(), sourceColumn.getMappedTypeCode(),
                        targetColumn.getMappedTypeCode() });
        changes.add(new ColumnDataTypeChange(sourceTable, sourceColumn, targetColumn.getMappedTypeCode()));
    }

    String targetSize = targetColumn.getSize();
    if (targetSize == null) {
        Integer defaultSize = platformInfo
                .getDefaultSize(platformInfo.getTargetJdbcType(targetColumn.getMappedTypeCode()));
        if (defaultSize != null) {
            targetSize = defaultSize.toString();
        } else {
            targetSize = "0";
        }
    }
    if (sizeMatters && !StringUtils.equals(sourceColumn.getSize(), targetSize)) {
        log.debug("The {} column on the {} table changed size from ({}) to ({})",
                new Object[] { sourceColumn.getName(), sourceTable.getName(), sourceColumn.getSizeAsInt(),
                        targetColumn.getSizeAsInt() });

        changes.add(new ColumnSizeChange(sourceTable, sourceColumn, targetColumn.getSizeAsInt(),
                targetColumn.getScale()));
    } else if (scaleMatters && (!StringUtils.equals(sourceColumn.getSize(), targetSize) ||
    // ojdbc6.jar returns -127 for the scale of NUMBER that was not given a
    // size or precision
            (!(sourceColumn.getScale() < 0 && targetColumn.getScale() == 0)
                    && sourceColumn.getScale() != targetColumn.getScale()))) {
        log.debug("The {} column on the {} table changed scale from ({},{}) to ({},{})",
                new Object[] { sourceColumn.getName(), sourceTable.getName(), sourceColumn.getSizeAsInt(),
                        sourceColumn.getScale(), targetColumn.getSizeAsInt(), targetColumn.getScale() });
        changes.add(new ColumnSizeChange(sourceTable, sourceColumn, targetColumn.getSizeAsInt(),
                targetColumn.getScale()));
    }

    Object sourceDefaultValue = sourceColumn.getParsedDefaultValue();
    Object targetDefaultValue = targetColumn.getParsedDefaultValue();

    if ((sourceDefaultValue == null && targetDefaultValue != null)
            || (sourceDefaultValue != null && targetDefaultValue == null)
            || (sourceDefaultValue != null && targetDefaultValue != null
                    && !sourceDefaultValue.toString().equals(targetDefaultValue.toString()))) {
        log.debug("The {} column on the {} table changed default value from {} to {} ",
                new Object[] { sourceColumn.getName(), sourceTable.getName(), sourceColumn.getDefaultValue(),
                        targetColumn.getDefaultValue() });
        changes.add(new ColumnDefaultValueChange(sourceTable, sourceColumn, targetColumn.getDefaultValue()));
    }

    if (sourceColumn.isRequired() != targetColumn.isRequired()) {
        log.debug("The {} column on the {} table changed required status from {} to {}",
                new Object[] { sourceColumn.getName(), sourceTable.getName(), sourceColumn.isRequired(),
                        targetColumn.isRequired() });
        changes.add(new ColumnRequiredChange(sourceTable, sourceColumn));
    }

    if (sourceColumn.isAutoIncrement() != targetColumn.isAutoIncrement()) {
        log.debug("The {} column on the {} table changed auto increment status from {} to {} ",
                new Object[] { sourceColumn.getName(), sourceTable.getName(), sourceColumn.isAutoIncrement(),
                        targetColumn.isAutoIncrement() });
        changes.add(new ColumnAutoIncrementChange(sourceTable, sourceColumn));
    }

    return changes;
}

From source file:org.jumpmind.vaadin.ui.common.CommonUiUtils.java

@SuppressWarnings("unchecked")
public static Grid putResultsInGrid(final ResultSet rs, List<Integer> pkcolumns, int maxResultSize,
        final boolean showRowNumbers, String... excludeValues) throws SQLException {

    final Grid grid = new Grid();
    grid.setImmediate(true);//  ww w.  ja va2s .c  om
    grid.setSelectionMode(SelectionMode.MULTI);
    grid.setColumnReorderingAllowed(true);
    grid.setData(new HashMap<Object, List<Object>>());

    final ResultSetMetaData meta = rs.getMetaData();
    int columnCount = meta.getColumnCount();
    grid.addColumn("#", Integer.class).setHeaderCaption("#").setHidable(true);
    Set<String> columnNames = new HashSet<String>();
    Set<Integer> skipColumnIndexes = new HashSet<Integer>();
    int[] types = new int[columnCount];
    for (int i = 1; i <= columnCount; i++) {
        String realColumnName = meta.getColumnName(i);
        String columnName = realColumnName;
        if (!Arrays.asList(excludeValues).contains(columnName)) {

            int index = 1;
            while (columnNames.contains(columnName)) {
                columnName = realColumnName + "_" + index++;
            }
            columnNames.add(columnName);

            Class<?> typeClass = Object.class;
            int type = meta.getColumnType(i);
            types[i - 1] = type;
            switch (type) {
            case Types.FLOAT:
            case Types.DOUBLE:
            case Types.NUMERIC:
            case Types.REAL:
            case Types.DECIMAL:
                typeClass = BigDecimal.class;
                break;
            case Types.TINYINT:
            case Types.SMALLINT:
            case Types.BIGINT:
            case Types.INTEGER:
                typeClass = Long.class;
                break;
            case Types.VARCHAR:
            case Types.CHAR:
            case Types.NVARCHAR:
            case Types.NCHAR:
            case Types.CLOB:
                typeClass = String.class;
            default:
                break;
            }
            Column column = grid.addColumn(columnName, typeClass).setHeaderCaption(columnName).setHidable(true);
            if (typeClass.equals(Long.class)) {
                column.setConverter(new StringToLongConverter() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public String convertToPresentation(Long value, Class<? extends String> targetType,
                            Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
                        if (value == null) {
                            return NULL_TEXT;
                        } else {
                            return value.toString();
                        }
                    }
                });
            } else if (typeClass.equals(BigDecimal.class)) {
                column.setConverter(new StringToBigDecimalConverter() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public String convertToPresentation(BigDecimal value, Class<? extends String> targetType,
                            Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
                        if (value == null) {
                            return NULL_TEXT;
                        } else {
                            return value.toString();
                        }
                    }
                });
            } else {
                column.setConverter(new Converter<String, Object>() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public Object convertToModel(String value, Class<? extends Object> targetType,
                            Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
                        return null;
                    }

                    @Override
                    public String convertToPresentation(Object value, Class<? extends String> targetType,
                            Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
                        if (value == null) {
                            return NULL_TEXT;
                        } else {
                            return value.toString();
                        }
                    }

                    @Override
                    public Class<Object> getModelType() {
                        return Object.class;
                    }

                    @Override
                    public Class<String> getPresentationType() {
                        return String.class;
                    }

                });
            }
        } else {
            skipColumnIndexes.add(i - 1);
        }

    }
    int rowNumber = 1;
    while (rs.next() && rowNumber <= maxResultSize) {
        Object[] row = new Object[columnNames.size() + 1];
        row[0] = new Integer(rowNumber);
        int rowIndex = 1;
        for (int i = 0; i < columnCount; i++) {
            if (!skipColumnIndexes.contains(i)) {
                Object o = getObject(rs, i + 1);
                int type = types[i];
                switch (type) {
                case Types.FLOAT:
                case Types.DOUBLE:
                case Types.REAL:
                case Types.NUMERIC:
                case Types.DECIMAL:
                    if (o != null && !(o instanceof BigDecimal)) {
                        o = new BigDecimal(castToNumber(o.toString()));
                    }
                    break;
                case Types.TINYINT:
                case Types.SMALLINT:
                case Types.BIGINT:
                case Types.INTEGER:
                    if (o != null && !(o instanceof Long)) {
                        o = new Long(castToNumber(o.toString()));
                    }
                    break;
                default:
                    break;
                }
                List<Object> primaryKeys = new ArrayList<Object>();
                for (Integer pkcolumn : pkcolumns) {
                    primaryKeys.add(getObject(rs, pkcolumn + 1));
                }
                ((HashMap<Object, List<Object>>) grid.getData()).put(o, primaryKeys);
                row[rowIndex] = o;
                rowIndex++;
            }
        }
        grid.addRow(row);
        rowNumber++;
    }

    if (rowNumber < 100) {
        grid.getColumn("#").setWidth(75);
    } else if (rowNumber < 1000) {
        grid.getColumn("#").setWidth(95);
    } else {
        grid.getColumn("#").setWidth(115);
    }

    if (!showRowNumbers) {
        grid.getColumn("#").setHidden(true);
    } else {
        grid.setFrozenColumnCount(1);
    }

    return grid;
}

From source file:org.jumpmind.symmetric.test.SimpleIntegrationTest.java

@Test(timeout = 120000)
public void test07SyncToClientMultipleUpdates() {

    logTestRunning();/*  ww  w  . jav a2  s .  c  o  m*/
    // test pulling no data
    clientPull();

    final int NEW_ZIP = 44444;
    final String NEW_NAME = "JoJo Duh Doh";

    // now change some data that should be sync'd
    serverTestService.updateCustomer(100, "zip", NEW_ZIP, Types.NUMERIC);
    serverTestService.updateCustomer(100, "name", NEW_NAME, Types.VARCHAR);

    boolean didPullData = clientPull();

    assertTrue(didPullData);

    Customer clientCustomer = clientTestService.getCustomer(100);
    assertEquals(NEW_ZIP, clientCustomer.getZip());
    assertEquals(NEW_NAME, clientCustomer.getName());

}

From source file:com.streamsets.pipeline.stage.processor.parser.sql.SqlParserProcessor.java

private void resolveSchema(SchemaAndTable schemaAndTable) throws StageException {
    Map<String, Integer> columns = new HashMap<>();
    String schema = schemaAndTable.getSchema();
    String table = schemaAndTable.getTable();
    try (Statement s = connection.createStatement()) {
        ResultSetMetaData md = s/*from  w  w w. ja  v  a 2s .co m*/
                .executeQuery(Utils.format("SELECT * FROM {}{} WHERE 1 = 0",
                        StringUtils.isNotEmpty(schema) ? "\"" + schema + "\"." : "", "\"" + table + "\""))
                .getMetaData();
        int colCount = md.getColumnCount();
        for (int i = 1; i <= colCount; i++) {
            int colType = md.getColumnType(i);
            String colName = md.getColumnName(i);
            if (!configBean.caseSensitive) {
                colName = colName.toUpperCase();
            }
            if (colType == Types.DATE || colType == Types.TIME || colType == Types.TIMESTAMP) {
                dateTimeColumns.computeIfAbsent(schemaAndTable, k -> new HashMap<>());
                dateTimeColumns.get(schemaAndTable).put(colName, md.getColumnTypeName(i));
            }

            if (colType == Types.DECIMAL || colType == Types.NUMERIC) {
                decimalColumns.computeIfAbsent(schemaAndTable, k -> new HashMap<>()).put(colName,
                        new PrecisionAndScale(md.getPrecision(i), md.getScale(i)));
            }
            columns.put(md.getColumnName(i), md.getColumnType(i));
        }
        tableSchemas.put(schemaAndTable, columns);
    } catch (SQLException ex) {
        throw new StageException(JDBC_00, configBean.hikariConfigBean.connectionString);
    }
}

From source file:org.springframework.jdbc.object.SqlQueryTests.java

public void testFindCustomerIntInt() throws SQLException {
    mockResultSet.next();//from  www  . j a v  a  2s  .c  o m
    ctrlResultSet.setReturnValue(true);
    mockResultSet.getInt("id");
    ctrlResultSet.setReturnValue(1);
    mockResultSet.getString("forename");
    ctrlResultSet.setReturnValue("rod");
    mockResultSet.next();
    ctrlResultSet.setReturnValue(false);
    mockResultSet.close();
    ctrlResultSet.setVoidCallable();

    mockPreparedStatement.setObject(1, new Integer(1), Types.NUMERIC);
    ctrlPreparedStatement.setVoidCallable();
    mockPreparedStatement.setObject(2, new Integer(1), Types.NUMERIC);
    ctrlPreparedStatement.setVoidCallable();
    mockPreparedStatement.executeQuery();
    ctrlPreparedStatement.setReturnValue(mockResultSet);
    if (debugEnabled) {
        mockPreparedStatement.getWarnings();
        ctrlPreparedStatement.setReturnValue(null);
    }
    mockPreparedStatement.close();
    ctrlPreparedStatement.setVoidCallable();

    mockConnection.prepareStatement(SELECT_ID_WHERE);
    ctrlConnection.setReturnValue(mockPreparedStatement);

    replay();

    class CustomerQuery extends MappingSqlQuery {

        public CustomerQuery(DataSource ds) {
            super(ds, SELECT_ID_WHERE);
            declareParameter(new SqlParameter(Types.NUMERIC));
            declareParameter(new SqlParameter(Types.NUMERIC));
            compile();
        }

        protected Object mapRow(ResultSet rs, int rownum) throws SQLException {
            Customer cust = new Customer();
            cust.setId(rs.getInt(COLUMN_NAMES[0]));
            cust.setForename(rs.getString(COLUMN_NAMES[1]));
            return cust;
        }

        public Customer findCustomer(int id, int otherNum) {
            return (Customer) findObject(id, otherNum);
        }
    }

    CustomerQuery query = new CustomerQuery(mockDataSource);
    Customer cust = query.findCustomer(1, 1);

    assertTrue("Customer id was assigned correctly", cust.getId() == 1);
    assertTrue("Customer forename was assigned correctly", cust.getForename().equals("rod"));
}

From source file:org.springframework.jdbc.core.metadata.GenericTableMetaDataProvider.java

/**
 * Method supporting the metadata processing for a table's columns
 *///  w  w w .j  a  va2  s.com
private void processTableColumns(DatabaseMetaData databaseMetaData, TableMetaData tmd) {
    ResultSet tableColumns = null;
    String metaDataCatalogName = metaDataCatalogNameToUse(tmd.getCatalogName());
    String metaDataSchemaName = metaDataSchemaNameToUse(tmd.getSchemaName());
    String metaDataTableName = tableNameToUse(tmd.getTableName());
    if (logger.isDebugEnabled()) {
        logger.debug("Retrieving metadata for " + metaDataCatalogName + '/' + metaDataSchemaName + '/'
                + metaDataTableName);
    }
    try {
        tableColumns = databaseMetaData.getColumns(metaDataCatalogName, metaDataSchemaName, metaDataTableName,
                null);
        while (tableColumns.next()) {
            String columnName = tableColumns.getString("COLUMN_NAME");
            int dataType = tableColumns.getInt("DATA_TYPE");
            if (dataType == Types.DECIMAL) {
                String typeName = tableColumns.getString("TYPE_NAME");
                int decimalDigits = tableColumns.getInt("DECIMAL_DIGITS");
                // Override a DECIMAL data type for no-decimal numerics
                // (this is for better Oracle support where there have been issues
                // using DECIMAL for certain inserts (see SPR-6912))
                if ("NUMBER".equals(typeName) && decimalDigits == 0) {
                    dataType = Types.NUMERIC;
                    if (logger.isDebugEnabled()) {
                        logger.debug("Overriding metadata: " + columnName + " now NUMERIC instead of DECIMAL");
                    }
                }
            }
            boolean nullable = tableColumns.getBoolean("NULLABLE");
            TableParameterMetaData meta = new TableParameterMetaData(columnName, dataType, nullable);
            this.tableParameterMetaData.add(meta);
            if (logger.isDebugEnabled()) {
                logger.debug("Retrieved metadata: " + meta.getParameterName() + " " + meta.getSqlType() + " "
                        + meta.isNullable());
            }
        }
    } catch (SQLException ex) {
        if (logger.isWarnEnabled()) {
            logger.warn("Error while retrieving metadata for table columns: " + ex.getMessage());
        }
    } finally {
        JdbcUtils.closeResultSet(tableColumns);
    }
}

From source file:org.jumpmind.symmetric.service.impl.IncomingBatchService.java

public int updateIncomingBatch(ISqlTransaction transaction, IncomingBatch batch) {
    int count = 0;
    if (batch.isPersistable()) {
        if (batch.getStatus() == IncomingBatch.Status.ER) {
            batch.setErrorFlag(true);/*from  w  ww  .j  av  a  2s .c  o  m*/
        } else if (batch.getStatus() == IncomingBatch.Status.OK) {
            batch.setErrorFlag(false);
        }
        batch.setLastUpdatedHostName(clusterService.getServerId());
        batch.setLastUpdatedTime(new Date());
        count = transaction.prepareAndExecute(getSql("updateIncomingBatchSql"),
                new Object[] { batch.getStatus().name(), batch.isErrorFlag() ? 1 : 0, batch.getNetworkMillis(),
                        batch.getFilterMillis(), batch.getDatabaseMillis(), batch.getFailedRowNumber(),
                        batch.getFailedLineNumber(), batch.getByteCount(), batch.getStatementCount(),
                        batch.getFallbackInsertCount(), batch.getFallbackUpdateCount(), batch.getIgnoreCount(),
                        batch.getMissingDeleteCount(), batch.getSkipCount(), batch.getSqlState(),
                        batch.getSqlCode(), FormatUtils.abbreviateForLogging(batch.getSqlMessage()),
                        batch.getLastUpdatedHostName(), batch.getLastUpdatedTime(), batch.getBatchId(),
                        batch.getNodeId() },
                new int[] { Types.CHAR, Types.SMALLINT, Types.NUMERIC, Types.NUMERIC, Types.NUMERIC,
                        Types.NUMERIC, Types.NUMERIC, Types.NUMERIC, Types.NUMERIC, Types.NUMERIC,
                        Types.NUMERIC, Types.NUMERIC, Types.NUMERIC, Types.NUMERIC, Types.VARCHAR,
                        Types.NUMERIC, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP,
                        symmetricDialect.getSqlTypeForIds(), Types.VARCHAR });
    }
    return count;
}