Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:APIJSON APIJSON Demo DataBuildResultSet

From Leeroopedia
Knowledge Sources
Domains Database, Data_Mapping, Redis
Last Updated 2026-10-14 00:00 GMT

Overview

Concrete tool for wrapping in-memory list data as a JDBC ResultSet so the APIJSON framework can process non-JDBC data sources (like Redis) through its standard SQL execution pipeline.

Description

The DataBuildResultSet class implements the java.sql.ResultSet interface, wrapping List<List<Object>> row data and List<String> column headers. It allows the RediSQL DemoSQLExecutor to return Redis query results through APIJSON's standard executeQuery pipeline, which expects a ResultSet. It supports cursor navigation (next()), column lookups by index and name, and standard type extraction methods (getString, getInt, getLong, etc.).

Usage

Use this class when you need to adapt non-relational data sources (Redis, Elasticsearch, Kafka) to the APIJSON SQL executor's JDBC-based ResultSet contract.

Code Reference

Source Location

Signature

public class DataBuildResultSet implements ResultSet {
    private int index = -1;
    private List<List<Object>> rows;
    private List<Object> current = null;
    private List<String> headers = null;
    private ResultSetMetaData metaData;

    public DataBuildResultSet(Statement statement, final List<String> headers, final List<List<Object>> lines);

    @Override
    public boolean next() throws SQLException;
    @Override
    public String getString(int columnIndex) throws SQLException;
    @Override
    public String getString(String columnLabel) throws SQLException;
    @Override
    public int getInt(int columnIndex) throws SQLException;
    @Override
    public long getLong(int columnIndex) throws SQLException;
    // ... all ResultSet methods
}

Import

import apijson.demo.resultSet.DataBuildResultSet;

I/O Contract

Inputs

Name Type Required Description
statement Statement No JDBC statement (can be null)
headers List<String> Yes Column header names
lines List<List<Object>> Yes Row data as list of lists

Outputs

Name Type Description
next() returns boolean Whether more rows remain
getString/getInt/etc. T Typed cell values from current row
getMetaData() returns ResultSetMetaData Column metadata wrapper

Usage Examples

Wrap Redis Data as ResultSet

import apijson.demo.resultSet.DataBuildResultSet;
import java.util.List;
import java.util.ArrayList;

// Build row data from Redis query results
List<String> headers = List.of("key", "value", "score");
List<List<Object>> rows = new ArrayList<>();
rows.add(List.of("user:1", "Alice", 100));
rows.add(List.of("user:2", "Bob", 200));

// Create ResultSet
DataBuildResultSet rs = new DataBuildResultSet(null, headers, rows);

// Iterate like a normal JDBC ResultSet
while (rs.next()) {
    String key = rs.getString("key");
    String value = rs.getString("value");
    int score = rs.getInt("score");
    System.out.println(key + " = " + value + " (score=" + score + ")");
}
rs.close();

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment