Example usage for java.sql Types BOOLEAN

List of usage examples for java.sql Types BOOLEAN

Introduction

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

Prototype

int BOOLEAN

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

Click Source Link

Document

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

Usage

From source file:org.easyrec.plugin.arm.store.dao.impl.RuleminingItemAssocDAOMysqlImpl.java

@Override
public int insertOrUpdateItemAssoc(ItemAssocVO<Integer, Integer> itemAssoc) {
    // validate input parameters
    if (itemAssoc == null) {
        throw new IllegalArgumentException("missing 'itemAssoc'");
    }//w  w  w  .j  a  v  a  2 s . c o m

    // validate unique key
    validateUniqueKey(itemAssoc);
    validateAssocValue(itemAssoc);
    validateViewType(itemAssoc);

    if (logger.isDebugEnabled()) {
        logger.debug("inserting 'itemAssoc': " + itemAssoc);
    }

    // @HINT: maybe use UniqueIdService later (instead of auto_imcrement)
    StringBuilder sqlString = new StringBuilder("INSERT INTO ");
    sqlString.append(DEFAULT_TABLE_NAME);
    sqlString.append(" (");
    sqlString.append(DEFAULT_TENANT_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_ITEM_FROM_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_ITEM_FROM_TYPE_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_ASSOC_TYPE_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_ASSOC_VALUE_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_ITEM_TO_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_ITEM_TO_TYPE_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_SOURCE_TYPE_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_SOURCE_INFO_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_VIEW_TYPE_COLUMN_NAME);
    sqlString.append(", ");
    if (itemAssoc.isActive() != null) {
        sqlString.append(DEFAULT_ACTIVE_COLUMN_NAME);
        sqlString.append(", ");
    }
    sqlString.append(DEFAULT_CHANGE_DATE_COLUMN_NAME);
    if (itemAssoc.getChangeDate() == null) {
        itemAssoc.setChangeDate(new Date(System.currentTimeMillis()));
    }
    if (itemAssoc.isActive() != null) {
        sqlString.append(") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    } else {
        sqlString.append(") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    }

    sqlString.append(" ON DUPLICATE KEY UPDATE ");
    sqlString.append(DEFAULT_ASSOC_VALUE_COLUMN_NAME);
    sqlString.append("=?, ");
    sqlString.append(DEFAULT_VIEW_TYPE_COLUMN_NAME);
    sqlString.append("=?, ");
    sqlString.append(DEFAULT_SOURCE_INFO_COLUMN_NAME);
    sqlString.append("=?, ");
    if (itemAssoc.isActive() != null) {
        sqlString.append(DEFAULT_ACTIVE_COLUMN_NAME);
        sqlString.append("=?, ");
    }
    sqlString.append(DEFAULT_CHANGE_DATE_COLUMN_NAME);
    sqlString.append("=?");

    Object[] args;
    int[] argTypes;
    if (itemAssoc.isActive() != null) {
        args = new Object[] { itemAssoc.getTenant(), itemAssoc.getItemFrom().getItem(),
                itemAssoc.getItemFrom().getType(), itemAssoc.getAssocType(), itemAssoc.getAssocValue(),
                itemAssoc.getItemTo().getItem(), itemAssoc.getItemTo().getType(), itemAssoc.getSourceType(),
                itemAssoc.getSourceInfo(), itemAssoc.getViewType(), itemAssoc.isActive(),
                itemAssoc.getChangeDate(), itemAssoc.getAssocValue(), itemAssoc.getViewType(),
                itemAssoc.getSourceInfo(), itemAssoc.isActive(), itemAssoc.getChangeDate() };
        argTypes = new int[] { Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.DOUBLE,
                Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.BOOLEAN,
                Types.TIMESTAMP, Types.DOUBLE, Types.INTEGER, Types.VARCHAR, Types.BOOLEAN, Types.TIMESTAMP, };
    } else {
        args = new Object[] { itemAssoc.getTenant(), itemAssoc.getItemFrom().getItem(),
                itemAssoc.getItemFrom().getType(), itemAssoc.getAssocType(), itemAssoc.getAssocValue(),
                itemAssoc.getItemTo().getItem(), itemAssoc.getItemTo().getType(), itemAssoc.getSourceType(),
                itemAssoc.getSourceInfo(), itemAssoc.getViewType(), itemAssoc.getChangeDate(),
                itemAssoc.getAssocValue(), itemAssoc.getViewType(), itemAssoc.getSourceInfo(),
                itemAssoc.getChangeDate() };
        argTypes = new int[] { Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.DOUBLE,
                Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.TIMESTAMP,
                Types.DOUBLE, Types.INTEGER, Types.VARCHAR, Types.TIMESTAMP, };
    }
    PreparedStatementCreatorFactory factory = new PreparedStatementCreatorFactory(sqlString.toString(),
            argTypes);

    int rowsAffected = getJdbcTemplate().update(factory.newPreparedStatementCreator(args));

    return rowsAffected;
}

From source file:org.easyrec.plugin.profileduke.store.dao.impl.ProfileSimilarityItemAssocDAOMysqlImpl.java

public int insertOrUpdateItemAssoc(ItemAssocVO<Integer, Integer> itemAssoc) {
    // validate input parameters
    if (itemAssoc == null) {
        throw new IllegalArgumentException("missing 'itemAssoc'");
    }/* w  w w. j a  va 2  s.com*/

    // validate unique key
    validateUniqueKey(itemAssoc);
    validateAssocValue(itemAssoc);
    validateViewType(itemAssoc);

    if (logger.isDebugEnabled()) {
        logger.debug("inserting 'itemAssoc': " + itemAssoc);
    }

    // @HINT: maybe use UniqueIdService later (instead of auto_imcrement)
    StringBuilder sqlString = new StringBuilder("INSERT INTO ");
    sqlString.append(DEFAULT_TABLE_NAME);
    sqlString.append(" (");
    sqlString.append(DEFAULT_TENANT_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_ITEM_FROM_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_ITEM_FROM_TYPE_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_ASSOC_TYPE_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_ASSOC_VALUE_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_ITEM_TO_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_ITEM_TO_TYPE_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_SOURCE_TYPE_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_SOURCE_INFO_COLUMN_NAME);
    sqlString.append(", ");
    sqlString.append(DEFAULT_VIEW_TYPE_COLUMN_NAME);
    sqlString.append(", ");
    if (itemAssoc.isActive() != null) {
        sqlString.append(DEFAULT_ACTIVE_COLUMN_NAME);
        sqlString.append(", ");
    }
    sqlString.append(DEFAULT_CHANGE_DATE_COLUMN_NAME);
    if (itemAssoc.getChangeDate() == null) {
        itemAssoc.setChangeDate(new Date(System.currentTimeMillis()));
    }
    if (itemAssoc.isActive() != null) {
        sqlString.append(") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    } else {
        sqlString.append(") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    }

    sqlString.append(" ON DUPLICATE KEY UPDATE ");
    sqlString.append(DEFAULT_ASSOC_VALUE_COLUMN_NAME);
    sqlString.append("=?, ");
    sqlString.append(DEFAULT_VIEW_TYPE_COLUMN_NAME);
    sqlString.append("=?, ");
    sqlString.append(DEFAULT_SOURCE_INFO_COLUMN_NAME);
    sqlString.append("=?, ");
    if (itemAssoc.isActive() != null) {
        sqlString.append(DEFAULT_ACTIVE_COLUMN_NAME);
        sqlString.append("=?, ");
    }
    sqlString.append(DEFAULT_CHANGE_DATE_COLUMN_NAME);
    sqlString.append("=?");

    Object[] args;
    int[] argTypes;
    if (itemAssoc.isActive() != null) {
        args = new Object[] { itemAssoc.getTenant(), itemAssoc.getItemFrom().getItem(),
                itemAssoc.getItemFrom().getType(), itemAssoc.getAssocType(), itemAssoc.getAssocValue(),
                itemAssoc.getItemTo().getItem(), itemAssoc.getItemTo().getType(), itemAssoc.getSourceType(),
                itemAssoc.getSourceInfo(), itemAssoc.getViewType(), itemAssoc.isActive(),
                itemAssoc.getChangeDate(), itemAssoc.getAssocValue(), itemAssoc.getViewType(),
                itemAssoc.getSourceInfo(), itemAssoc.isActive(), itemAssoc.getChangeDate() };
        argTypes = new int[] { Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.DOUBLE,
                Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.BOOLEAN,
                Types.TIMESTAMP, Types.DOUBLE, Types.INTEGER, Types.VARCHAR, Types.BOOLEAN, Types.TIMESTAMP, };
    } else {
        args = new Object[] { itemAssoc.getTenant(), itemAssoc.getItemFrom().getItem(),
                itemAssoc.getItemFrom().getType(), itemAssoc.getAssocType(), itemAssoc.getAssocValue(),
                itemAssoc.getItemTo().getItem(), itemAssoc.getItemTo().getType(), itemAssoc.getSourceType(),
                itemAssoc.getSourceInfo(), itemAssoc.getViewType(), itemAssoc.getChangeDate(),
                itemAssoc.getAssocValue(), itemAssoc.getViewType(), itemAssoc.getSourceInfo(),
                itemAssoc.getChangeDate() };
        argTypes = new int[] { Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.DOUBLE,
                Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.TIMESTAMP,
                Types.DOUBLE, Types.INTEGER, Types.VARCHAR, Types.TIMESTAMP, };
    }
    PreparedStatementCreatorFactory factory = new PreparedStatementCreatorFactory(sqlString.toString(),
            argTypes);

    int rowsAffected = getJdbcTemplate().update(factory.newPreparedStatementCreator(args));

    return rowsAffected;
}

From source file:org.apache.syncope.core.persistence.jpa.content.ContentLoaderHandler.java

private Object[] getParameters(final String tableName, final Attributes attrs) {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

    Map<String, Integer> colTypes = jdbcTemplate.query("SELECT * FROM " + tableName + " WHERE 0=1",
            new ResultSetExtractor<Map<String, Integer>>() {

                @Override/*from w w  w .jav  a 2s  .com*/
                public Map<String, Integer> extractData(final ResultSet rs) throws SQLException {
                    Map<String, Integer> colTypes = new HashMap<>();
                    for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                        colTypes.put(rs.getMetaData().getColumnName(i).toUpperCase(),
                                rs.getMetaData().getColumnType(i));
                    }
                    return colTypes;
                }
            });

    Object[] parameters = new Object[attrs.getLength()];
    for (int i = 0; i < attrs.getLength(); i++) {
        Integer colType = colTypes.get(attrs.getQName(i).toUpperCase());
        if (colType == null) {
            LOG.warn("No column type found for {}", attrs.getQName(i).toUpperCase());
            colType = Types.VARCHAR;
        }

        switch (colType) {
        case Types.INTEGER:
        case Types.TINYINT:
        case Types.SMALLINT:
            try {
                parameters[i] = Integer.valueOf(attrs.getValue(i));
            } catch (NumberFormatException e) {
                LOG.error("Unparsable Integer '{}'", attrs.getValue(i));
                parameters[i] = attrs.getValue(i);
            }
            break;

        case Types.NUMERIC:
        case Types.DECIMAL:
        case Types.BIGINT:
            try {
                parameters[i] = Long.valueOf(attrs.getValue(i));
            } catch (NumberFormatException e) {
                LOG.error("Unparsable Long '{}'", attrs.getValue(i));
                parameters[i] = attrs.getValue(i);
            }
            break;

        case Types.DOUBLE:
            try {
                parameters[i] = Double.valueOf(attrs.getValue(i));
            } catch (NumberFormatException e) {
                LOG.error("Unparsable Double '{}'", attrs.getValue(i));
                parameters[i] = attrs.getValue(i);
            }
            break;

        case Types.REAL:
        case Types.FLOAT:
            try {
                parameters[i] = Float.valueOf(attrs.getValue(i));
            } catch (NumberFormatException e) {
                LOG.error("Unparsable Float '{}'", attrs.getValue(i));
                parameters[i] = attrs.getValue(i);
            }
            break;

        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            try {
                parameters[i] = FormatUtils.parseDate(attrs.getValue(i));
            } catch (ParseException e) {
                LOG.error("Unparsable Date '{}'", attrs.getValue(i));
                parameters[i] = attrs.getValue(i);
            }
            break;

        case Types.BIT:
        case Types.BOOLEAN:
            parameters[i] = "1".equals(attrs.getValue(i)) ? Boolean.TRUE : Boolean.FALSE;
            break;

        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
            try {
                parameters[i] = Hex.decodeHex(attrs.getValue(i).toCharArray());
            } catch (DecoderException | IllegalArgumentException e) {
                parameters[i] = attrs.getValue(i);
            }
            break;

        case Types.BLOB:
            try {
                parameters[i] = Hex.decodeHex(attrs.getValue(i).toCharArray());
            } catch (DecoderException | IllegalArgumentException e) {
                LOG.warn("Error decoding hex string to specify a blob parameter", e);
                parameters[i] = attrs.getValue(i);
            } catch (Exception e) {
                LOG.warn("Error creating a new blob parameter", e);
            }
            break;

        default:
            parameters[i] = attrs.getValue(i);
        }
    }

    return parameters;
}

From source file:org.apache.sqoop.hcat.HCatalogExportTest.java

public void testIntTypes() throws Exception {
    final int TOTAL_RECORDS = 1 * 10;
    String table = getTableName().toUpperCase();
    ColumnGenerator[] cols = new ColumnGenerator[] {
            HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0), "boolean", Types.BOOLEAN,
                    HCatFieldSchema.Type.BOOLEAN, 0, 0, Boolean.TRUE, Boolean.TRUE, KeyType.NOT_A_KEY),
            HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1), "tinyint", Types.INTEGER,
                    HCatFieldSchema.Type.INT, 0, 0, 10, 10, KeyType.NOT_A_KEY),
            HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(2), "smallint", Types.INTEGER,
                    HCatFieldSchema.Type.INT, 0, 0, 100, 100, KeyType.NOT_A_KEY),
            HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(3), "int", Types.INTEGER,
                    HCatFieldSchema.Type.INT, 0, 0, 1000, 1000, KeyType.NOT_A_KEY),
            HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(4), "bigint", Types.BIGINT,
                    HCatFieldSchema.Type.BIGINT, 0, 0, 10000L, 10000L, KeyType.NOT_A_KEY), };
    List<String> addlArgsArray = new ArrayList<String>();
    runHCatExport(addlArgsArray, TOTAL_RECORDS, table, cols);
}

