Example usage for java.sql Types BIGINT

List of usage examples for java.sql Types BIGINT

Introduction

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

Prototype

int BIGINT

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

Click Source Link

Document

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

Usage

From source file:com.cloudera.sqoop.mapreduce.db.DataDrivenDBInputFormat.java

/**
 * @return the DBSplitter implementation to use to divide the table/query
 * into InputSplits./*ww  w  .  ja  v a 2  s .  c o  m*/
 */
protected DBSplitter getSplitter(int sqlDataType) {
    switch (sqlDataType) {
    case Types.NUMERIC:
    case Types.DECIMAL:
        return new BigDecimalSplitter();

    case Types.BIT:
    case Types.BOOLEAN:
        return new BooleanSplitter();

    case Types.INTEGER:
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.BIGINT:
        return new IntegerSplitter();

    case Types.REAL:
    case Types.FLOAT:
    case Types.DOUBLE:
        return new FloatSplitter();

    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        return new TextSplitter();

    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
        return new DateSplitter();

    default:
        // TODO: Support BINARY, VARBINARY, LONGVARBINARY, DISTINCT, CLOB,
        // BLOB, ARRAY, STRUCT, REF, DATALINK, and JAVA_OBJECT.
        return null;
    }
}

From source file:com.opencsv.ResultSetHelperService.java

private String getColumnValue(ResultSet rs, int colType, int colIndex, boolean trim, String dateFormatString,
        String timestampFormatString) throws SQLException, IOException {

    String value = "";

    switch (colType) {
    case Types.BIT:
    case Types.JAVA_OBJECT:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getObject(colIndex), "");
        value = ObjectUtils.toString(rs.getObject(colIndex), "");
        break;/*from   w w w  .j av  a 2 s .  c om*/
    case Types.BOOLEAN:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getBoolean(colIndex));
        value = ObjectUtils.toString(rs.getBoolean(colIndex));
        break;
    case Types.NCLOB: // todo : use rs.getNClob
    case Types.CLOB:
        Clob c = rs.getClob(colIndex);
        if (c != null) {
            StrBuilder sb = new StrBuilder();
            sb.readFrom(c.getCharacterStream());
            value = sb.toString();
        }
        break;
    case Types.BIGINT:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getLong(colIndex));
        value = ObjectUtils.toString(rs.getLong(colIndex));
        break;
    case Types.DECIMAL:
    case Types.REAL:
    case Types.NUMERIC:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getBigDecimal(colIndex), "");
        value = ObjectUtils.toString(rs.getBigDecimal(colIndex), "");
        break;
    case Types.DOUBLE:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getDouble(colIndex));
        value = ObjectUtils.toString(rs.getDouble(colIndex));
        break;
    case Types.FLOAT:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getFloat(colIndex));
        value = ObjectUtils.toString(rs.getFloat(colIndex));
        break;
    case Types.INTEGER:
    case Types.TINYINT:
    case Types.SMALLINT:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getInt(colIndex));
        value = ObjectUtils.toString(rs.getInt(colIndex));
        break;
    case Types.DATE:
        java.sql.Date date = rs.getDate(colIndex);
        if (date != null) {
            SimpleDateFormat df = new SimpleDateFormat(dateFormatString);
            value = df.format(date);
        }
        break;
    case Types.TIME:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getTime(colIndex), "");
        value = ObjectUtils.toString(rs.getTime(colIndex), "");
        break;
    case Types.TIMESTAMP:
        value = handleTimestamp(rs.getTimestamp(colIndex), timestampFormatString);
        break;
    case Types.NVARCHAR: // todo : use rs.getNString
    case Types.NCHAR: // todo : use rs.getNString
    case Types.LONGNVARCHAR: // todo : use rs.getNString
    case Types.LONGVARCHAR:
    case Types.VARCHAR:
    case Types.CHAR:
        String columnValue = rs.getString(colIndex);
        if (trim && columnValue != null) {
            value = columnValue.trim();
        } else {
            value = columnValue;
        }
        break;
    default:
        value = "";
    }

    if (rs.wasNull() || value == null) {
        value = "";
    }

    return value;
}

From source file:co.nubetech.apache.hadoop.DataDrivenDBInputFormat.java

/**
 * @return the DBSplitter implementation to use to divide the table/query
 *         into InputSplits.//  w  w w . j a  v a  2  s  . co  m
 */
