Show/Hide Toolbars

TMS XData Documentation

Navigation: Getting Started > Creating the Server Manually

Example 1: In-memory SQLite for testing/development

Scroll Prev Top Next More

The following example is a minimum console application that illustrates how to start an XData server at address "http://localhost:2001/tms/music" using an in-memory SQLite database. It uses an unit named "AureliusEntities" which is not shown here for simplification. Such a unit should just contain the Aurelius mapped classes that will be exposed by the server.


An extra note about this example: Since it is an in-memory database, the database will be empty every time the server starts. Thus, before the server starts, the method "UpdateDatabase(Connection)", which is declared in unit DatabaseUtils (also not listed here), will be called to create the required tables and data. Such a thing is a regular TMS Aurelius procedure and is out of the scope of this example as well. The purpose of this example is to show how to start an XData server.


program SQLiteConsoleServer;
procedure StartServer;
  Server: THttpSysServer;
  Connection: IDBConnection;
  Server := THttpSysServer.Create;
    Connection := TSQLiteNativeConnectionAdapter.Create(':memory:');
        function: IDBConnection
          Result := Connection;
    WriteLn('Server started. Press ENTER to stop.');