From source file:com.sangupta.fileanalysis.db.DBResultViewer.java

private int getColumnSize(final String tableName, final String columnName, final int columnType) {
    // check if we have the value in database cache
    int size = database.getColSize(tableName, columnName);
    if (size > 0) {
        return size;
    }//from ww  w  .j a  va 2  s.c  o  m

    switch (columnType) {
    case Types.VARCHAR:
        return 255;

    case Types.INTEGER:
        return 10;

    case Types.BOOLEAN:
        return 3;

    case Types.DOUBLE:
        return 14;

    case Types.BIGINT:
        return 20;

    case Types.TIMESTAMP:
        return 26;
    }

    return 10;
}

From source file:org.apache.sqoop.manager.ConnManager.java

/**
 * Resolve a database-specific type to Avro data type.
 * @param sqlType     sql type//from ww  w  .  ja  v a 2  s.  c  om
 * @return            avro type
 */
public Type toAvroType(int sqlType) {
    switch (sqlType) {
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
        return Type.INT;
    case Types.BIGINT:
        return Type.LONG;
    case Types.BIT:
    case Types.BOOLEAN:
        return Type.BOOLEAN;
    case Types.REAL:
        return Type.FLOAT;
    case Types.FLOAT:
    case Types.DOUBLE:
        return Type.DOUBLE;
    case Types.NUMERIC:
    case Types.DECIMAL:
        return Type.STRING;
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
    case Types.LONGNVARCHAR:
    case Types.NVARCHAR:
    case Types.NCHAR:
        return Type.STRING;
    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
        return Type.STRING;
    case Types.BLOB:
    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        return Type.BYTES;
    default:
        throw new IllegalArgumentException("Cannot convert SQL type " + sqlType);
    }
}

