Share My Creation [Project Template] jRDC3 Server

jRDC3 Server Template​

Version: 3.60 (based on jRDC3 Server version 3.00)

GitHub: https://github.com/pyhoon/jrdc3-server-template

Overview​

A B4J template for creating a jRDC3 remote database server — an HTTP-based middleware that bridges B4X client applications (B4A, B4i, B4J) with your database, exposing SQL operations through a simple binary-serialized protocol.


Note: Connections between clients and server are bi-directional.

Work with jRDC2 Client template and jRDC3 Client template.
 

Attachments

  • jRDC3r3.png
    437.1 KB · Views: 259
  • jRDC3 Server (3.60).b4xtemplate
    36.4 KB · Views: 61
Last edited:

aeric

Expert
Licensed User
Longtime User

Features​

  • Multi-database support — SQLite, MySQL, MariaDB, MSSQL, PostgreSQL, Firebird, DBF
  • Zero-config SQLite — works out of the box with a bundled sample database
  • HTTP API — clients send DBCommand objects over HTTP and receive DBResult responses
  • Batch transactions — execute multiple INSERT/UPDATE/DELETE statements atomically
  • SSL/TLS — optional HTTPS with configurable keystore
  • Auto-provisioning — creates tables and seed data on first run
  • Health check — /test endpoint verifies database connectivity
  • Status dashboard — browser-based UI at / with HTMX-powered auto-refresh
  • Request log viewer — real-time request log via HTMX polling, shown in a modal
  • Debug mode — hot-reload SQL queries from config file on each request
  • 6 build configurations — one-click select the database driver in the IDE
 
Last edited:

aeric

Expert
Licensed User
Longtime User

Supported Databases​

Note: Please check vulnerabilities before download.
These versions are tested by me during development of jRDC2 Server Template. You can always download the newer versions.
 
Last edited:

aeric

Expert
Licensed User
Longtime User

Getting Started​

Using the template (end-user)​

  1. Copy or install the .b4xtemplate file from release/ into your B4J Additional Libraries folder.
  2. In B4J, create a new project using the jRDC3 Server template.
  3. Select your database Build Configuration (SQLite is the default).
  4. Open Files/config.properties and set your database connection details.
  5. Press F5 (Run).
  6. Visit http://127.0.0.1:17178/ to see the status dashboard.

Building the template (from source) using #Macros​

  1. Clone jRDC3.b4j to $APPNAME$.b4j.
  2. Open $APPNAME$.b4j in a new B4J windows.
    Remove #Macro Step 1 to Step 5 and close it.
  3. Package the template to release/jRDC3 Server (3.60).b4xtemplate.
  4. Copy the .b4xtemplate file to B4J's Additional Libraries directory.
  5. Check the created template in target directory.
 
Last edited:

aeric

Expert
Licensed User
Longtime User

Configuration​

All settings are in Files/config.properties:

SectionKeyDefault
ServerServerPort17178
ServerSSLPort0 (disabled)
ServerDebugQueriesTrue
SQLiteSQLite.DBFilesample.db
MySQLMySQL.JdbcUrljdbc:mysql://localhost:3306/{DBName}
MSSQLMSSQL.JdbcUrljdbc:sqlserver://localhost:1433;databaseName={DBName}
PostgreSQLPostgresql.JdbcUrljdbc:postgresql://localhost:5432/{DBName}
FirebirdFirebird.JdbcUrljdbc:firebirdsql://localhost:3050/{DBName}
DBFDBF.DBFDir(directory of .dbf files)
SQL Queries(per-database)Predefined CRUD for tbl_category & tbl_products
To enable SSL, set SSLPort, SSL_KEYSTORE_FILE, and SSL_KEYSTORE_PASSWORD.
 
Last edited:

aeric

Expert
Licensed User
Longtime User

API Endpoints​

EndpointMethodDescription
/GETStatus dashboard (HTML)
/testGETHealth check — returns DB connection status as HTML
/rdcPOSTExecute a DBCommand (query or batch) — returns DBResult
/logGETReturns recent request log entries as HTML (used by dashboard modal)

/rdc Protocol​

The /rdc endpoint accepts POST requests with a binary-serialized DBCommand payload:
  • method=query2 — Execute a SELECT query, returns rows via B4XSerializator
  • method=batch2 — Execute multiple DML statements in a single transaction
Both client and server share the DBCommand / DBResult type definitions.
 
Last edited:

aeric

Expert
Licensed User
Longtime User

Architecture​

B4X:
┌──────────────┐      HTTP (B4XSerializator)       ┌──────────────────┐
│  B4A / B4i   │  ──────────────────────────────>  │  jRDC3 Server    │
│  / B4J App   │  <──────────────────────────────  │  (B4J / Java)    │
└──────────────┘                                   └────────┬─────────┘
                                                            │ JDBC
                                                            ▼
                                                   ┌──────────────────┐
                                                   │   Database       │
                                                   │  (SQLite/MySQL/  │
                                                   │   MSSQL/etc.)    │
                                                   └──────────────────┘
The server uses B4XSerializator for binary serialization, jserver for HTTP handling, and jsql for database access.
 

aeric

Expert
Licensed User
Longtime User

Modules​

ModuleResponsibility
IndexHandler.basServes the dashboard homepage (/) and health check (/test)
RDCHandler.basProcesses /rdc requests — query and batch execution
RDCConnector.basDatabase connection management and SQL query loading
HttpsFilter.basOptional HTTP-to-HTTPS redirect filter
LogHandler.basReturns the last 50 request log entries at /log
 
Last edited:

aeric

Expert
Licensed User
Longtime User
Version: 3.60 (rev 3)
With "Request Log" button on Index page (bottom left). Clicking the button shows a modal dialog and list of requests.
The log caps at 50 entries (FIFO).

The list is auto-refreshes every 2s via HTMX while open.

Please download the update on post #1.
 
Last edited:

Mashiane

Expert
Licensed User
Longtime User
Perhaps include download locations for the drivers. This makes everything easy to find.
 

aeric

Expert
Licensed User
Longtime User

Differences from original jRDC3 Server​

1. LoadSQLCommands​

Original:
Private Sub LoadSQLCommands(Config As Map)
    Dim newCommands As Map
    newCommands.Initialize
    For Each k As String In Config.Keys
        If k.StartsWith("sql.") Then
            newCommands.Put(k, Config.Get(k))
        End If
    Next
    commands = newCommands
End Sub
Modified:
Private Sub LoadSQLCommands
    mCommands.Initialize
    For Each Key As String In mConfig.Keys
        If Key.StartsWith(mDbType & ".SQL.") Or Key.StartsWith("SQL.") Then
            mCommands.Put(Key, mConfig.Get(Key))
        End If
    Next
End Sub
Check config.properties to find the differences.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…