Example usage for java.sql Types FLOAT

List of usage examples for java.sql Types FLOAT

Introduction

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

Prototype

int FLOAT

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

Click Source Link

Document

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

Usage

From source file:org.brucalipto.sqlutil.SQLManager.java

/**
 * Method useful for SQL SELECT/*from   w  w w  .  j a  v  a2  s  .com*/
 * @param preparedStatement The prepared statement to execute
 * @param parameters List of {@link SQLParameter} to use to complete the prepared statement
 * @return Returns a RowSetDynaClass containing returned rows
 * @throws SQLException 
 */
public RowSetDynaClass dynaSelect(final String preparedStatement, final SQLParameter[] params)
        throws SQLException {
    final long elapsedTime = System.currentTimeMillis();
    SQLParameter[] parameters;
    if (params == null) {
        parameters = new SQLParameter[0];
        log.debug("Going to execute a query without parameters.");
    } else {
        parameters = (SQLParameter[]) params.clone();
    }
    Connection dbConn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    try {
        if (this.dataSource != null) {
            dbConn = this.dataSource.getConnection();
        } else {
            dbConn = this.connection;
        }
        pstmt = dbConn.prepareStatement(preparedStatement);
        for (int i = 0; i < parameters.length; i++) {
            final SQLParameter param = parameters[i];
            log.debug((i + 1) + ") Going to add parameter " + param);
            final int sqlType = param.getSqlType();
            final Object paramValue = param.getValue();
            if (paramValue == null) {
                pstmt.setNull(i + 1, sqlType);
                continue;
            }
            switch (sqlType) {
            case Types.VARCHAR:
                pstmt.setString(i + 1, (String) paramValue);
                break;
            case Types.INTEGER:
                if (paramValue instanceof Integer) {
                    pstmt.setInt(i + 1, ((Integer) paramValue).intValue());
                } else if (paramValue instanceof Long) {
                    pstmt.setLong(i + 1, ((Long) paramValue).longValue());
                }
                break;
            case Types.DATE:
                pstmt.setDate(i + 1, (Date) paramValue);
                break;
            case Types.BOOLEAN:
                pstmt.setBoolean(i + 1, ((Boolean) paramValue).booleanValue());
                break;
            case Types.CHAR:
                pstmt.setString(i + 1, ((Character) paramValue).toString());
                break;
            case Types.DOUBLE:
                pstmt.setDouble(i + 1, ((Double) paramValue).doubleValue());
                break;
            case Types.FLOAT:
                pstmt.setFloat(i + 1, ((Float) paramValue).floatValue());
                break;
            case Types.TIMESTAMP:
                pstmt.setTimestamp(i + 1, (Timestamp) paramValue);
                break;
            default:
                pstmt.setObject(i + 1, paramValue);
                break;
            }
        }

        rs = pstmt.executeQuery();
        RowSetDynaClass rowSetDynaClass = new RowSetDynaClass(rs, false);
        if (log.isDebugEnabled()) {
            log.debug("Prepared statement '" + preparedStatement + "' returned '"
                    + rowSetDynaClass.getRows().size() + "' rows in '"
                    + (System.currentTimeMillis() - elapsedTime) + "' millis with following properties:");
            DynaProperty[] properties = rowSetDynaClass.getDynaProperties();
            for (int i = 0; i < properties.length; i++) {
                log.debug("Name: '" + properties[i].getName() + "'; Type: '" + properties[i].getType().getName()
                        + "'");
            }
        }
        return rowSetDynaClass;
    } catch (SQLException e) {
        log.error("Error executing prepared statement '" + preparedStatement + "'", e);
        throw e;
    } finally {
        closeResources(rs, pstmt, dbConn);
    }
}

From source file:com.jaspersoft.jrx.query.PlSqlQueryExecuter.java