From source file:org.batoo.jpa.jdbc.adapter.HsqlAdaptor.java

/**
 * {@inheritDoc}//from w  w w.  j a  v  a2s .c  o m
 * 
 */
@Override
protected String getColumnType(AbstractColumn cd, int sqlType) {
    switch (sqlType) {
    case Types.BLOB:
    case Types.CLOB:
        return "VARBINARY(" + cd.getLength() + ")";
    case Types.VARCHAR:
        return "VARCHAR(" + cd.getLength() + ")";
    case Types.TIME:
        return "TIME";
    case Types.DATE:
        return "DATE";
    case Types.TIMESTAMP:
        return "TIMESTAMP";
    case Types.CHAR:
        return "CHAR";
    case Types.BOOLEAN:
        return "BOOLEAN";
    case Types.TINYINT:
    case Types.SMALLINT:
        return "SMALLINT";
    case Types.INTEGER:
        return "INTEGER";
    case Types.BIGINT:
        return "BIGINT";
    case Types.FLOAT:
        return "FLOAT" + (cd.getPrecision() > 0 ? "(" + cd.getPrecision() + ")" : "");
    case Types.DOUBLE:
        return "DOUBLE" + (cd.getPrecision() > 0 ? "(" + cd.getPrecision() + ")" : "");
    case Types.DECIMAL:
        return "DECIMAL" + (cd.getPrecision() > 0
                ? "(" + cd.getPrecision() + (cd.getScale() > 0 ? "," + cd.getScale() : "") + ")"
                : "");
    }

    throw new IllegalArgumentException("Unhandled sql type: " + sqlType);
}

