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.store.dao.core.impl.ItemAssocDAOMysqlImpl.java

@Override
public int insertItemAssoc(ItemAssocVO<Integer, Integer> itemAssoc) {
    // validate input parameters
    if (itemAssoc == null) {
        throw new IllegalArgumentException("missing 'itemAssoc'");
    }//from w w w . j  ava2 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    }

    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() };
        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 };
    } 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() };
        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 };
    }
    PreparedStatementCreatorFactory factory = new PreparedStatementCreatorFactory(sqlString.toString(),
            argTypes);
    factory.setReturnGeneratedKeys(true);
    KeyHolder keyHolder = new GeneratedKeyHolder();

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

    // retrieve auto increment id, and set to VO
    itemAssoc.setId(keyHolder.getKey().longValue());

    return rowsAffected;
}

From source file:org.apache.ode.scheduler.simple.jdbc.SchedulerDAOConnectionImpl.java

public boolean insertJob(JobDAO job, String nodeId, boolean loaded) throws DatabaseException {
    if (__log.isDebugEnabled())
        __log.debug("insertJob " + job.getJobId() + " on node " + nodeId + " loaded=" + loaded);

    Connection con = null;/*w ww  .  j a v a2  s. c o  m*/
    PreparedStatement ps = null;
    try {
        int i = 1;
        con = getConnection();
        ps = con.prepareStatement(SAVE_JOB);
        ps.setString(i++, job.getJobId());
        ps.setString(i++, nodeId);
        ps.setLong(i++, job.getScheduledDate());
        ps.setBoolean(i++, loaded);
        ps.setBoolean(i++, job.isTransacted());

        JobDetails details = job.getDetails();

        ps.setObject(i++, details.instanceId, Types.BIGINT);
        ps.setObject(i++, details.mexId, Types.VARCHAR);
        ps.setObject(i++, details.processId, Types.VARCHAR);
        ps.setObject(i++, details.type, Types.VARCHAR);
        ps.setObject(i++, details.channel, Types.VARCHAR);
        ps.setObject(i++, details.correlatorId, Types.VARCHAR);
        ps.setObject(i++, details.correlationKeySet, Types.VARCHAR);
        ps.setObject(i++, details.retryCount, Types.INTEGER);
        ps.setObject(i++, details.inMem, Types.BOOLEAN);

        if (details.detailsExt == null || details.detailsExt.size() == 0) {
            ps.setObject(i++, null, Types.BLOB);
        } else {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            try {
                StreamUtils.write(bos, (Serializable) details.detailsExt);
            } catch (Exception ex) {
                __log.error("Error serializing job detail: " + job.getDetails());
                throw new DatabaseException(ex);
            }
            ps.setObject(i++, bos.toByteArray(), Types.BLOB);
        }

        return ps.executeUpdate() == 1;
    } catch (SQLException se) {
        throw new DatabaseException(se);
    } finally {
        close(ps);
        close(con);
    }
}

From source file:org.apache.syncope.core.util.ImportExport.java

