Example usage for java.sql ResultSet getByte

List of usage examples for java.sql ResultSet getByte

Introduction

In this page you can find the example usage for java.sql ResultSet getByte.

Prototype

byte getByte(String columnLabel) throws SQLException;

Source Link

Document

Retrieves the value of the designated column in the current row of this ResultSet object as a byte in the Java programming language.

Usage

From source file:org.apache.phoenix.mapreduce.index.automation.PhoenixMRJobSubmitter.java

public Map<String, PhoenixAsyncIndex> getCandidateJobs() throws SQLException {
    Properties props = new Properties();
    UpgradeUtil.doNotUpgradeOnFirstConnection(props);
    Connection con = DriverManager.getConnection("jdbc:phoenix:" + zkQuorum);
    Statement s = con.createStatement();
    ResultSet rs = s.executeQuery(CANDIDATE_INDEX_INFO_QUERY);
    Map<String, PhoenixAsyncIndex> candidateIndexes = new HashMap<String, PhoenixAsyncIndex>();
    while (rs.next()) {
        PhoenixAsyncIndex indexInfo = new PhoenixAsyncIndex();
        indexInfo.setIndexType(IndexType.fromSerializedValue(rs.getByte(PhoenixDatabaseMetaData.INDEX_TYPE)));
        indexInfo.setDataTableName(rs.getString(PhoenixDatabaseMetaData.DATA_TABLE_NAME));
        indexInfo.setTableSchem(rs.getString(PhoenixDatabaseMetaData.TABLE_SCHEM));
        indexInfo.setTableName(rs.getString(PhoenixDatabaseMetaData.TABLE_NAME));
        candidateIndexes.put(String.format(IndexTool.INDEX_JOB_NAME_TEMPLATE, indexInfo.getDataTableName(),
                indexInfo.getTableName()), indexInfo);
    }/*from w ww.j  a  v  a  2  s . c o m*/

    return candidateIndexes;
}

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

/**
 * Get value from given ResultSet at given index with given SQL type.
 * /*from  w ww  .j av  a2s .  com*/
 * @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:mum.bigdata.car.recommender.repository.impl.CarRepositoryImpl.java

@Override
public List<Car> buildResult(ResultSet rs) throws SQLException {
    List<Car> cars = new ArrayList<>();
    while (rs.next()) {
        Car car = new Car();
        car.setCid(rs.getLong("car.cid"));
        car.setName(rs.getString("car.name"));
        car.setMake(rs.getString("car.make"));
        car.setModel(rs.getString("car.model"));
        car.setYear(rs.getInt("car.year"));
        car.setMpg(rs.getString("car.mpg"));
        car.setTransmission(rs.getString("car.transmission"));
        car.setDoors(rs.getByte("car.doors"));
        car.setSubmodel(rs.getString("car.submodel"));
        car.setMsrp(rs.getInt("car.msrp"));
        car.setRating(rs.getString("car.rating"));
        car.setConsumerRating(rs.getString("car.customer_rating"));
        car.setPhoto(rs.getString("car.photo"));
        cars.add(car);/*from   w  w  w . j  a  v  a  2 s .c om*/
    }
    return cars;
}

From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityPgSql.CFSecurityPgSqlSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {/*from  ww  w. java  2  s.com*/
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFSecurityPgSqlSchema.class, "getNullableByte",
                e);
    }
}

From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityDb2LUW.CFSecurityDb2LUWSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {//from  w  w  w  .  j a v  a2 s  . c o  m
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFSecurityDb2LUWSchema.class, "getNullableByte",
                e);
    }
}

From source file:net.sf.l2j.gameserver.instancemanager.DimensionalRiftManager.java

private void loadRooms() {
    Connection con = null;//from  w  ww . j a  va2 s  . co  m
    try {
        con = L2DatabaseFactory.getInstance().getConnection();
        PreparedStatement s = con.prepareStatement("SELECT * FROM dimensional_rift");
        ResultSet rs = s.executeQuery();
        while (rs.next()) {
            // 0 waiting room, 1 recruit, 2 soldier, 3 officer, 4 captain ,
            // 5 commander, 6 hero
            byte type = rs.getByte("type");
            byte room_id = rs.getByte("room_id");
            // coords related
            int xMin = rs.getInt("xMin");
            int xMax = rs.getInt("xMax");
            int yMin = rs.getInt("yMin");
            int yMax = rs.getInt("yMax");
            int z1 = rs.getInt("zMin");
            int z2 = rs.getInt("zMax");
            int xT = rs.getInt("xT");
            int yT = rs.getInt("yT");
            int zT = rs.getInt("zT");
            boolean isBossRoom = rs.getByte("boss") > 0;
            if (!_rooms.containsKey(type))
                _rooms.put(type, new FastMap<Byte, DimensionalRiftRoom>());
            _rooms.get(type).put(room_id, new DimensionalRiftRoom(type, room_id, xMin, xMax, yMin, yMax, z1, z2,
                    xT, yT, zT, isBossRoom));
        }
        s.close();
        con.close();
    } catch (Exception e) {
        _log.warn("Can't load Dimension Rift zones. " + e);
    } finally {
        try {
            con.close();
        } catch (Exception e) { /* do nothing */
        }
    }
    int typeSize = _rooms.keySet().size();
    int roomSize = 0;
    for (Byte b : _rooms.keySet())
        roomSize += _rooms.get(b).keySet().size();
    _log.info("DimensionalRiftManager: Loaded " + typeSize + " room types with " + roomSize + " rooms.");
}

From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityOracle.CFSecurityOracleSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {/*from  w w  w.  j  av  a  2 s.co  m*/
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFSecurityOracleSchema.class, "getNullableByte",
                e);
    }
}

From source file:net.sourceforge.msscodefactory.cfsecurity.v2_1.CFSecuritySybase.CFSecuritySybaseSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {/*w w w  .  ja  v  a2s  .c o  m*/
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFSecuritySybaseSchema.class, "getNullableByte",
                e);
    }
}

From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityMySql.CFSecurityMySqlSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {/* w  w w  .j  a v  a 2  s.c o  m*/
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFSecurityMySqlSchema.class, "getNullableByte",
                e);
    }
}

From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityMSSql.CFSecurityMSSqlSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {// w w  w .  ja  v  a 2 s  . c o m
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFSecurityMSSqlSchema.class, "getNullableByte",
                e);
    }
}