private void createStatement() throws JRException {
    String queryString = getQueryString();

    if (connection != null && queryString != null && queryString.trim().length() > 0) {

        try {/*from  ww  w.  j a  v a 2  s  .c o m*/
            isStoredProcedure = isOracleStoredProcedure(queryString);

            if (isStoredProcedure) {
                statement = connection.prepareCall(queryString);
            } else {
                statement = connection.prepareStatement(queryString);
            }

            int fetchSize = JRPropertiesUtil.getInstance(getJasperReportsContext()).getIntegerProperty(
                    dataset.getPropertiesMap(), JRJdbcQueryExecuterFactory.PROPERTY_JDBC_FETCH_SIZE, 0);
            if (fetchSize > 0) {
                statement.setFetchSize(fetchSize);
            }

            List<String> parameterNames = getCollectedParameterNames();
            if (!parameterNames.isEmpty()) {
                for (int i = 0; i < parameterNames.size(); i++) {
                    String parameterName = (String) parameterNames.get(i);
                    JRValueParameter parameter = getValueParameter(parameterName);
                    Class<?> clazz = parameter.getValueClass();
                    Object parameterValue = parameter.getValue();

                    if (clazz.equals(java.lang.Object.class)) {
                        if (parameterValue == null) {
                            statement.setNull(i + 1, Types.JAVA_OBJECT);
                        } else {
                            statement.setObject(i + 1, parameterValue);
                        }
                    } else if (clazz.equals(java.lang.Boolean.class)) {
                        if (parameterValue == null) {
                            statement.setNull(i + 1, Types.BIT);
                        } else {
                            statement.setBoolean(i + 1, ((Boolean) parameterValue).booleanValue());
                        }
                    } else if (clazz.equals(java.lang.Byte.class)) {
                        if (parameterValue == null) {
                            statement.setNull(i + 1, Types.TINYINT);
                        } else {
                            statement.setByte(i + 1, ((Byte) parameterValue).byteValue());
                        }
                    } else if (clazz.equals(java.lang.Double.class)) {
                        if (parameterValue == null) {
                            statement.setNull(i + 1, Types.DOUBLE);
                        } else {
                            statement.setDouble(i + 1, ((Double) parameterValue).doubleValue());
                        }
                    } else if (clazz.equals(java.lang.Float.class)) {
                        if (parameterValue == null) {
                            statement.setNull(i + 1, Types.FLOAT);
                        } else {
                            statement.setFloat(i + 1, ((Float) parameterValue).floatValue());
                        }
                    } else if (clazz.equals(java.lang.Integer.class)) {
                        if (parameterValue == null) {
                            statement.setNull(i + 1, Types.INTEGER);
                        } else {
                            statement.setInt(i + 1, ((Integer) parameterValue).intValue());
                        }
                    } else if (clazz.equals(java.lang.Long.class)) {
                        if (parameterValue == null) {
                            statement.setNull(i + 1, Types.BIGINT);
                        } else {
                            statement.setLong(i + 1, ((Long) parameterValue).longValue());
                        }
                    } else if (clazz.equals(java.lang.Short.class)) {
                        if (parameterValue == null) {
                            statement.setNull(i + 1, Types.SMALLINT);
                        } else {
                            statement.setShort(i + 1, ((Short) parameterValue).shortValue());
                        }
                    } else if (clazz.equals(java.math.BigDecimal.class)) {
                        if (parameterValue == null) {
                            statement.setNull(i + 1, Types.DECIMAL);
                        } else {
                            statement.setBigDecimal(i + 1, (BigDecimal) parameterValue);
                        }
                    } else if (clazz.equals(java.lang.String.class)) {
                        if (parameterValue == null) {
                            statement.setNull(i + 1, Types.VARCHAR);
                        } else {
                            statement.setString(i + 1, parameterValue.toString());
                        }
                    } else if (clazz.equals(java.util.Date.class)) {
                        if (parameterValue == null) {
                            statement.setNull(i + 1, Types.DATE);
                        } else {
                            statement.setDate(i + 1,
                                    new java.sql.Date(((java.util.Date) parameterValue).getTime()));
                        }
                    } else if (clazz.equals(java.sql.Timestamp.class)) {
                        if (parameterValue == null) {
                            statement.setNull(i + 1, Types.TIMESTAMP);
                        } else {
                            statement.setTimestamp(i + 1, (java.sql.Timestamp) parameterValue);
                        }
                    } else if (clazz.equals(java.sql.Time.class)) {
                        if (parameterValue == null) {
                            statement.setNull(i + 1, Types.TIME);
                        } else {
                            statement.setTime(i + 1, (java.sql.Time) parameterValue);
                        }
                    } else if (clazz.equals(java.sql.ResultSet.class)) {
                        if (!isStoredProcedure) {
                            throw new JRException("OUT paramater used in non-stored procedure call : "
                                    + parameterName + " class " + clazz.getName());
                        } else if (cursorParameter > 0) {
                            throw new JRException("A stored procedure can have at most one cursor parameter : "
                                    + parameterName + " class " + clazz.getName());
                        }

                        ((CallableStatement) statement).registerOutParameter(i + 1, ORACLE_CURSOR_TYPE);
                        cursorParameter = i + 1;
                    } else {
                        throw new JRException("Parameter type not supported in query : " + parameterName
                                + " class " + clazz.getName());
                    }
                }
            }
        } catch (SQLException e) {
            throw new JRException("Error preparing statement for executing the report query : " + "\n\n"
                    + queryString + "\n\n", e);
        }
    }
}