private void setParameters(final String tableName, final Attributes attrs, final Query query) {

    Map<String, Integer> colTypes = new HashMap<String, Integer>();

    final Table table = getTable(tableName);

    for (int i = 0; i < attrs.getLength(); i++) {
        Integer colType = table.getColumn(QualifiedDBIdentifier.newColumn(attrs.getQName(i))).getType();
        if (colType == null) {
            LOG.warn("No column type found for {}", attrs.getQName(i).toUpperCase());
            colType = Types.VARCHAR;
        }//from  ww w  .j av a2s. co  m

        switch (colType) {
        case Types.INTEGER:
        case Types.TINYINT:
        case Types.SMALLINT:
            try {
                query.setParameter(i + 1, Integer.valueOf(attrs.getValue(i)));
            } catch (NumberFormatException e) {
                LOG.error("Unparsable Integer '{}'", attrs.getValue(i));
                query.setParameter(i + 1, attrs.getValue(i));
            }
            break;

        case Types.NUMERIC:
        case Types.DECIMAL:
        case Types.BIGINT:
            try {
                query.setParameter(i + 1, Long.valueOf(attrs.getValue(i)));
            } catch (NumberFormatException e) {
                LOG.error("Unparsable Long '{}'", attrs.getValue(i));
                query.setParameter(i + 1, attrs.getValue(i));
            }
            break;

        case Types.DOUBLE:
            try {
                query.setParameter(i + 1, Double.valueOf(attrs.getValue(i)));
            } catch (NumberFormatException e) {
                LOG.error("Unparsable Double '{}'", attrs.getValue(i));
                query.setParameter(i + 1, attrs.getValue(i));
            }
            break;

        case Types.REAL:
        case Types.FLOAT:
            try {
                query.setParameter(i + 1, Float.valueOf(attrs.getValue(i)));
            } catch (NumberFormatException e) {
                LOG.error("Unparsable Float '{}'", attrs.getValue(i));
                query.setParameter(i + 1, attrs.getValue(i));
            }
            break;

        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            try {
                query.setParameter(i + 1,
                        DateUtils.parseDate(attrs.getValue(i), SyncopeConstants.DATE_PATTERNS),
                        TemporalType.TIMESTAMP);
            } catch (ParseException e) {
                LOG.error("Unparsable Date '{}'", attrs.getValue(i));
                query.setParameter(i + 1, attrs.getValue(i));
            }
            break;

        case Types.BIT:
        case Types.BOOLEAN:
            query.setParameter(i + 1, "1".equals(attrs.getValue(i)) ? Boolean.TRUE : Boolean.FALSE);
            break;

        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
            try {
                query.setParameter(i + 1, Hex.decode(attrs.getValue(i)));
            } catch (IllegalArgumentException e) {
                query.setParameter(i + 1, attrs.getValue(i));
            }
            break;

        case Types.BLOB:
            try {
                query.setParameter(i + 1, Hex.decode(attrs.getValue(i)));
            } catch (IllegalArgumentException e) {
                LOG.warn("Error decoding hex string to specify a blob parameter", e);
                query.setParameter(i + 1, attrs.getValue(i));
            } catch (Exception e) {
                LOG.warn("Error creating a new blob parameter", e);
            }
            break;

        default:
            query.setParameter(i + 1, attrs.getValue(i));
        }
    }
}

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

/**
 * Method useful for SQL SELECT/*from  w w w  . ja  va  2 s.  co  m*/
 * @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:org.opennms.core.db.install.Column.java

/**
 * <p>getColumnSqlType</p>/*from ww w  .j av  a 2 s . co  m*/
 *
 * @return a int.
 * @throws java.lang.Exception if any.
 */
public int getColumnSqlType() throws Exception {
    if (m_type.equals("integer")) {
        return Types.INTEGER;
    } else if (m_type.equals("smallint")) {
        return Types.SMALLINT;
    } else if (m_type.equals("bigint")) {
        return Types.BIGINT;
    } else if (m_type.equals("real")) {
        return Types.REAL;
    } else if (m_type.equals("double precision")) {
        return Types.DOUBLE;
    } else if (m_type.equals("boolean")) {
        return Types.BOOLEAN;
    } else if (m_type.equals("character")) {
        return Types.CHAR;
    } else if (m_type.equals("character varying")) {
        return Types.VARCHAR;
    } else if (m_type.equals("bpchar")) {
        return Types.VARCHAR;
    } else if (m_type.equals("numeric")) {
        return Types.NUMERIC;
    } else if (m_type.equals("text")) {
        return Types.LONGVARCHAR;
    } else if (m_type.equals("timestamp")) {
        return Types.TIMESTAMP;
    } else if (m_type.equals("timestamptz")) {
        return Types.TIMESTAMP;
    } else if (m_type.equals("bytea")) {
        return Types.VARBINARY;
    } else {
        throw new Exception("Do not have a Java SQL type for \"" + m_type + "\"");
    }
}

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

private String getValues(final ResultSet rs, final String columnName, final Integer columnType)
        throws SQLException {

    String res = null;//from  w  ww.j  ava  2 s.c  o  m

    try {
        switch (columnType) {
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
            final InputStream is = rs.getBinaryStream(columnName);
            if (is != null) {
                res = DatatypeConverter.printHexBinary(IOUtils.toByteArray(is));
            }
            break;

        case Types.BLOB:
            final Blob blob = rs.getBlob(columnName);
            if (blob != null) {
                res = DatatypeConverter.printHexBinary(IOUtils.toByteArray(blob.getBinaryStream()));
            }
            break;

        case Types.BIT:
        case Types.BOOLEAN:
            if (rs.getBoolean(columnName)) {
                res = "1";
            } else {
                res = "0";
            }
            break;

        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            final Timestamp timestamp = rs.getTimestamp(columnName);
            if (timestamp != null) {
                res = FormatUtils.format(new Date(timestamp.getTime()));
            }
            break;

        default:
            res = rs.getString(columnName);
        }
    } catch (IOException e) {
        LOG.error("Error retrieving hexadecimal string", e);
    }

    return res;
}

