ResultSet.getBytes
Code IndexAdd Codota to your IDE (free)

Best code snippets using java.sql.ResultSet.getBytes(Showing top 20 results out of 2,205)

Refine search

  • ResultSet.next
  • PreparedStatement.executeQuery
  • Connection.prepareStatement
  • ResultSet.getString
  • Common ways to obtain ResultSet
private void myMethod () {
ResultSet r =
  • PreparedStatement ps;ps.executeQuery()
  • Statement stmt;stmt.executeQuery(sql)
  • Statement statement;statement.getResultSet()
  • AI code suggestions by Codota
}
origin: deeplearning4j/deeplearning4j

private <T> T queryAndGet(String sql, int columnIndex) {
  try (Statement statement = connection.createStatement()) {
    ResultSet rs = statement.executeQuery(sql);
    if (!rs.next())
      return null;
    byte[] bytes = rs.getBytes(columnIndex);
    return deserialize(bytes);
  } catch (SQLException e) {
    throw new RuntimeException(e);
  }
}
origin: prestodb/presto

  @Override
  public ShardNode map(int index, ResultSet r, StatementContext ctx)
      throws SQLException
  {
    return new ShardNode(
        uuidFromBytes(r.getBytes("shard_uuid")),
        r.getString("node_identifier"));
  }
}
origin: com.h2database/h2

private byte[] fetch() {
  try {
    prep.setInt(2, seq++);
    ResultSet rs = prep.executeQuery();
    if (rs.next()) {
      return rs.getBytes(1);
    }
    return null;
  } catch (SQLException e) {
    throw DbException.convert(e);
  }
}
origin: mysql/mysql-connector-java

public Xid[] recover(int flag) throws XAException {
  return recover(this.underlyingConnection, flag);
}
origin: mysql/mysql-connector-java

protected void getBatchedGeneratedKeys(java.sql.Statement batchedStatement) throws SQLException {
  synchronized (checkClosed().getConnectionMutex()) {
    if (this.retrieveGeneratedKeys) {
      java.sql.ResultSet rs = null;
      try {
        rs = batchedStatement.getGeneratedKeys();
        while (rs.next()) {
          this.batchedGeneratedKeys.add(new ByteArrayRow(new byte[][] { rs.getBytes(1) }, getExceptionInterceptor()));
        }
      } finally {
        if (rs != null) {
          rs.close();
        }
      }
    }
  }
}
origin: prestodb/presto

/**
 * Compute split-per-shard (separate split for each shard).
 */
private BucketShards compute()
    throws SQLException
{
  if (!resultSet.next()) {
    return endOfData();
  }
  UUID shardUuid = uuidFromBytes(resultSet.getBytes("shard_uuid"));
  Set<String> nodeIdentifiers;
  OptionalInt bucketNumber = OptionalInt.empty();
  if (bucketToNode != null) {
    int bucket = resultSet.getInt("bucket_number");
    bucketNumber = OptionalInt.of(bucket);
    nodeIdentifiers = ImmutableSet.of(getBucketNode(bucket));
  }
  else {
    List<Integer> nodeIds = intArrayFromBytes(resultSet.getBytes("node_ids"));
    nodeIdentifiers = getNodeIdentifiers(nodeIds, shardUuid);
  }
  ShardNodes shard = new ShardNodes(shardUuid, nodeIdentifiers);
  return new BucketShards(bucketNumber, ImmutableSet.of(shard));
}
origin: stackoverflow.com