From source file:org.apache.cayenne.migration.MigrationGenerator.java

protected String nameForJdbcType(int type) {
    switch (type) {
    case Types.ARRAY:
        return "array";
    case Types.BIGINT:
        return "bigInt";
    case Types.BINARY:
        return "binary";
    case Types.BIT:
        return "bit";
    case Types.BLOB:
        return "blob";
    case Types.BOOLEAN:
        return "boolean";
    case Types.CHAR:
        return "char";
    case Types.CLOB:
        return "clob";
    case Types.DATE:
        return "date";
    case Types.DECIMAL:
        return "decimal";
    case Types.DOUBLE:
        return "double";
    case Types.FLOAT:
        return "float";
    case Types.INTEGER:
        return "integer";
    case Types.LONGVARBINARY:
        return "longVarBinary";
    case Types.LONGVARCHAR:
        return "longVarChar";
    case Types.NUMERIC:
        return "numeric";
    case Types.REAL:
        return "real";
    case Types.SMALLINT:
        return "smallInt";
    case Types.TIME:
        return "time";
    case Types.TIMESTAMP:
        return "timestamp";
    case Types.TINYINT:
        return "tinyInt";
    case Types.VARBINARY:
        return "varBinary";
    case Types.VARCHAR:
        return "varchar";
    default://from  w w w.j av a  2 s .c  o  m
        return null;
    }
}

From source file:madgik.exareme.master.queryProcessor.analyzer.stat.ExternalStat.java

private int computeColumnSize(String columnName, int columnType, String table_sample) throws Exception {
    int columnSize = 0;
    if (columnType == Types.INTEGER || columnType == Types.REAL || columnType == Types.DOUBLE
            || columnType == Types.DECIMAL || columnType == Types.FLOAT || columnType == Types.NUMERIC) {
        columnSize = NUM_SIZE;//from  ww w  .  ja  v a 2s. co m
    } else if (columnType == Types.VARCHAR) {
        String query0 = "select max(length(" + columnName + ")) as length from (select " + columnName + " from "
                + table_sample + ") A" + " where " + columnName + " is not null limit " + MAX_STRING_SAMPLE;

        if (con.getClass().getName().contains("oracle")) {
            query0 = "select max(length(" + columnName + ")) as length from (select " + columnName + " from "
                    + table_sample + ") A" + " where " + columnName + " is not null and ROWNUM< "
                    + MAX_STRING_SAMPLE;
        }
        log.debug("executing col size query:" + query0);
        Statement stmt0 = con.createStatement();
        ResultSet rs0 = stmt0.executeQuery(query0);

        while (rs0.next()) {
            columnSize = rs0.getInt("length");
        }
        rs0.close();
        stmt0.close();

    } else if (columnType == Types.BLOB)
        columnSize = BLOB_SIZE;

    return columnSize;
}

From source file:org.jumpmind.db.platform.interbase.InterbaseDdlReader.java