protected DBSplitter getSplitter(int sqlDataType) {
    switch (sqlDataType) {
    case Types.NUMERIC:
    case Types.DECIMAL:
        return new BigDecimalSplitter();

    case Types.BIT:
    case Types.BOOLEAN:
        return new BooleanSplitter();

    case Types.INTEGER:
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.BIGINT:
        return new IntegerSplitter();

    case Types.REAL:
    case Types.FLOAT:
    case Types.DOUBLE:
        return new FloatSplitter();

    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        return new TextSplitter();

    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
        return new DateSplitter();

    default:
        // TODO: Support BINARY, VARBINARY, LONGVARBINARY, DISTINCT, CLOB,
        // BLOB, ARRAY
        // STRUCT, REF, DATALINK, and JAVA_OBJECT.
        return null;
    }
}

From source file:com.bt.aloha.dao.StateInfoDaoImpl.java

public void add(StateInfoBase<T> info, String collectionTypeName) {
    if (collectionTypeName == null)
        throw new IllegalArgumentException("Cannot add null collection type to collection.");

    if (info == null)
        throw new IllegalArgumentException("Cannot add null info object to collection.");

    if (info.getId() == null)
        throw new IllegalArgumentException("Cannot add info object with null id to collection.");

    try {/*from   www  .j a va  2 s.  c  om*/
        Object[] params = new Object[] { info.getId(), collectionTypeName, info.getVersionId(),
                info.getLastUsedTime(), info.isDead() ? 1 : 0,
                new SqlLobValue(new ObjectSerialiser().serialise(info)), };
        int[] types = new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BIGINT, Types.INTEGER,
                Types.BLOB };
        getJdbcTemplate().update(INSERT_SQL, params, types);
    } catch (DataIntegrityViolationException e) {
        throw new IllegalArgumentException(
                String.format("Info %s already exists in database, use replaceDialog instead", info.getId()),
                e);
    } catch (DataAccessException e) {
        throw new IllegalArgumentException(String.format("Cannot add info %s to database", info.getId()), e);
    }
}

From source file:co.nubetech.hiho.mapreduce.lib.db.apache.DataDrivenDBInputFormat.java

/**
 * @return the DBSplitter implementation to use to divide the table/query into InputSplits.
 *///from   w  w  w.  j a  v a 2 s  .c  om
protected DBSplitter getSplitter(int sqlDataType) {
    switch (sqlDataType) {
    case Types.NUMERIC:
    case Types.DECIMAL:
        return new BigDecimalSplitter();

    case Types.BIT:
    case Types.BOOLEAN:
        return new BooleanSplitter();

    case Types.INTEGER:
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.BIGINT:
        return new IntegerSplitter();

    case Types.REAL:
    case Types.FLOAT:
    case Types.DOUBLE:
        return new FloatSplitter();

    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        return new TextSplitter();

    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
        return new DateSplitter();

    default:
        // TODO: Support BINARY, VARBINARY, LONGVARBINARY, DISTINCT, CLOB, BLOB, ARRAY
        // STRUCT, REF, DATALINK, and JAVA_OBJECT.
        return null;
    }
}

From source file:com.xpfriend.fixture.cast.temp.TypeConverter.java

private static Class<?> getJavaType(int sqltype, int precision, int scale) {
    switch (sqltype) {
    case Types.BIGINT:
        return Long.class;
    case Types.BIT:
        return Boolean.class;
    case Types.BOOLEAN:
        return Boolean.class;
    case Types.CHAR:
        return String.class;
    case Types.DECIMAL:
        return getNumericType(precision, scale);
    case Types.DOUBLE:
        return Double.class;
    case Types.FLOAT:
        return Double.class;
    case Types.INTEGER:
        return Integer.class;
    case Types.LONGVARCHAR:
        return String.class;
    case Types.NUMERIC:
        return getNumericType(precision, scale);
    case Types.REAL:
        return Float.class;
    case Types.SMALLINT:
        return Short.class;
    case Types.DATE:
        return java.sql.Timestamp.class;
    case Types.TIME:
        return java.sql.Time.class;
    case Types.TIMESTAMP:
        return java.sql.Timestamp.class;
    case Types.TINYINT:
        return Byte.class;
    case Types.VARCHAR:
        return String.class;
    case Types.BLOB:
        return byte[].class;
    case Types.LONGVARBINARY:
        return byte[].class;
    case Types.CLOB:
        return String.class;
    case Types.BINARY:
        return byte[].class;
    case Types.VARBINARY:
        return byte[].class;
    case Types.NVARCHAR:
        return String.class;
    case Types.NCHAR:
        return String.class;
    case Types.LONGNVARCHAR:
        return String.class;
    case -155://from   w  ww. j ava  2s. c o m
        return java.sql.Timestamp.class;
    default:
        return Object.class;
    }
}