From source file:org.georepublic.db.utils.ResultSetConverter.java

public static JSONArray convertGeoJson(ResultSet rs) throws SQLException, JSONException {

    JSONArray json = new JSONArray();
    ResultSetMetaData rsmd = rs.getMetaData();

    while (rs.next()) {
        int numColumns = rsmd.getColumnCount();
        JSONObject obj = new JSONObject();
        JSONObject feat = new JSONObject();

        feat.put("type", "Feature");

        for (int i = 1; i < numColumns + 1; i++) {
            String column_name = rsmd.getColumnName(i);

            if (StringUtils.equals(column_name, "the_geom")) {
                continue;
            }/*from   www  .  j  a v a  2  s  .c  o m*/
            if (StringUtils.equals(column_name, "geojson")) {
                continue;
            }
            if (rsmd.getColumnType(i) == java.sql.Types.ARRAY) {
                obj.put(column_name, rs.getArray(column_name));
            } else if (rsmd.getColumnType(i) == java.sql.Types.BIGINT) {
                obj.put(column_name, rs.getInt(column_name));
            } else if (rsmd.getColumnType(i) == java.sql.Types.BOOLEAN) {
                obj.put(column_name, rs.getBoolean(column_name));
            } else if (rsmd.getColumnType(i) == java.sql.Types.BLOB) {
                obj.put(column_name, rs.getBlob(column_name));
            } else if (rsmd.getColumnType(i) == java.sql.Types.DOUBLE) {
                obj.put(column_name, rs.getDouble(column_name));
            } else if (rsmd.getColumnType(i) == java.sql.Types.FLOAT) {
                obj.put(column_name, rs.getFloat(column_name));
            } else if (rsmd.getColumnType(i) == java.sql.Types.INTEGER) {
                obj.put(column_name, rs.getInt(column_name));
            } else if (rsmd.getColumnType(i) == java.sql.Types.NVARCHAR) {
                obj.put(column_name, rs.getNString(column_name));
            } else if (rsmd.getColumnType(i) == java.sql.Types.VARCHAR) {
                obj.put(column_name, rs.getString(column_name));
            } else if (rsmd.getColumnType(i) == java.sql.Types.TINYINT) {
                obj.put(column_name, rs.getInt(column_name));
            } else if (rsmd.getColumnType(i) == java.sql.Types.SMALLINT) {
                obj.put(column_name, rs.getInt(column_name));
            } else if (rsmd.getColumnType(i) == java.sql.Types.DATE) {
                obj.put(column_name, rs.getDate(column_name));
            } else if (rsmd.getColumnType(i) == java.sql.Types.TIMESTAMP) {
                obj.put(column_name, rs.getTimestamp(column_name));
            } else {
                obj.put(column_name, rs.getObject(column_name));
            }
        }

        feat.put("properties", obj);

        try {
            rs.findColumn("lon");
            rs.findColumn("lat");

            JSONObject geo = new JSONObject();
            JSONArray coord = new JSONArray();

            coord.put(rs.getDouble("lon"));
            coord.put(rs.getDouble("lat"));

            geo.put("type", "point");
            geo.put("coordinates", coord);

            feat.put("geometry", geo);
        } catch (Exception ex1) {
            ;
        }

        json.put(feat);
    }

    return json;

}