protected void adjustColumns(Table table) {
    Column[] columns = table.getColumns();

    for (int idx = 0; idx < columns.length; idx++) {
        if (columns[idx].getMappedTypeCode() == Types.FLOAT) {
            columns[idx].setMappedTypeCode(Types.REAL);
        } else if ((columns[idx].getMappedTypeCode() == Types.NUMERIC)
                || (columns[idx].getMappedTypeCode() == Types.DECIMAL)) {
            if ((columns[idx].getMappedTypeCode() == Types.NUMERIC) && (columns[idx].getSizeAsInt() == 18)
                    && (columns[idx].getScale() == 0)) {
                columns[idx].setMappedTypeCode(Types.BIGINT);
            }//from  w w w . jav  a  2 s . com
        } else if (TypeMap.isTextType(columns[idx].getMappedTypeCode())) {
            columns[idx].setDefaultValue(unescape(columns[idx].getDefaultValue(), "'", "''"));
        }
    }
}

From source file:org.castor.jdo.engine.SQLTypeInfos.java

/**
 * Get value from given ResultSet at given index with given SQL type.
 * /*from www .  j  av  a 2 s  .  c  o m*/
 * @param rs The ResultSet to get the value from.
 * @param index The index of the value in the ResultSet.
 * @param sqlType The SQL type of the value.
 * @return The value.
 * @throws SQLException If a database access error occurs.
 */
public static Object getValue(final ResultSet rs, final int index, final int sqlType) throws SQLException {
    switch (sqlType) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        return rs.getString(index);
    case Types.DECIMAL:
    case Types.NUMERIC:
        return rs.getBigDecimal(index);
    case Types.INTEGER:
        int intVal = rs.getInt(index);
        return (rs.wasNull() ? null : new Integer(intVal));
    case Types.TIME:
        return rs.getTime(index, getCalendar());
    case Types.DATE:
        return rs.getDate(index);
    case Types.TIMESTAMP:
        return rs.getTimestamp(index, getCalendar());
    case Types.FLOAT:
    case Types.DOUBLE:
        double doubleVal = rs.getDouble(index);
        return (rs.wasNull() ? null : new Double(doubleVal));
    case Types.REAL:
        float floatVal = rs.getFloat(index);
        return (rs.wasNull() ? null : new Float(floatVal));
    case Types.SMALLINT:
        short shortVal = rs.getShort(index);
        return (rs.wasNull() ? null : new Short(shortVal));
    case Types.TINYINT:
        byte byteVal = rs.getByte(index);
        return (rs.wasNull() ? null : new Byte(byteVal));
    case Types.LONGVARBINARY:
    case Types.VARBINARY:
    case Types.BINARY:
        return rs.getBytes(index);
    case Types.BLOB:
        Blob blob = rs.getBlob(index);
        return (blob == null ? null : blob.getBinaryStream());
    case Types.CLOB:
        return rs.getClob(index);
    case Types.BIGINT:
        long longVal = rs.getLong(index);
        return (rs.wasNull() ? null : new Long(longVal));
    case Types.BIT:
        boolean boolVal = rs.getBoolean(index);
        return (rs.wasNull() ? null : new Boolean(boolVal));
    default:
        Object value = rs.getObject(index);
        return (rs.wasNull() ? null : value);
    }
}

From source file:org.jfree.data.jdbc.JDBCCategoryDataset.java

/**
 * Populates the dataset by executing the supplied query against the
 * existing database connection.  If no connection exists then no action
 * is taken.//  w w  w .j  av  a 2 s  . c o  m
 * <p>
 * The results from the query are extracted and cached locally, thus
 * applying an upper limit on how many rows can be retrieved successfully.
 *
 * @param con  the connection.
 * @param query  the query.
 *
 * @throws SQLException if there is a problem executing the query.
 */
