Implementation:APIJSON APIJSON Demo DemoSQLExecutor SimpleDemo
| 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
- Repository: APIJSON_APIJSON_Demo
- File: APIJSON-Java-Server/APIJSONSimpleDemo-SpringBoot3/src/main/java/com/example/apijsondemo/DemoSQLExecutor.java
- Lines: 1-109
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)