From source file:org.apache.ddlutils.platform.mssql.MSSqlBuilder.java

/**
 * {@inheritDoc}// w w  w .  j a v a 2  s .c om
 */
protected String getNativeDefaultValue(Column column) {
    // Sql Server wants BIT default values as 0 or 1
    if ((column.getTypeCode() == Types.BIT) || (column.getTypeCode() == Types.BOOLEAN)) {
        return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(), Types.SMALLINT);
    } else {
        return super.getNativeDefaultValue(column);
    }
}

From source file:org.netflux.core.FieldMetadata.java

/**
 * Sets the <code>type</code> of the field that this metadata describes. The currently supported types are: string ({@link java.sql.Types#CHAR},
 * {@link java.sql.Types#VARCHAR}), date ({@link java.sql.Types#DATE}, {@link java.sql.Types#TIMESTAMP}), numeric ({@link java.sql.Types#SMALLINT},
 * {@link java.sql.Types#INTEGER}, {@link java.sql.Types#BIGINT}, {@link java.sql.Types#DECIMAL}, {@link java.sql.Types#FLOAT},
 * {@link java.sql.Types#DOUBLE}) and boolean ({@link java.sql.Types#BOOLEAN}). If the supplied <code>type</code> is not one of
 * the above, an <code>IllegalArgumentException</code> will be thrown.
 * /*  www  . ja v  a2s .co m*/
 * @param type the <code>type</code> of the field that this metadata describes.
 * @throws IllegalArgumentException if the supplied <code>type</code> is not included in the supported types.
 */
public void setType(int type) {
    switch (type) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.DATE:
    case Types.TIMESTAMP:
    case Types.SMALLINT:
    case Types.INTEGER:
    case Types.BIGINT:
    case Types.DECIMAL:
    case Types.FLOAT:
    case Types.DOUBLE:
    case Types.BOOLEAN:
        this.type = type;
        break;
    default:
        if (FieldMetadata.log.isInfoEnabled()) {
            FieldMetadata.log.info(FieldMetadata.messages.getString("exception.unsupported.type"));
        }
        throw new IllegalArgumentException();
    }
}