public void executeQuery(Connection con, String query) throws SQLException {

    Statement statement = null;
    ResultSet resultSet = null;
    try {
        statement = con.createStatement();
        resultSet = statement.executeQuery(query);
        ResultSetMetaData metaData = resultSet.getMetaData();

        int columnCount = metaData.getColumnCount();

        if (columnCount < 2) {
            throw new SQLException("JDBCCategoryDataset.executeQuery() : insufficient columns "
                    + "returned from the database.");
        }

        // Remove any previous old data
        int i = getRowCount();
        while (--i >= 0) {
            removeRow(i);
        }

        while (resultSet.next()) {
            // first column contains the row key...
            Comparable rowKey = resultSet.getString(1);
            for (int column = 2; column <= columnCount; column++) {

                Comparable columnKey = metaData.getColumnName(column);
                int columnType = metaData.getColumnType(column);

                switch (columnType) {
                case Types.TINYINT:
                case Types.SMALLINT:
                case Types.INTEGER:
                case Types.BIGINT:
                case Types.FLOAT:
                case Types.DOUBLE:
                case Types.DECIMAL:
                case Types.NUMERIC:
                case Types.REAL: {
                    Number value = (Number) resultSet.getObject(column);
                    if (this.transpose) {
                        setValue(value, columnKey, rowKey);
                    } else {
                        setValue(value, rowKey, columnKey);
                    }
                    break;
                }
                case Types.DATE:
                case Types.TIME:
                case Types.TIMESTAMP: {
                    Date date = (Date) resultSet.getObject(column);
                    Number value = new Long(date.getTime());
                    if (this.transpose) {
                        setValue(value, columnKey, rowKey);
                    } else {
                        setValue(value, rowKey, columnKey);
                    }
                    break;
                }
                case Types.CHAR:
                case Types.VARCHAR:
                case Types.LONGVARCHAR: {
                    String string = (String) resultSet.getObject(column);
                    try {
                        Number value = Double.valueOf(string);
                        if (this.transpose) {
                            setValue(value, columnKey, rowKey);
                        } else {
                            setValue(value, rowKey, columnKey);
                        }
                    } catch (NumberFormatException e) {
                        // suppress (value defaults to null)
                    }
                    break;
                }
                default:
                    // not a value, can't use it (defaults to null)
                    break;
                }
            }
        }

        fireDatasetChanged(new DatasetChangeInfo());
        //TODO: fill in real change info
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (Exception e) {
                // report this?
            }
        }
        if (statement != null) {
            try {
                statement.close();
            } catch (Exception e) {
                // report this?
            }
        }
    }
}

From source file:br.bookmark.db.util.ResultSetUtils.java

/**
 * Map JDBC objects to Java equivalents.
 * Used by getBean() and getBeans()./*from ww  w.  j ava 2 s.c o m*/
 * <p>
 * Some types not supported.
 * Many not work with all drivers.
 * <p>
 * Makes binary conversions of BIGINT, DATE, DECIMAL, DOUBLE, FLOAT, INTEGER,
 * REAL, SMALLINT, TIME, TIMESTAMP, TINYINT.
 * Makes Sting conversions of CHAR, CLOB, VARCHAR, LONGVARCHAR, BLOB, LONGVARBINARY,
 * VARBINARY.
 * <p>
 * DECIMAL, INTEGER, SMALLINT, TIMESTAMP, CHAR, VARCHAR tested with MySQL and Poolman.
 * Others not guaranteed.
 * @param classeDestino 
 * @throws NoSuchFieldException 
 * @throws SecurityException 
 */