From source file:dk.netarkivet.harvester.datamodel.ScheduleDBDAO.java

/** Sets the first twelve parameters of a Schedule in the order.
 * name, comments, startdate, enddate, maxrepeats,
 * timeunit, numtimeunits, anytime, onminute, onhour,
 * ondayofweek, ondayofmonth//from  w  w w .  j  a  v  a2  s  .  co  m
 * @param s a prepared SQL statement
 * @param schedule a given schedule.
 * @throws SQLException If the operation fails.
 */
private void setScheduleParameters(PreparedStatement s, Schedule schedule) throws SQLException {
    DBUtils.setName(s, 1, schedule, Constants.MAX_NAME_SIZE);
    DBUtils.setComments(s, 2, schedule, Constants.MAX_COMMENT_SIZE);
    final Date startDate = schedule.getStartDate();
    final int fieldNum = 3;
    DBUtils.setDateMaybeNull(s, fieldNum, startDate);
    if (schedule instanceof TimedSchedule) {
        TimedSchedule ts = (TimedSchedule) schedule;
        DBUtils.setDateMaybeNull(s, 4, ts.getEndDate());
        s.setNull(5, Types.BIGINT);
    } else {
        s.setNull(4, Types.DATE);
        RepeatingSchedule rs = (RepeatingSchedule) schedule;
        s.setLong(5, rs.getRepeats());
    }
    Frequency freq = schedule.getFrequency();
    s.setInt(6, freq.ordinal());
    s.setInt(7, freq.getNumUnits());
    s.setBoolean(8, freq.isAnytime());
    DBUtils.setIntegerMaybeNull(s, 9, freq.getOnMinute());
    DBUtils.setIntegerMaybeNull(s, 10, freq.getOnHour());
    DBUtils.setIntegerMaybeNull(s, 11, freq.getOnDayOfWeek());
    DBUtils.setIntegerMaybeNull(s, 12, freq.getOnDayOfMonth());
}

From source file:com.fns.grivet.repo.JdbcEntityRepository.java

@Override
public List<EntityAttributeValue> findByEntityId(Long eid) {
    String sql = QueryBuilder.newInstance().obtainValuesForOneEntity().build();
    log.trace(String.format("JdbcEntityRepository.findById[sql=%s]", sql));
    return mapRows(jdbcTemplate.query(sql, new SqlRowSetResultSetExtractor(),
            new SqlParameterValue(Types.BIGINT, eid)));
}

From source file:com.nextep.designer.dbgm.services.impl.DataService.java

@Override
public void addDataline(IDataSet set, IDataLine... lines) {
    Connection localConn = null;//from ww w  .j a v  a 2 s .  com
    PreparedStatement stmt = null;
    IStorageHandle handle = set.getStorageHandle();
    if (handle == null) {
        storageService.createDataSetStorage(set);
        handle = set.getStorageHandle();
    }
    try {
        localConn = storageService.getLocalConnection();
        final String insertStmt = handle.getInsertStatement();
        stmt = localConn.prepareStatement(insertStmt);
        for (IDataLine line : lines) {
            int col = 1;
            // For repository handles, we specify the row id
            // if (handle.isRepositoryHandle()) {
            if (line.getRowId() == 0) {
                stmt.setNull(col++, Types.BIGINT);
            } else {
                stmt.setLong(col++, line.getRowId());
            }
            // }
            // Processing line data
            for (IReference r : set.getColumnsRef()) {
                final IColumnValue value = line.getColumnValue(r);
                Object valueObj = null;
                if (value != null) {
                    valueObj = value.getValue();
                    if (valueObj != null) {
                        stmt.setObject(col, valueObj);
                    } else {
                        IBasicColumn c = (IBasicColumn) VersionHelper.getReferencedItem(r);
                        int jdbcType = storageService.getColumnSqlType(set, c);
                        stmt.setNull(col, jdbcType);
                    }
                }
                // Incrementing column index
                col++;

            }
            stmt.addBatch();
        }
        stmt.executeBatch();
        localConn.commit();
    } catch (SQLException e) {
        LOGGER.error(DBGMMessages.getString("service.data.addDatalineFailed") + e.getMessage(), //$NON-NLS-1$
                e);
    } finally {
        safeClose(null, stmt, localConn, false);
    }

}