当前位置: 首页>>代码示例>>Java>>正文


Java ResultSet.getByte方法代码示例

本文整理汇总了Java中java.sql.ResultSet.getByte方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.getByte方法的具体用法?Java ResultSet.getByte怎么用?Java ResultSet.getByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.ResultSet的用法示例。


在下文中一共展示了ResultSet.getByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getColumnValue

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * 根据JavaBean属性类型名称得到Java8种原始类型下的ResultSet对应序号列的值.
 * @param rs ResultSet实例
 * @param colNum 结果集列序号
 * @param propType 属性类型名称
 * @return 字段值
 */
@Override
public Object getColumnValue(ResultSet rs, int colNum, Class<?> propType) throws SQLException {
    // 将几种常用原始类型放前面优先判断并直接返回结果
    String propTypeName = propType.getName();
    if ("int".equals(propTypeName)) {
        return rs.getInt(colNum);
    } else if ("long".equals(propTypeName)) {
        return rs.getLong(colNum);
    } else if ("double".equals(propTypeName)) {
        return rs.getDouble(colNum);
    } else if ("boolean".equals(propTypeName)) {
        return rs.getBoolean(colNum);
    } else if ("byte".equals(propTypeName)) {
        return rs.getByte(colNum);
    } else if ("short".equals(propTypeName)) {
        return rs.getShort(colNum);
    } else if ("float".equals(propTypeName)) {
        return rs.getFloat(colNum);
    } else if ("char".equals(propTypeName)) {
        return rs.getString(colNum);
    }
    return null;
}
 
开发者ID:blinkfox,项目名称:adept,代码行数:31,代码来源:PrimitiveHandler.java

示例2: acceptToS

