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 DemoSQLExecutor SimpleDemo

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

Overview

Concrete tool for executing SQL with BigInt/Long precision-loss prevention and multi-datasource connection routing in the APIJSON SimpleDemo Spring Boot 3 variant.

Description

The DemoSQLExecutor class (SimpleDemo variant) extends APIJSONSQLExecutor<Long> and overrides getValue to convert BigInteger and large Long values (>15 digits) to strings, preventing JavaScript precision loss. It also overrides getConnection to route connections by datasource name (db1, db2) via Spring bean lookup.

Usage

Use this class when the APIJSON SimpleDemo needs to prevent ID precision loss for large bigint values and route to multiple named datasources.

Code Reference

Source Location

Signature

public class DemoSQLExecutor extends APIJSONSQLExecutor<Long> {
    @Override
    protected Object getValue(SQLConfig<Long> config, ResultSet rs, ResultSetMetaData rsmd, int tablePosition,
            JSONObject table, int columnIndex, String lable, Map<String, JSONObject> childMap) throws Exception;
    @Override
    public Connection getConnection(SQLConfig<Long> config) throws Exception;
}

Import

import com.example.apijsondemo.DemoSQLExecutor;

I/O Contract

Inputs

Name Type Required Description
config SQLConfig Yes SQL config with datasource name
rs ResultSet Yes JDBC result set
columnIndex int Yes Column index for value extraction

Outputs

Name Type Description
getValue() returns Object Typed value; BigInt/Long>15 digits converted to String

Usage Examples

// Large bigint IDs are automatically converted to strings
// to prevent JavaScript precision loss:
// Database: 123456789012345678 (Long)
// JSON output: "123456789012345678" (String)

Related Pages

Page Connections

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