private static void putEntry(Map properties, ResultSetMetaData metaData, ResultSet resultSet, int i,
        Class classeDestino) throws Exception {

    /*
    In a perfect universe, this would be enough
    properties.put(
        metaData.getColumnName(i),
        resultSet.getObject(i));
    But only String, Timestamp, and Integer seem to get through that way.
    */

    String columnName = metaData.getColumnName(i);

    // Testa se  uma FK
    /*Field[] fields = classeDestino.getDeclaredFields();
    for (int j = 0; j < fields.length; j++) {
    if (fields[j].getAnnotation(DBFK.class) != null) {
        properties.put(columnName, resultSet.getString(i));
    }
    }*/
    //System.out.println(i+"-"+metaData.getColumnType(i));
    switch (metaData.getColumnType(i)) {

    // http://java.sun.com/j2se/1.3.0/docs/api/java/sql/Types.html

    case Types.BIGINT:
        properties.put(columnName, new Long(resultSet.getLong(i)));
        break;

    case Types.DATE:
        properties.put(columnName, resultSet.getDate(i));
        break;

    case Types.DECIMAL:
    case Types.DOUBLE:
        properties.put(columnName, new Double(resultSet.getDouble(i)));
        break;

    case Types.FLOAT:
        properties.put(columnName, new Float(resultSet.getFloat(i)));
        break;

    case Types.INTEGER:
        int valor = 0;
        try { // Se o campo esta vazio d erro
            valor = resultSet.getInt(i);
        } catch (SQLException e) {
        }
        properties.put(columnName, new Integer(valor));
        break;

    case Types.REAL:
        properties.put(columnName, new Double(resultSet.getString(i)));
        break;

    case Types.SMALLINT:
        properties.put(columnName, new Short(resultSet.getShort(i)));
        break;

    case Types.TIME:
        properties.put(columnName, resultSet.getTime(i));
        break;

    case Types.TIMESTAMP:
        properties.put(columnName, resultSet.getTimestamp(i));
        break;

    // :FIXME: Throws java.lang.ClassCastException: java.lang.Integer
    // :FIXME: with Poolman and MySQL unless use getString.
    case Types.TINYINT:
        properties.put(columnName, new Byte(resultSet.getString(i)));
        break;

    case Types.CHAR:
    case Types.CLOB:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        // :FIXME: Handle binaries differently?
    case Types.BLOB:
    case Types.LONGVARBINARY:
    case Types.VARBINARY:
        properties.put(columnName, resultSet.getString(i));
        break;

    /*
        :FIXME: Add handlers for
        ARRAY
        BINARY
        BIT
        DISTINCT
        JAVA_OBJECT
        NULL
        NUMERIC
        OTHER
        REF
        STRUCT
    */

    // Otherwise, pass as *String property to be converted
    default:
        properties.put(columnName + "String", resultSet.getString(i));
        break;
    } // end switch

}

From source file:org.pentaho.metadata.util.SQLModelGenerator.java

private static DataType converDataType(int type) {
    switch (type) {
    case Types.FLOAT:
    case Types.BIT:
    case Types.DOUBLE:
    case Types.SMALLINT:
    case Types.REAL:
    case Types.DECIMAL:
    case Types.BIGINT:
    case Types.INTEGER:
    case Types.NUMERIC:
        return DataType.NUMERIC;

    case Types.BINARY:
    case Types.CLOB:
    case Types.BLOB:
        return DataType.BINARY;

    case Types.BOOLEAN:
        return DataType.BOOLEAN;

    case Types.DATE:
        return DataType.DATE;

    case Types.TIMESTAMP:
        return DataType.DATE;

    case Types.LONGVARCHAR:
    case Types.VARCHAR:
        return DataType.STRING;

    default:/*  ww  w. j  a  v a  2 s. com*/
        return DataType.UNKNOWN;
    }
}

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

public static Table putResultsInTable(final ResultSet rs, int maxResultSize, final boolean showRowNumbers,
        String... excludeValues) throws SQLException {

    final Table table = createTable();
    table.setImmediate(true);//from   w w  w.  j a va2  s . c om
    table.setSortEnabled(true);
    table.setSelectable(true);
    table.setMultiSelect(true);
    table.setColumnReorderingAllowed(true);
    table.setColumnReorderingAllowed(true);
    table.setColumnCollapsingAllowed(true);

    final ResultSetMetaData meta = rs.getMetaData();
    int columnCount = meta.getColumnCount();
    table.addContainerProperty("#", Integer.class, null);
    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;
            }
            table.addContainerProperty(i, typeClass, null);
            table.setColumnHeader(i, columnName);
        } 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 = new BigDecimal(-1);
                    }
                    if (!(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 = new Long(-1);
                    }

                    if (!(o instanceof Long)) {
                        o = new Long(castToNumber(o.toString()));
                    }
                    break;
                default:
                    break;
                }
                row[rowIndex] = o == null ? NULL_TEXT : o;
                rowIndex++;
            }
        }
        table.addItem(row, rowNumber);
        rowNumber++;
    }

    if (rowNumber < 100) {
        table.setColumnWidth("#", 18);
    } else if (rowNumber < 1000) {
        table.setColumnWidth("#", 25);
    } else {
        table.setColumnWidth("#", 30);
    }

    if (!showRowNumbers) {
        table.setColumnCollapsed("#", true);
    }

    return table;
}