From source file:org.efaps.db.wrapper.AbstractSQLInsertUpdate.java

/**
 * Defines a new column <code>_columnName</code> with {@link Boolean}
 * <code>_value</code> within this SQL insert / update statement.
 *
 * @param _columnName   name of the column
 * @param _value        value of the column
 * @return this SQL statement/*from w  w  w . j  a  v  a2s. c  o m*/
 */
@SuppressWarnings("unchecked")
public STMT column(final String _columnName, final boolean _value) {
    this.columnWithValues
            .add(new AbstractSQLInsertUpdate.AbstractColumnWithValue<Boolean>(_columnName, _value) {
                @Override
                public void set(final int _index, final PreparedStatement _stmt) throws SQLException {
                    if (getValue() == null) {
                        _stmt.setNull(_index, Types.BOOLEAN);
                    } else {
                        _stmt.setBoolean(_index, getValue());
                    }
                }
            });
    return (STMT) this;
}

From source file:org.nuxeo.ecm.core.storage.sql.jdbc.dialect.DialectPostgreSQL.java

@Override
public JDBCInfo getJDBCTypeAndString(ColumnType type) {
    switch (type.spec) {
    case STRING:/*  w w w .ja v  a2  s  .c  om*/
        if (type.isUnconstrained()) {
            return jdbcInfo("varchar", Types.VARCHAR);
        } else if (type.isClob()) {
            return jdbcInfo("text", Types.CLOB);
        } else {
            return jdbcInfo("varchar(%d)", type.length, Types.VARCHAR);
        }
    case ARRAY_STRING:
        if (type.isUnconstrained()) {
            return jdbcInfo("varchar[]", Types.ARRAY, "varchar", Types.VARCHAR);
        } else if (type.isClob()) {
            return jdbcInfo("text[]", Types.ARRAY, "text", Types.CLOB);
        } else {
            return jdbcInfo("varchar(%d)[]", type.length, Types.ARRAY, "varchar", Types.VARCHAR);
        }
    case BOOLEAN:
        return jdbcInfo("bool", Types.BIT);
    case ARRAY_BOOLEAN:
        return jdbcInfo("bool[]", Types.ARRAY, "bool", Types.BOOLEAN);
    case LONG:
        return jdbcInfo("int8", Types.BIGINT);
    case ARRAY_LONG:
        return jdbcInfo("int8[]", Types.ARRAY, "int8", Types.BIGINT);
    case DOUBLE:
        return jdbcInfo("float8", Types.DOUBLE);
    case ARRAY_DOUBLE:
        return jdbcInfo("float8[]", Types.ARRAY, "float8", Types.DOUBLE);
    case TIMESTAMP:
        return jdbcInfo("timestamp", Types.TIMESTAMP);
    case ARRAY_TIMESTAMP:
        return jdbcInfo("timestamp[]", Types.ARRAY, "timestamp", Types.TIMESTAMP);
    case BLOBID:
        return jdbcInfo("varchar(40)", Types.VARCHAR);
    case ARRAY_BLOBID:
        return jdbcInfo("varchar(40)[]", Types.ARRAY, "varchar", Types.VARCHAR);
    // -----
    case NODEID:
    case NODEIDFK:
    case NODEIDFKNP:
    case NODEIDFKMUL:
    case NODEIDFKNULL:
    case NODEIDPK:
    case NODEVAL:
        switch (idType) {
        case VARCHAR:
            return jdbcInfo("varchar(36)", Types.VARCHAR);
        case UUID:
            return jdbcInfo("uuid", Types.OTHER);
        case SEQUENCE:
            return jdbcInfo("int8", Types.BIGINT);
        }
    case NODEARRAY:
        switch (idType) {
        case VARCHAR:
            return jdbcInfo("varchar(36)[]", Types.ARRAY, "varchar", Types.VARCHAR);
        case UUID:
            return jdbcInfo("uuid[]", Types.ARRAY, "uuid", Types.OTHER);
        case SEQUENCE:
            return jdbcInfo("int8[]", Types.ARRAY, "int8", Types.BIGINT);
        }
    case SYSNAME:
        return jdbcInfo("varchar(250)", Types.VARCHAR);
    case SYSNAMEARRAY:
        return jdbcInfo("varchar(250)[]", Types.ARRAY, "varchar", Types.VARCHAR);
    case TINYINT:
        return jdbcInfo("int2", Types.SMALLINT);
    case INTEGER:
        return jdbcInfo("int4", Types.INTEGER);
    case ARRAY_INTEGER:
        return jdbcInfo("int4[]", Types.ARRAY, "int4", Types.INTEGER);
    case AUTOINC:
        return jdbcInfo("serial", Types.INTEGER);
    case FTINDEXED:
        if (compatibilityFulltextTable) {
            return jdbcInfo("tsvector", Types.OTHER);
        } else {
            return jdbcInfo("text", Types.CLOB);
        }
    case FTSTORED:
        if (compatibilityFulltextTable) {
            return jdbcInfo("tsvector", Types.OTHER);
        } else {
            return jdbcInfo("text", Types.CLOB);
        }
    case CLUSTERNODE:
        return jdbcInfo("int4", Types.INTEGER);
    case CLUSTERFRAGS:
        return jdbcInfo("varchar[]", Types.ARRAY, "varchar", Types.VARCHAR);
    }
    throw new AssertionError(type);
}