import java.sql.ResultSet; //导入方法依赖的package包/类
public boolean acceptToS() {
    boolean disconnectForBeingAFaggot = false;
    if (accountName == null) {
        return true;
    }
    try {
        PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT `tos` FROM accounts WHERE id = ?");
        ps.setInt(1, accId);
        ResultSet rs = ps.executeQuery();

        if (rs.next()) {
            if (rs.getByte("tos") == 1) {
                disconnectForBeingAFaggot = true;
            }
        }
        ps.close();
        rs.close();
        ps = DatabaseConnection.getConnection().prepareStatement("UPDATE accounts SET tos = 1 WHERE id = ?");
        ps.setInt(1, accId);
        ps.executeUpdate();
        ps.close();
    } catch (SQLException e) {
    }
    return disconnectForBeingAFaggot;
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:26,代码来源:MapleClient.java

示例3: PlayerNPCs

import java.sql.ResultSet; //导入方法依赖的package包/类
public PlayerNPCs(ResultSet rs) {
    try {
        CY = rs.getInt("cy");
        name = rs.getString("name");
        hair = rs.getInt("hair");
        face = rs.getInt("face");
        skin = rs.getByte("skin");
        FH = rs.getInt("Foothold");
        RX0 = rs.getInt("rx0");
        RX1 = rs.getInt("rx1");
        npcId = rs.getInt("ScriptId");
        setPosition(new Point(rs.getInt("x"), CY));
        PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT equippos, equipid FROM playernpcs_equip WHERE NpcId = ?");
        ps.setInt(1, rs.getInt("id"));
        ResultSet rs2 = ps.executeQuery();
        while (rs2.next()) {
            equips.put(rs2.getByte("equippos"), rs2.getInt("equipid"));
        }
        rs2.close();
        ps.close();
    } catch (SQLException e) {
    }
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:24,代码来源:PlayerNPCs.java

示例4: Asset

import java.sql.ResultSet; //导入方法依赖的package包/类
private Asset(ResultSet rs) throws SQLException {
    this.assetId = rs.getLong("id");
    this.dbKey = assetDbKeyFactory.newKey(this.assetId);
    this.accountId = rs.getLong("account_id");
    this.name = rs.getString("name");
    this.description = rs.getString("description");
    this.quantityQNT = rs.getLong("quantity");
    this.decimals = rs.getByte("decimals");
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:10,代码来源:Asset.java

示例5: Poll

import java.sql.ResultSet; //导入方法依赖的package包/类
private Poll(ResultSet rs) throws SQLException {
    this.id = rs.getLong("id");
    this.dbKey = pollDbKeyFactory.newKey(this.id);
    this.name = rs.getString("name");
    this.description = rs.getString("description");
    this.options = (String[])rs.getArray("options").getArray();
    this.minNumberOfOptions = rs.getByte("min_num_options");
    this.maxNumberOfOptions = rs.getByte("max_num_options");
    this.optionsAreBinary = rs.getBoolean("binary_options");
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:11,代码来源:Poll.java

示例6: readResult

import java.sql.ResultSet; //导入方法依赖的package包/类
protected void readResult(ResultSet results) throws SQLException {
	while (results.next()) {
		Vector3i pos = new Vector3i(results.getInt("x"), results.getInt("y"), results.getInt("z"));
		UUID world = UUID.fromString(results.getString("world"));
		ActionType type = ActionType.valueCache[results.getByte("type")];
		String cause = results.getString("cause");
		String data = results.getString("data");
		BlockType block = Sponge.getRegistry().getType(BlockType.class, results.getString("AS_Id.value")).get();
		boolean rolledBack = results.getBoolean("rolled_back");
		long timestamp = results.getLong("time");
		lines.add(new LookupLine(pos, world, type, cause, data, block, 1, 0, rolledBack, timestamp));
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:14,代码来源:BlockLookupResult.java

示例7: readResult

import java.sql.ResultSet; //导入方法依赖的package包/类
protected void readResult(ResultSet results) throws SQLException {
	while (results.next()) {
		Vector3i pos = new Vector3i(results.getInt("x"), results.getInt("y"), results.getInt("z"));
		UUID world = UUID.fromString(results.getString("world"));
		ActionType type = ActionType.valueCache[results.getByte("type")];
		String cause = results.getString("cause");
		String data = results.getString("data");
		ItemType item = Sponge.getRegistry().getType(ItemType.class, results.getString("AS_Id.value")).get();
		int count = results.getByte("count");
		int slot = results.getInt("slot");
		boolean rolledBack = results.getBoolean("rolled_back");
		long timestamp = results.getLong("time");
		lines.add(new LookupLine(pos, world, type, cause, data, item, count, slot, rolledBack, timestamp));
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:16,代码来源:ContainerLookupResult.java

示例8: testGetByte

import java.sql.ResultSet; //导入方法依赖的package包/类
public void testGetByte(ResultSet resultSet) throws SQLException {
  try {
    resultSet.getByte(ordinal);
    fail("Was expecting to throw SQLDataException");
  } catch (Exception e) {
    assertThat(e, isA((Class) SQLDataException.class)); // success
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:9,代码来源:AvaticaResultSetConversionsTest.java

示例9: PlayerNPC

import java.sql.ResultSet; //导入方法依赖的package包/类
public PlayerNPC(ResultSet rs) throws Exception {
    super(rs.getInt("ScriptId"), rs.getString("name"));
    hair = rs.getInt("hair");
    secondHair = hair;
    face = rs.getInt("face");
    secondFace = face;
    mapid = rs.getInt("map");
    skin = rs.getByte("skin");
    secondSkin = skin;
    charId = rs.getInt("charid");
    gender = rs.getByte("gender");
    secondGender = gender;
    job = rs.getShort("job");
    elf = rs.getInt("elf");
    faceMarking = rs.getInt("faceMarking");
    setCoords(rs.getInt("x"), rs.getInt("y"), rs.getInt("dir"), rs.getInt("Foothold"));
    String[] pet = rs.getString("pets").split(",");
    for (int i = 0; i < 3; i++) {
        if (pet[i] != null) {
            pets[i] = Integer.parseInt(pet[i]);
        } else {
            pets[i] = 0;
        }
    }

    Connection con = DatabaseConnection.getConnection();
    try (PreparedStatement ps = con.prepareStatement("SELECT * FROM playernpcs_equip WHERE NpcId = ?")) {
        ps.setInt(1, getId());
        try (ResultSet rs2 = ps.executeQuery()) {
            while (rs2.next()) {
                equips.put(rs2.getByte("equippos"), rs2.getInt("equipid"));
                secondEquips.put(rs2.getByte("equippos"), rs2.getInt("equipid"));
            }
        }
    }
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:37,代码来源:PlayerNPC.java

示例10: loadStorage

import java.sql.ResultSet; //导入方法依赖的package包/类
public static MapleStorage loadStorage(int id) {
    MapleStorage ret = null;
    int storeId;
    try {
        Connection con = DatabaseConnection.getConnection();
        PreparedStatement ps = con.prepareStatement("SELECT * FROM storages WHERE accountid = ?");
        ps.setInt(1, id);
        ResultSet rs = ps.executeQuery();

        if (rs.next()) {
            storeId = rs.getInt("storageid");
            ret = new MapleStorage(storeId, rs.getByte("slots"), rs.getInt("meso"), id);
            rs.close();
            ps.close();

            for (Pair<Item, MapleInventoryType> mit : ItemLoader.STORAGE.loadItems(false, id).values()) {
                ret.items.add(mit.getLeft());
            }
        } else {
            storeId = create(id);
            ret = new MapleStorage(storeId, (byte) 4, 0, id);
            rs.close();
            ps.close();
        }
    } catch (SQLException ex) {
        System.err.println("Error loading storage" + ex);
    }
    return ret;
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:30,代码来源:MapleStorage.java

示例11: loadTransaction

import java.sql.ResultSet; //导入方法依赖的package包/类
static TransactionImpl loadTransaction(Connection con, ResultSet rs) throws NxtException.ValidationException {
    try {

        byte type = rs.getByte("type");
        byte subtype = rs.getByte("subtype");
        int timestamp = rs.getInt("timestamp");
        short deadline = rs.getShort("deadline");
        byte[] senderPublicKey = rs.getBytes("sender_public_key");
        long amountNQT = rs.getLong("amount");
        long feeNQT = rs.getLong("fee");
        byte[] referencedTransactionFullHash = rs.getBytes("referenced_transaction_full_hash");
        int ecBlockHeight = rs.getInt("ec_block_height");
        long ecBlockId = rs.getLong("ec_block_id");
        byte[] signature = rs.getBytes("signature");
        long blockId = rs.getLong("block_id");
        int height = rs.getInt("height");
        long id = rs.getLong("id");
        long senderId = rs.getLong("sender_id");
        byte[] attachmentBytes = rs.getBytes("attachment_bytes");
        int blockTimestamp = rs.getInt("block_timestamp");
        byte[] fullHash = rs.getBytes("full_hash");
        byte version = rs.getByte("version");

        ByteBuffer buffer = null;
        if (attachmentBytes != null) {
            buffer = ByteBuffer.wrap(attachmentBytes);
            buffer.order(ByteOrder.LITTLE_ENDIAN);
        }

        TransactionType transactionType = TransactionType.findTransactionType(type, subtype);
        TransactionImpl.BuilderImpl builder = new TransactionImpl.BuilderImpl(version, senderPublicKey,
                amountNQT, feeNQT, timestamp, deadline,
                transactionType.parseAttachment(buffer, version))
                .referencedTransactionFullHash(referencedTransactionFullHash)
                .signature(signature)
                .blockId(blockId)
                .height(height)
                .id(id)
                .senderId(senderId)
                .blockTimestamp(blockTimestamp)
                .fullHash(fullHash);
        if (transactionType.hasRecipient()) {
            long recipientId = rs.getLong("recipient_id");
            if (! rs.wasNull()) {
                builder.recipientId(recipientId);
            }
        }
        if (rs.getBoolean("has_message")) {
            builder.message(new Appendix.Message(buffer, version));
        }
        if (rs.getBoolean("has_encrypted_message")) {
            builder.encryptedMessage(new Appendix.EncryptedMessage(buffer, version));
        }
        if (rs.getBoolean("has_public_key_announcement")) {
            builder.publicKeyAnnouncement(new Appendix.PublicKeyAnnouncement(buffer, version));
        }
        if (rs.getBoolean("has_encrypttoself_message")) {
            builder.encryptToSelfMessage(new Appendix.EncryptToSelfMessage(buffer, version));
        }
        if (version > 0) {
            builder.ecBlockHeight(ecBlockHeight);
            builder.ecBlockId(ecBlockId);
        }

        return builder.build();

    } catch (SQLException e) {
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:71,代码来源:TransactionDb.java

示例12: build

import java.sql.ResultSet; //导入方法依赖的package包/类
public MsSqlChange build(TableMetadataProvider.TableMetadata tableMetadata, ResultSet resultSet, Time time) throws SQLException {
  MsSqlChange change = new MsSqlChange();
  change.timestamp = time.milliseconds();
  change.databaseName = tableMetadata.databaseName();
  change.schemaName = tableMetadata.schemaName();
  change.tableName = tableMetadata.tableName();

  final long sysChangeVersion = resultSet.getLong("__metadata_sys_change_version");
  final long sysChangeCreationVersion = resultSet.getLong("__metadata_sys_change_creation_version");
  final String changeOperation = resultSet.getString("__metadata_sys_change_operation");

  change.metadata = ImmutableMap.of(
      "sys_change_operation", changeOperation,
      "sys_change_creation_version", String.valueOf(sysChangeCreationVersion),
      "sys_change_version", String.valueOf(sysChangeVersion)
  );

  switch (changeOperation) {
    case "I":
      change.changeType = ChangeType.INSERT;
      break;
    case "U":
      change.changeType = ChangeType.UPDATE;
      break;
    case "D":
      change.changeType = ChangeType.DELETE;
      break;
    default:
      throw new UnsupportedOperationException(
          String.format("Unsupported sys_change_operation of '%s'", changeOperation)
      );
  }
  log.trace("build() - changeType = {}", change.changeType);

  change.keyColumns = new ArrayList<>(tableMetadata.keyColumns().size());
  change.valueColumns = new ArrayList<>(tableMetadata.columnSchemas().size());

  for (Map.Entry<String, Schema> kvp : tableMetadata.columnSchemas().entrySet()) {
    String columnName = kvp.getKey();
    Schema schema = kvp.getValue();
    Object value;
    if (Schema.Type.INT8 == schema.type()) {
      // Really lame Microsoft. A tiny int is stored as a single byte with a value of 0-255.
      // Explain how this should be returned as a short?
      value = resultSet.getByte(columnName);
    } else if (Schema.Type.INT32 == schema.type() &&
        Date.LOGICAL_NAME.equals(schema.name())) {
      value = new java.util.Date(
          resultSet.getDate(columnName, calendar).getTime()
      );
    } else if (Schema.Type.INT32 == schema.type() &&
        org.apache.kafka.connect.data.Time.LOGICAL_NAME.equals(schema.name())) {
      value = new java.util.Date(
          resultSet.getTime(columnName, calendar).getTime()
      );
    } else {
      value = resultSet.getObject(columnName);
    }

    log.trace("build() - columnName = '{}' value = '{}'", columnName, value);
    MsSqlColumnValue columnValue = new MsSqlColumnValue(columnName, schema, value);
    change.valueColumns.add(columnValue);
    if (tableMetadata.keyColumns().contains(columnName)) {
      change.keyColumns.add(columnValue);
    }
  }

  return change;
}
 
开发者ID:jcustenborder,项目名称:kafka-connect-cdc-mssql,代码行数:70,代码来源:MsSqlChange.java

示例13: getNullableResult

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public Byte getNullableResult(ResultSet rs, String columnName) throws SQLException {
	return rs.getByte(columnName);
}
 
开发者ID:xsonorg,项目名称:tangyuan2,代码行数:5,代码来源:ByteTypeHandler.java

示例14: getValue

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
protected Byte getValue(ResultSet rs, String columnName)
        throws SQLException {
    return rs.getByte(columnName);
}
 
开发者ID:tiglabs,项目名称:jsf-core,代码行数:6,代码来源:ConvertableEnumTypeHandler.java

示例15: getValue

import java.sql.ResultSet; //导入方法依赖的package包/类
private static Object getValue(ResultSet resultSet, int type, int j,
    Calendar calendar) throws SQLException {
  switch (type) {
  case Types.BIGINT:
    final long aLong = resultSet.getLong(j + 1);
    return aLong == 0 && resultSet.wasNull() ? null : aLong;
  case Types.INTEGER:
    final int anInt = resultSet.getInt(j + 1);
    return anInt == 0 && resultSet.wasNull() ? null : anInt;
  case Types.SMALLINT:
    final short aShort = resultSet.getShort(j + 1);
    return aShort == 0 && resultSet.wasNull() ? null : aShort;
  case Types.TINYINT:
    final byte aByte = resultSet.getByte(j + 1);
    return aByte == 0 && resultSet.wasNull() ? null : aByte;
  case Types.DOUBLE:
  case Types.FLOAT:
    final double aDouble = resultSet.getDouble(j + 1);
    return aDouble == 0D && resultSet.wasNull() ? null : aDouble;
  case Types.REAL:
    final float aFloat = resultSet.getFloat(j + 1);
    return aFloat == 0D && resultSet.wasNull() ? null : aFloat;
  case Types.DATE:
    final Date aDate = resultSet.getDate(j + 1, calendar);
    return aDate == null
        ? null
        : (int) (aDate.getTime() / DateTimeUtils.MILLIS_PER_DAY);
  case Types.TIME:
    final Time aTime = resultSet.getTime(j + 1, calendar);
    return aTime == null
        ? null
        : (int) (aTime.getTime() % DateTimeUtils.MILLIS_PER_DAY);
  case Types.TIMESTAMP:
    final Timestamp aTimestamp = resultSet.getTimestamp(j + 1, calendar);
    return aTimestamp == null ? null : aTimestamp.getTime();
  case Types.ARRAY:
    final Array array = resultSet.getArray(j + 1);
    if (null == array) {
      return null;
    }
    try {
      // Recursively extracts an Array using its ResultSet-representation
      return extractUsingResultSet(array, calendar);
    } catch (UnsupportedOperationException | SQLFeatureNotSupportedException e) {
      // Not every database might implement Array.getResultSet(). This call
      // assumes a non-nested array (depends on the db if that's a valid assumption)
      return extractUsingArray(array, calendar);
    }
  case Types.STRUCT:
    Struct struct = resultSet.getObject(j + 1, Struct.class);
    Object[] attrs = struct.getAttributes();
    List<Object> list = new ArrayList<>(attrs.length);
    for (Object o : attrs) {
      list.add(o);
    }
    return list;
  default:
    return resultSet.getObject(j + 1);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:61,代码来源:JdbcResultSet.java


注:本文中的java.sql.ResultSet.getByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。