String imageName = request.getPathInfo().substring(1); // Returns "foo.png".
try (Connection connection = dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement(SQL_FIND)) {
  statement.setString(1, imageName);
  try (ResultSet resultSet = statement.executeQuery()) {
    if (resultSet.next()) {
      byte[] content = resultSet.getBytes("content");
      response.setContentType(getServletContext().getMimeType(imageName));
      response.setContentLength(content.length);
origin: prestodb/presto

/**
 * Compute split-per-bucket (single split for all shards in a bucket).
 */
private BucketShards computeMerged()
    throws SQLException
{
  if (resultSet.isAfterLast()) {
    return endOfData();
  }
  if (first) {
    first = false;
    if (!resultSet.next()) {
      return endOfData();
    }
  }
  int bucketNumber = resultSet.getInt("bucket_number");
  ImmutableSet.Builder<ShardNodes> shards = ImmutableSet.builder();
  do {
    UUID shardUuid = uuidFromBytes(resultSet.getBytes("shard_uuid"));
    int bucket = resultSet.getInt("bucket_number");
    Set<String> nodeIdentifiers = ImmutableSet.of(getBucketNode(bucket));
    shards.add(new ShardNodes(shardUuid, nodeIdentifiers));
  }
  while (resultSet.next() && resultSet.getInt("bucket_number") == bucketNumber);
  return new BucketShards(OptionalInt.of(bucketNumber), shards.build());
}
origin: druid-io/druid

@Override
public List<StatusType> getInactiveStatusesSince(DateTime timestamp, @Nullable Integer maxNumStatuses)
{
 return getConnector().retryWithHandle(
   handle -> {
    final Query<Map<String, Object>> query = createInactiveStatusesSinceQuery(handle, timestamp, maxNumStatuses);
    return query
      .map(
        (ResultSetMapper<StatusType>) (index, r, ctx) -> {
         try {
          return getJsonMapper().readValue(
            r.getBytes("status_payload"),
            getStatusType()
          );
         }
         catch (IOException e) {
          log.makeAlert(e, "Failed to parse status payload")
            .addData("entry", r.getString("id"))
            .emit();
          throw new SQLException(e);
         }
        }
      ).list();
   }
 );
}
origin: mysql/mysql-connector-java

private synchronized void extractDefaultValues() throws SQLException {
  java.sql.DatabaseMetaData dbmd = this.getConnection().getMetaData();
  this.defaultColumnValue = new byte[this.getMetadata().getFields().length][];
  java.sql.ResultSet columnsResultSet = null;
  for (Map.Entry<String, Map<String, Map<String, Integer>>> dbEntry : this.databasesUsedToTablesUsed.entrySet()) {
    for (Map.Entry<String, Map<String, Integer>> tableEntry : dbEntry.getValue().entrySet()) {
      String tableName = tableEntry.getKey();
      Map<String, Integer> columnNamesToIndices = tableEntry.getValue();
      try {
        columnsResultSet = dbmd.getColumns(this.catalog, null, tableName, "%");
        while (columnsResultSet.next()) {
          String columnName = columnsResultSet.getString("COLUMN_NAME");
          byte[] defaultValue = columnsResultSet.getBytes("COLUMN_DEF");
          if (columnNamesToIndices.containsKey(columnName)) {
            int localColumnIndex = columnNamesToIndices.get(columnName).intValue();
            this.defaultColumnValue[localColumnIndex] = defaultValue;
          } // else assert?
        }
      } finally {
        if (columnsResultSet != null) {
          columnsResultSet.close();
          columnsResultSet = null;
        }
      }
    }
  }
}
origin: com.h2database/h2

PreparedStatement prep = prepare(sql);
prep.setLong(1, block);
ResultSet rs = prep.executeQuery();
if (!rs.next()) {
  throw DbException.get(ErrorCode.IO_EXCEPTION_1,
      "Missing lob entry, block: " + block)
byte[] buffer = rs.getBytes(2);
if (compressed != 0) {
  buffer = compress.expand(buffer);
origin: mysql/mysql-connector-java

protected void getBatchedGeneratedKeys(int maxKeys) throws SQLException {
  synchronized (checkClosed().getConnectionMutex()) {
    if (this.retrieveGeneratedKeys) {
      java.sql.ResultSet rs = null;
      try {
        if (maxKeys == 0) {
          rs = getGeneratedKeysInternal();
        } else {
          rs = getGeneratedKeysInternal(maxKeys);
        }
        while (rs.next()) {
          this.batchedGeneratedKeys.add(new ByteArrayRow(new byte[][] { rs.getBytes(1) }, getExceptionInterceptor()));
        }
      } finally {
        this.isImplicitlyClosingResults = true;
        try {
          if (rs != null) {
            rs.close();
          }
        } finally {
          this.isImplicitlyClosingResults = false;
        }
      }
    }
  }
}
origin: apache/storm

try {
  connection = connectionProvider.getConnection();
  try (PreparedStatement preparedStatement = connection.prepareStatement(sqlQuery)) {
    if (queryTimeoutSecs > 0) {
      preparedStatement.setQueryTimeout(queryTimeoutSecs);
    try (ResultSet resultSet = preparedStatement.executeQuery()) {
      List<List<Column>> rows = Lists.newArrayList();
      while (resultSet.next()) {
        ResultSetMetaData metaData = resultSet.getMetaData();
        int columnCount = metaData.getColumnCount();
          Class columnJavaType = Util.getJavaType(columnType);
          if (columnJavaType.equals(String.class)) {
            row.add(new Column<String>(columnLabel, resultSet.getString(columnLabel), columnType));
          } else if (columnJavaType.equals(Integer.class)) {
            row.add(new Column<Integer>(columnLabel, resultSet.getInt(columnLabel), columnType));
            row.add(new Column<Boolean>(columnLabel, resultSet.getBoolean(columnLabel), columnType));
          } else if (columnJavaType.equals(byte[].class)) {
            row.add(new Column<byte[]>(columnLabel, resultSet.getBytes(columnLabel), columnType));
          } else if (columnJavaType.equals(Long.class)) {
            row.add(new Column<Long>(columnLabel, resultSet.getLong(columnLabel), columnType));
origin: prestodb/presto

byte[] bytes = resultSet.getBytes(i + 1);
nulls[i] = resultSet.wasNull();
strings[i] = nulls[i] ? null : uuidFromBytes(bytes).toString().toLowerCase(ENGLISH);
String value = resultSet.getString(i + 1);
nulls[i] = resultSet.wasNull();
strings[i] = nulls[i] ? null : value;
origin: com.h2database/h2

PreparedStatement prep = prepare(sql);
prep.setLong(1, block);
ResultSet rs = prep.executeQuery();
if (rs.next()) {
  boolean compressed = rs.getInt(1) != 0;
  byte[] compare = rs.getBytes(2);
  if (compressed == (compressAlgorithm != null) && Arrays.equals(b, compare)) {
    blockExists = true;
origin: shardingjdbc/sharding-jdbc

  result = getCurrentResultSet().getDouble(columnIndex);
} else if (String.class == type) {
  result = getCurrentResultSet().getString(columnIndex);
} else if (BigDecimal.class == type) {
  result = getCurrentResultSet().getBigDecimal(columnIndex);
} else if (byte[].class == type) {
  result = getCurrentResultSet().getBytes(columnIndex);
} else if (Date.class == type) {
  result = getCurrentResultSet().getDate(columnIndex);
origin: mysql/mysql-connector-java

while (results.next()) {
  TypeDescriptor typeDesc = new TypeDescriptor(results.getString("Type"), results.getString("Null"));
  byte[][] rowVal = new byte[8][];
  rowVal[0] = null;                                                                           // SCOPE is not used
  rowVal[1] = results.getBytes("Field");                                                      // COLUMN_NAME
  rowVal[2] = Short.toString((short) typeDesc.mysqlType.getJdbcType()).getBytes();                                   // DATA_TYPE
  rowVal[3] = s2b(typeDesc.mysqlType.getName());                                                         // TYPE_NAME
origin: mysql/mysql-connector-java

while (results.next()) {
  String keyType = results.getString("Key");
      byte[][] rowVal = new byte[8][];
      rowVal[0] = Integer.toString(java.sql.DatabaseMetaData.bestRowSession).getBytes();
      rowVal[1] = results.getBytes("Field");
      String type = results.getString("Type");
      int size = stmt.getMaxFieldSize();
      int decimals = 0;
origin: MyCATApache/Mycat-Server

while (rs.next()) {
  RowDataPacket curRow = new RowDataPacket(colunmCount);
  for (int i = 0; i < colunmCount; i++) {
    int j = i + 1;
    if(MysqlDefs.isBianry((byte) fieldPks.get(i).type)) {
        curRow.add(rs.getBytes(j));
    } else if(fieldPks.get(i).type == MysqlDefs.FIELD_TYPE_DECIMAL ||
        fieldPks.get(i).type == (MysqlDefs.FIELD_TYPE_NEW_DECIMAL - 256)) { // field type is unsigned byte
          sc.getCharset()));
    } else {
        curRow.add(StringUtil.encode(rs.getString(j),
            sc.getCharset()));
origin: mysql/mysql-connector-java

if (rs.next()) {
  for (int i = 0; i < numCols; i++) {
    byte[] val = rs.getBytes(i + 1);
      rowToRefresh.setBytes(i, rs.getBytes(i + 1));
java.sqlResultSetgetBytes

Javadoc

Retrieves the value of the designated column in the current row of this ResultSet object as a byte array in the Java programming language. The bytes represent the raw values returned by the driver.

Popular methods of ResultSet

  • next
    Shifts the cursor position down one row in this ResultSet object. Any input streams associated with
  • getString
    Gets the value of a column specified by column name, as a String.
  • close
    Releases this ResultSet's database and JDBC resources. You are strongly advised to use this method r
  • getInt
    Gets the value of a column specified by column name, as an intvalue.
  • getLong
    Gets the value of a column specified by column name, as a longvalue.
  • getMetaData
    Gets the metadata for this ResultSet. This defines the number, types and properties of the columns i
  • getObject
    Gets the value of a column specified by column name as a Java Object. The type of the Java object wi
  • getTimestamp
    Gets the value of a column specified by column name, as a java.sql.Timestamp value. The supplied Cal
  • getBoolean
    Gets the value of a column specified by column name, as a boolean.
  • getDouble
    Gets the value of a column specified by column name as a doublevalue.
  • wasNull
    Determines whether the last column read from this ResultSetcontained SQL NULL.
  • getDate
    Gets the value of a column specified by column name, as a java.sql.Date object.
  • wasNull,
  • getDate,
  • getFloat,
  • getShort,
  • getBlob,
  • getTime,
  • getBigDecimal,
  • getBinaryStream,
  • getByte

Popular classes and methods

  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • setRequestProperty (URLConnection)
    Sets the value of the specified request header field. The value will only be used by the current URL
  • setScale (BigDecimal)
    Returns a new BigDecimal instance with the specified scale. If the new scale is greater than the old
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • JComboBox (javax.swing)
  • Option (scala)

For IntelliJ IDEA and
Android Studio

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)