From source file:org.latticesoft.util.resource.dao.Param.java

private Object readValue(ResultSet rs) throws SQLException {
    Object retVal = null;/*from   w  w w . jav  a  2  s . c o  m*/
    switch (this.sqlType) {
    case Types.VARCHAR:
    case Types.CHAR:
        String s = null;
        if (this.getSqlIndex() == 0) {
            s = rs.getString(this.getSqlName());
        } else {
            s = rs.getString(this.getSqlIndex());
        }
        retVal = s;
        break;
    case Types.BOOLEAN:
        boolean b = false;
        if (this.getSqlIndex() == 0) {
            b = rs.getBoolean(this.getSqlName());
        } else {
            b = rs.getBoolean(this.getSqlIndex());
        }
        retVal = new Boolean(b);
        break;
    case Types.INTEGER:
        int i = 0;
        if (this.getSqlIndex() == 0) {
            i = rs.getInt(this.getSqlName());
        } else {
            i = rs.getInt(this.getSqlIndex());
        }
        retVal = new Integer(i);
        break;
    case Types.SMALLINT:
        short ss = 0;
        if (this.getSqlIndex() == 0) {
            ss = rs.getShort(this.getSqlName());
        } else {
            ss = rs.getShort(this.getSqlIndex());
        }
        retVal = new Short(ss);
        break;
    case Types.TINYINT:
        byte bb = 0;
        if (this.getSqlIndex() == 0) {
            bb = rs.getByte(this.getSqlName());
        } else {
            bb = rs.getByte(this.getSqlIndex());
        }
        retVal = new Byte(bb);
        break;
    case Types.BIGINT:
        long l = 0;
        if (this.getSqlIndex() == 0) {
            l = rs.getLong(this.getSqlName());
        } else {
            l = rs.getLong(this.getSqlIndex());
        }
        retVal = new Long(l);
        break;
    case Types.DOUBLE:
        double dd = 0;
        if (this.getSqlIndex() == 0) {
            dd = rs.getDouble(this.getSqlName());
        } else {
            dd = rs.getDouble(this.getSqlIndex());
        }
        retVal = new Double(dd);
        break;
    case Types.FLOAT:
        float f = 0;
        if (this.getSqlIndex() == 0) {
            f = rs.getFloat(this.getSqlName());
        } else {
            f = rs.getFloat(this.getSqlIndex());
        }
        retVal = new Float(f);
        break;
    case Types.NUMERIC:
        BigDecimal bd = null;
        if (this.getSqlIndex() == 0) {
            bd = rs.getBigDecimal(this.getSqlName());
        } else {
            bd = rs.getBigDecimal(this.getSqlIndex());
        }
        retVal = bd;
        break;
    case Types.TIMESTAMP:
        Timestamp ts = null;
        if (this.getSqlIndex() == 0) {
            ts = rs.getTimestamp(this.getSqlName());
        } else {
            ts = rs.getTimestamp(this.getSqlIndex());
        }
        retVal = ts;
        break;
    default:
        if (this.getSqlIndex() == 0) {
            retVal = rs.getObject(this.getSqlName());
        } else {
            retVal = rs.getObject(this.getSqlIndex());
        }
        break;
    }
    if (log.isDebugEnabled()) {
        log.debug(this.getAttribute() + "=" + retVal);
    }
    return retVal;
}

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  ww  w  . j  ava2  s.co m*/
        return null;
    }
}