How mrmanendra/sql2rest works
sql2rest is a Java service that turns SQL entries in a properties file into JSON REST endpoints. At startup, the application initializes Spring components and starts the HTTP API; each generated endpoint substitutes query parameters, invokes SQL execution, and returns database rows as JSON. The API also exposes a health check and a reload route for updating configured queries without restarting. The source excerpts show the principal calls and property reads; the README documents the endpoint behavior and reload capability.
Main entry points: DataApi.java REST endpoints · PropertyUtils.java Property loading · Application.java Application entry · SqlFetcher.java SQL execution and JSON
Components 11
Application startup
- Application entry
src/main/java/com/sql2rest/Application.java - Spring component scan
src/main/java/com/sql2rest/config/AppConfig.java
REST and query routing
- REST endpoints
src/main/java/com/sql2rest/controller/DataApi.java - JSON response
Configuration and database
- Property loading
src/main/java/com/sql2rest/util/PropertyUtils.java - Runtime settings
sample-distribution/config.properties - SQL endpoint definitions
sample-distribution/sql.properties - SQL execution and JSON
src/main/java/com/sql2rest/service/SqlFetcher.java - JDBC connection
src/main/java/com/sql2rest/db/connection/DBConnectionUtil.java
Other components
- API client
- Relational database
Connections 15
- Application entry → Spring component scan: initializes
src/main/java/com/sql2rest/Application.java - Application entry → REST endpoints: starts API
src/main/java/com/sql2rest/Application.java - Spring component scan → REST endpoints: scans components
src/main/java/com/sql2rest/config/AppConfig.java - Application entry → Property loading: reads port
src/main/java/com/sql2rest/Application.java - API client → REST endpoints: requests endpoint
README.md - REST endpoints → Property loading: loads query keys
src/main/java/com/sql2rest/controller/DataApi.java - Property loading → SQL endpoint definitions: reads queries
src/main/java/com/sql2rest/util/PropertyUtils.java - REST endpoints → Property loading: reloads settings
src/main/java/com/sql2rest/controller/DataApi.java - Property loading → Runtime settings: reads settings
src/main/java/com/sql2rest/util/PropertyUtils.java - REST endpoints → SQL execution and JSON: executes query
src/main/java/com/sql2rest/controller/DataApi.java - SQL execution and JSON → JDBC connection: gets connection
src/main/java/com/sql2rest/service/SqlFetcher.java - JDBC connection → Property loading: reads DB settings
src/main/java/com/sql2rest/db/connection/DBConnectionUtil.java - JDBC connection → Relational database: connects via JDBC
src/main/java/com/sql2rest/db/connection/DBConnectionUtil.java - SQL execution and JSON → Relational database: runs SQL
src/main/java/com/sql2rest/service/SqlFetcher.java - REST endpoints → JSON response: returns JSON
src/main/java/com/sql2rest/controller/DataApi.java